hdf5 icon indicating copy to clipboard operation
hdf5 copied to clipboard

Add support for builtin_expect compiler hint

Open qkoziol opened this issue 10 months ago • 2 comments

qkoziol avatar Apr 20 '24 02:04 qkoziol

Do you have profiling that shows that this added complexity is worthwhile? I'm not opposed to adding it, but I don't want to add a bunch of /very/ compiler-specific complexity if this is just based on "thought experiment optimization".

derobins avatar Apr 21 '24 23:04 derobins

Do you have profiling that shows that this added complexity is worthwhile? I'm not opposed to adding it, but I don't want to add a bunch of /very/ compiler-specific complexity if this is just based on "thought experiment optimization".

Here's a good stackoverflow that talks about the general improvements: https://stackoverflow.com/questions/109710/how-do-the-likely-unlikely-macros-in-the-linux-kernel-work-and-what-is-their-ben

And here's a more in-depth article that measures the effect, which looks to be a 15-20% performance improvement: http://blog.man7.org/2012/10/how-much-do-builtinexpect-likely-and.html

I think that 15-20% is worth it for the FUNC_ENTER/LEAVE statements, which are almost never going to throw errors, and the concurrency routines, which are also very unlikely to throw errors and are also latency sensitive.

qkoziol avatar Apr 22 '24 02:04 qkoziol