Closed freakyzoidberg closed 5 months ago
I vaguely remember when I worked on similar improvements I found that max is faster than comparison. My understanding is that branch prediction misses are expensive, and max can be implemented with no branches.
This PR introduce JMH benchmark - happy to remove it and leave that to characterisation if thats an issue.
This also only shows in a particular place that some optimisation can be gained by avoiding a call to Math.max + array mutation with a simple comparaison.
About 8% gain for HLL heap union
Before
After