Re:gRPC benchmark results
by throwaway050821 on Saturday May 08, 2021 @10:23AM
(#27087382)
I worked on gRPC Java optimization for a few years. The primary reason it is so fast is because it does hardly anything, and avoids synchronization. However, there is a deeper reason why Java was so much faster: more people were working on making it faster. The external C++ version of gRPC was ignored for years, with people focusing on optimizing the internal version. The other languages (C#, Python, etc.) all had significantly less attention that Java did, so they aren't nearly as polished. It's been amusing to watch how stirred up people get about how fast a "language" is, rather than how much time has been spent optimizing the particular implementation.
[ Parent
| on HN ]
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?
Re:gRPC benchmark results
by 0x000000E2 on Saturday May 08, 2021 @01:43PM
(#27089236)
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.