hdr_value_at_percentile 30% on cpu time reduction: reuse common computed values within highest_equivalent_value/lowest_equivalent_value/hdr_median_equivalent_value calls on hdr_next_non_equivalent_value#94
Merged
mikeb01 merged 2 commits intoHdrHistogram:masterfrom Aug 13, 2021
Conversation
…owest_equivalent_value/hdr_median_equivalent_value calls on hdr_next_non_equivalent_value()
highest_equivalent_value/lowest_equivalent_value/hdr_median_equivalent_value calls on hdr_next_non_equivalent_value()
highest_equivalent_value/lowest_equivalent_value/hdr_median_equivalent_value calls on hdr_next_non_equivalent_value()highest_equivalent_value/lowest_equivalent_value/hdr_median_equivalent_value calls on hdr_next_non_equivalent_value
Contributor
|
Is ready to merge or was there some other changes that you wanted to include? |
Contributor
Author
@mikeb01 IMO we can merge and re-iterate over further changes. The smaller changes per review the best :) |
mikeb01
reviewed
Aug 12, 2021
…ven_bucket_indices static
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The performance problem
Using the current master commit 706a9e0.
Given the following on cpu analysis of
hdr_value_at_percentile()we notice that the top hotspots all relate tomove_nextand within ithighest_equivalent_value/lowest_equivalent_value/hdr_median_equivalent_value calls on hdr_next_non_equivalent_value()as shown on the follow top on-cpu consumers:If we look closer at the following 5 methods we see there a lot of repeated computation:
namely:
hdr_size_of_equivalent_value_rangeandlowest_equivalent_valueboth calculate the bucket/subbucket. Proposed optimization is to add two internal functions that take the precomputed bucket/subbucket indices.hdr_next_non_equivalent_valuefunction, the functionshighest_equivalent_valueandhdr_median_equivalent_valueboth calculate thelowest_equivalent_valueandhdr_size_of_equivalent_value_range. Proposed solution is to avoid at all duplicate computation and simplifyhdr_next_non_equivalent_value.Measured improvement
As expected, by simply reusing intermediate computation and consequently reducing the redundant computation within the internally called functions of
hdr_value_at_percentile(), we've measured a reduction in the overall CPU time of ~= 30%, as show on the following chart:Used platform details
The performance results provided in this PR were collected using: