Atomic variables are not only about atomicity

The code compiles. All the tests pass. The staging environment is healthy. Yet once per day a few servers in the production fleet mysteriously observe a crash with an error message that makes no sense – unreachable code has been reached, we have taken 9 items out of a collection that can only hold 8, or similar. Welcome to the world of rolling your own synchronization primitives.

Memory allocation is the root of all evil, part 2: Rust

A previous article illustrated how algorithms written in naïve C# can easily underperform due to being sloppy with memory allocations. It is a common assumption for engineers moving from the .NET world to the Rust world that this problem is automatically solved by Rust because "Rust is more efficient". Alas, this is not the case. … Continue reading Memory allocation is the root of all evil, part 2: Rust

Structural changes for +48-89% throughput in a Rust web service

Optimizing algorithms can be demanding work, requiring a fine-grained understanding of what the processor is doing, involving many repeated measurement and adjustment iterations, depending on a theoretical understanding of computer science principles and mathematics, requiring specialized tooling and the knowledge of how to use it. This article is about something completely different. We will take … Continue reading Structural changes for +48-89% throughput in a Rust web service

You do not need multithreading to do more than one thing at a time

As hardware gets faster and more capable, software keeps getting slower. It is remarkable how inefficiently typical apps use the capabilities of modern processors! Often this means an app is doing only one thing at a time when it could do multiple things simultaneously, even on a single thread. This article explores a technique for … Continue reading You do not need multithreading to do more than one thing at a time

Why is std::pin::Pin so weird?

Values of certain Rust types need to be pinned, which prevents them from moving in memory. This is expressed via the std::pin::Pin wrapper type and is typically encountered in the form of a function accepting Pin<&mut T> instead of &mut T. Pinning makes using many “normal” programming techniques difficult and has strange side-effects that do … Continue reading Why is std::pin::Pin so weird?