Making Rust faster than C

Initiative supporters & funders

Past initiative supporters & funders

Rust, being a systems language, should be best in class for performance-sensitive software.

While the performance difference with C is small, it currently blocks performance-sensitive Rust implementations from being widely adopted. Why go through a challenging migration only to end up with a 1% performance drop or a 2% additional battery drain?

Our mission is to make critical infrastructure software safer. We must eliminate performance considerations as a barrier for adopting Rust in order to achieve this goal. This initiative exists to contribute to change, to change Rust's performance story with the ultimate goal of making it faster than C.

What we've done

Our work on zlib-rs put us on the path to improving the performance of state machines. Complex state machines are niche but foundational to many programs, such as parsers, interpreters, and networking protocols.

This work has resulted in a #[loop_match] language experiment. This language experiment achieves a 2.7X speedup on some parsers, and a 7% speedup in a zlib-rs benchmark. Exact numbers are here, and a blog post explaining loop-match is here.

Work plan

Work is in progress, see our workplan for details.
The work includes:

Please get in touch with us, if you are interested in financially supporting our effort.

Acknowledgements

We want to acknowledge the work done in the Zig ecosystem where our idea was taken from fairly directly, and thank joshtriplett, jackh726 and folks at the codegen unconf at GOSIM 2024 for providing feedback.

We also thank Tweede golf for supporting the initial effort, and NLnet, AWS and Tempo Labs for funding the milestone 1, State machine codegen, milestone 2, Identify performance bottlenecks and milestone 3, Tail calls.

What's next

The current work shows that there is room for improvement. While outperforming C is impossible in the general case, we believe the gap with C can be closed and in specific cases Rust can be faster. If we can make better use Rust's advantages over C, e.g., having more information available about a program, Rust can optimize better. Closing the performance gap of foundational systems libraries furthers adoption, and hence the spreading of Rust's advantages like memory safety and portability.

Are you interested in supporting our effort to make Rust faster? Contact us via rustfasterthanc@trifectatech.org.