Rust is faster than C, even before I added SIMD
I found some old C code of mine from around 2001 or so. I vaguely remember trying to make it as optimized as possible. Sure, I was still a teenager, so it’s not state of the art. But it’s not half bad. I vaguely suspect I could do better with better optimization for cache lines, but it’s pretty good.
On my current laptop it does about 12 million passwords per second, single threaded.
Because I’m learning Rust, I decided to port it, and see how fast rust is.
Imagine my surprise when even the first version in Rust was faster. (Yes, I rebuilt the old C code with a modern compiler and its optimizations)
The first Rust version was about 13 million passwords per second.
Why is that? It’s basically the same as the C code. Maybe Rust can take advantage of knowing there’s no pointer aliasing (the reason usually quoted for why Fortran can be faster than C)? Or maybe the memory layout just happened to become more cache friendly?
In any case, I think we can already say that Rust is at least as fast as C.
The code is on github.
SIMD (with Rust)
I realized, of Continue reading

