HdrHistogram_rust icon indicating copy to clipboard operation
HdrHistogram_rust copied to clipboard

How is the performance compared to the C version?

Open gkorland opened this issue 4 years ago • 4 comments

How is Rust version performance compared to the C version?

gkorland avatar Mar 29 '22 11:03 gkorland

We do have a number of benchmarks (run with cargo +nightly bench), but I don't know that any of them are 1:1 with any known C benchmarks. Even things like measuring the performance of record is difficult because it depends on how you generate the samples, what precision you record with, what computer you're running on, etc. @marshallpierce probably has the most insight into this.

Do you have concrete benchmarks you'd like to see comparisons of? In general, I'd expect the Rust version to be very close in performance to the C version.

jonhoo avatar Apr 02 '22 00:04 jonhoo

Very generically though, on my laptop, recording a random value on average takes about 5.6ns.

jonhoo avatar Apr 02 '22 00:04 jonhoo

Concur w/ all of the above. I would expect it to be comparable, and if you find instances where it is not, that would be great to know. The hot paths inherit all the optimization that went into the Java version, so they boil down to patterns like loading a very-likely-cache-resident field, mask, shift, write. There's not a whole lot left to wring out of that sort of logic without SIMD, which isn't applicable here since we get one datum at a time, so we just hope that the LLVM gods smile upon us.

marshallpierce avatar Apr 02 '22 13:04 marshallpierce

We are probably missing some optimizations that have landed since the port for less-hot paths like https://github.com/HdrHistogram/HdrHistogram_rust/issues/109, but that's the only one I know about.

jonhoo avatar Apr 02 '22 15:04 jonhoo