Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise HLL union for mergeHLLtoHLL #572

Closed
wants to merge 1 commit into from

Conversation

freakyzoidberg
Copy link
Member

@freakyzoidberg freakyzoidberg commented Jun 10, 2024

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

Benchmark                                       Mode  Cnt    Score    Error  Units
BenchmarkUnion.benchHllUnionHLLToHLLMerge  avgt    5  511.411 ± 12.468  ms/op

After

Benchmark                                       Mode  Cnt    Score   Error  Units
BenchmarkUnion.benchHllUnionHLLToHLLMerge  avgt    5  471.329 ± 9.712  ms/op

@freakyzoidberg freakyzoidberg force-pushed the optimize-hll-union-bench branch from a53cd18 to d1753d4 Compare June 10, 2024 15:24
@AlexanderSaydakov
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants