lines masked in circle
purple circle at half opacity

Is a Rust Rewrite Really Worth It?

grid of red dots
white dots in concentric circle

Share This Post

“Is a Rust rewrite really worth it” is not just a tongue twister. It’s a dilemma keeping engineers awake at night. Will the potential performance gains be worth all the effort of wrestling with a fast-growing language that is extremely well-loved, but not (yet) all that commonly used?

Of course, there’s no simple answer to how well a Rust rewrite will ultimately pay off for your project and your team. But there are lots of captivating stories about why teams considered Rust rewrites, what path they took and how it ultimately worked out for them.

P99 CONF, a free and virtual conference for engineers obsessed with all things performance, is turning into the premier venue for sharing these stories. The conference is dedicated to exploring how top engineers are solving their toughest high-performance, low-latency challenges. Not surprisingly, Rust always features quite prominently in the agenda. Last year’s most tweeted-about sessions included Bryan Cantrill’s whirlwind keynote on “Rust and the Future of Low-Latency Systems” and Glauber Costa’s deep dive into “Rust is Safe. But is it Fast?” which looked at async Rust development pitfalls that could affect your ability to hit that sweet low p99.

Editor’s Note: P99 CONF 2022 is now a wrap! You can (re)watch all videos and access the decks now.

ACCESS ALL THE VIDEOS AND DECKS NOW

In terms of Rust rewrite dilemmas, Brian Martin of Twitter was the star of last year’s P99 CONF – and we’re expecting Mark Gritter’s tale of avoiding a Rust rewrite from Go to generate an equal amount of interest and discussion this year. Here’s a quick look at both.

‘Whoops! I Rewrote It in Rust’ — Brian Martin, Software Engineer at Twitter

Brian MartinTwitter services’ scalability and efficiency are highly reliant on high-quality cache offerings. They developed Pelikan as a caching system when Memcached and Redis didn’t fully meet their needs. Their No.1 priority for Pelikan was “best-in-class efficiency and predictability through latency-oriented design and lean implementation.” This was initially achieved with a C implementation. However, two subsequent projects introduced Rust into the framework, with rather impressive development speed.

When they decided to add TLS support to Pelikan, Twitter software engineer Brian Martin suspected it could be done faster and more efficiently in Rust than in C. But to gain approval, the Rust implementation had to match (or beat) the performance of the C implementation.

Initial prototypes with the existing Rust-based Twemcache (the Twitter Memcached) didn’t look promising from the performance perspective; they yielded 25 to 50% higher P999 latency as well as 10 to15% slower throughputs. Even when Martin doubled down on optimizing the Rust prototype’s performance, he saw minimal impact. After yet more frustrating performance test results, he considered several different implementation approaches. Fortunately, just as he was weighing potential compromises, he came across a new storage design that made it easier to port the entire storage library over to Rust.

Martin went all in on Rust at that point with a simplified single-threaded application and all memory allocations managed in Rust. The result? The 100% Rust implementation not only delivered performance equal to — or exceeding — both the C implementation and memcached. It also improved the overall design and enabled coding with confidence thanks to “awesome language features and tools,” which Martin then dived into.

Watch Brian’s full session here:

‘Taming Go’s Memory Usage and Avoiding a Rust Rewrite’ — Mark Gritter, Founding Engineer at Akita Software

Mark Gritter is currently on startup No. 4, having previously worked on streaming video at Kealia; VM-aware flash data storage at Tintri as a co-founder; observability on the HashiCorp Vault team; and now API observability at Akita Software.

We’re eagerly anticipating hearing about his journey into – and out of– a Go trough of despair and learning why he decided to take the contrarian path of avoiding a Rust rewrite. You can catch his session and chat with him when P99 CONF 2022 goes live, Oct. 19 and 20. Until then, here’s Gritter’s preview of what’s in store.

“Last summer, my team and I faced a question many young startups face. Should we rewrite our system in Rust?

“At the time of the decision, we were primarily writing in Go. I was working on an agent that passively watches network traffic, parses API calls and sends obfuscated summaries back to our service for analysis. As users were starting to run more traffic through us, memory usage by the agent grew to an unacceptably high level, impacting performance.

“This led me to spend 25 days in despair and immerse myself in the details of Go’s memory management, our technology stack and the profiling tools available – trying to get our memory footprint back under control. Go’s fully automatic memory management makes this no easy feat.

“Spoiler: I emerged victorious and our team still uses Go. In this talk, I’ll talk about key steps and lessons learned from my project. I intend this talk to be helpful for people curious about reducing their memory footprint in Go, or anybody wondering about the tradeoffs of switching to or from Go.”

50+ Sessions at P99 CONF – Free and Virtual

P99CONF is not “just” a Rust conference. WebAssembly, databases, event streaming, Go, Java, Linux kernel, OpenTelemetry, eBPF, Kubernetes, chaos engineering, SLIs/SLOs – it’s all on the agenda.

On Oct. 19-20, thousands of engineers will be coming together online to:

  • Discover expert strategies from engineers at Uber, Lyft, Square, Google, Red Hat, Oracle, Redis, Microsoft and more.
  • Explore performance strategies from multiple perspectives – programming languages, CPUs, frontends, backends, frameworks and observability.
  • Learn from luminaries like Bryan Cantrill, Avi Kivity, Charity Majors, Liz Rice, Gil Tene, Ron Pressler, Armin Ronacher, Alex Hidalgo, Malte Ubl and Steven Rostedt.

Don’t miss this opportunity to join your peers for two free days of concentrated learning, skill sharpening, and community collaboration. Register for free.

REGISTER FOR P99 CONF TODAY

More To Explore

P99 CONF Day 1: The Low-Latency Lowdown

Day 1 of P99 CONF kicked off with “misery metrics” and ended with a look at P99 latency reduction as a Sisyphean task. In between, engineers spoke of their many hard-fought performance battles and lessons learned. And thousands of engineers attending live had a great time digging into all this pain and suffering.

Background Texture
Background Texture