Hacker News new | ask | show | jobs
by PEJOE 1868 days ago
Looking at the 99% times and memory usage, it looks to me like rust came out on top if you’re looking at best worst-case performance. Any idea why the tail latency was so much better for rust vs Java or c++? E.g. specific work that went into it or language optimizations?
2 comments

I've heard the anecdote many times that the idiomatic way of writing Rust tends to also be performant. I've spent some time fiddling with C code to reuse buffers and avoid copies, make loops amenable to auto vectorization. Many times my first try in Rust will still be faster. In C reusing memory over and over is dangerous and confusing. In Rust it's the default because you use borrowing and transfer ownership.

My guess is that little time was spent optimizing the C++ and Rust codebase, and Rust performs better because the code doesn't do copies.

My money is on garbage collection. In Rust it can happen from compile time: https://stackoverflow.com/a/32677591/235463
That doesn’t explain C++’s poor tail performance, unless it’s just poorly optimized like the top comment suggested
Yes it’s hard to tell without looking at the Java options. But especially since it’s a single cpu benchmark, it’s likely something blocked for a period of time.