Repository navigation
Frequent items: sample at most the capacity in purge, as Java, Go and Rust do - #605
Draft
stojkomilos wants to merge 1 commit into
Draft
stojkomilos wants to merge 1 commit into
stojkomilos wants to merge 1 commit into
Conversation
… Rust do Purge sampled capacity + 1 counts for the median, so for maps of 1024 slots or fewer the median and offset differed from Java, Go and Rust. Co-authored-by: Isaac <no-reply@databricks.com>
This branch has not been deployed
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.
purge()takes its median over one count too many. A purge runs when the map is one item over capacity, sonum_active_is capacity + 1. For an 8-slot map (capacity 6), C++ takes the median of 7 counts. Java, Go and Rust take it of 6. The median can then differ, and so can the offset and the items that survive.Changes
purge()samplesmin(1024, capacity)counts instead ofmin(1024, num_active_). This makes C++ match the other libraries, which samplemin(1024, capacity)too:purge median samples at most the capacity, as java(8 slots).purge at 2048 slots matches java. Maps above 1024 slots sample 1024 counts before and after this change.What users see
Out of scope: Java also sizes its sample from the requested
lgMaxMapSizebefore it clamps it to 3. So Java samples 1 or 3 counts at lg 1 or 2. This change does not copy that. It is a Java bug.Checks
fi_testpasses, and passes under-fsanitize=address,undefined.This pull request and its description were written by Isaac.