Add ExponentialHistogramIndexerBenchmark #4989
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was analyzing the HistogramBenchmark and struggling to make sense of the results. Somewhat randomly, certain exponential histogram trials are 5-10x slower than not only explicit bucket histogram trials, but also other exponential histogram trials. For example, here's a group of exponential results:
The GAUSSIAN_LATENCY takes ~6x longer than UNIFORM_RANDOM_WITHIN_2K and FIXED_BUCKET_BOUNDARIES for the EXPONENTIAL_SMALL_CIRCULAR_BUFFER aggregation, but both GAUSSIAN_LATENCY and UNIFORM_RANDOM_WITHIN_2K are ~6x slower for the EXPONENTIAL_CIRCULAR_BUFFER aggregation. What's going on here? Why does the distribution sometimes have such a big impact and other times not?
Well I got to the bottom of it: The code path is different for positive scales than for zero and negative scales. Positive scales compute the bucket using
Math.ceil(Math.log(value) * scaleFactor) - 1
, while zero and negative scales use bit manipulation. It turns out thatMath.log
is really slow compared to bit manipulation. Going back to the benchmark, subtle differences in the distribution of values cause the scale to stabilize at different values, sometimes positive, sometimes zero or negative. The scale isn't consistent across runs of the benchmark, but certain distributions (i.e. gaussian) seem to be more prone to resulting in positive scales than others.What do we do about this?
Math.log
bucketing isn't a factor in these benchmarks.Math.log
codepath altogether. Positive scales correspond to small buckets. If you know your app doesn't need small buckets, you should be able to set your starting scale to zero, avoidingMath.log
and also reducing the number of rescales.ExponentialHistogramIndexerBenchmark
benchmark in this PR which specifically illustrates the performance difference between positive, negative, and zero scales. If we think its possible to make performance improvements to bucket indexing for positive scales, this will provide a more focussed place to analyze the results. The baseline results show very clearly the ~9x performance reduction when the scale is positive.cc @jsuereth