Hashing across architectures
In a previous post, I mentioned how just because you develop on a brand new or nearly new laptop doesn't mean that's where your code is going to run, especially if it's deployed to the cloud. Compute has come a long way from the single core days. Pretty sure I have more cpu cores sitting on my desk between my laptop and desktop than all previous computers I've owned since college combined. But…
In a previous post, the author discussed the importance of understanding how code performs across different architectures and hardware when it is deployed in the cloud. They noted that even though developers may work with the latest laptops and machines, they might not have access to multiple machines or different architectures to test their code on. To illustrate this point, the author conducted an experiment comparing the performance of hashing passwords using different languages and crates on various hardware.
The experiment used a 16-byte salt, a 64-byte secret, the PBKDF2 algorithm with SHA256, and 500,000 iterations. The code was compiled in release mode for Rust and Odin, and built with the -D ReleaseSafe flag. The tests were run on a MacBook Pro M4 Pro with macOS 15.7.5 and CachyOS, Linux Kernel 7.1.8, and an AMD Ryzen 9 9950X with CachyOS and Linux Kernel 7.1.8.
The results showed that performance varied between language choice and architecture, with the Mac M series chips showing a clear advantage. For example, Rust with the aws-lc-rs crate ran in 66ms, while Zig with the same crate took 123ms. The author emphasized the importance of testing code against the hardware it will run on, especially if the task is expensive and could potentially block on the server.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.