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

block sketch #271

Merged
merged 21 commits into from
Oct 8, 2022
Merged

block sketch #271

merged 21 commits into from
Oct 8, 2022

Conversation

bitfaster
Copy link
Owner

@bitfaster bitfaster commented Sep 21, 2022

Implement 'block' sketch, exploiting 64 byte CPU cache lines to increase throughput. Instead of indexing over the full counter table for each lookup, constrain to a 64 byte block, thereby minimizing L1 caches misses. The block is partitioned into 4 segments of 32 counters (still 4 bits) and we guarantee that exactly 1 counter in each segment will be incremented. Since each segment maps to 2 long values in the table this eliminates data dependencies when incrementing.

Final code uses the 'BlockSeg' implementation below. Code for all impls is in commit 8b76d1f.

Frequency

Method Mean Error StdDev Ratio Allocated
EstimateFrequency 96.37 ns 1.903 ns 2.963 ns 1.00 -
EstimateFrequencyAvx 83.91 ns 1.507 ns 1.335 ns 0.86 -
EstimateFrequencyBlock 74.24 ns 1.455 ns 1.676 ns 0.77 -
EstimateFrequencyBlockAvx 47.40 ns 0.943 ns 2.347 ns 0.50 -
EstimateFrequencyBlock2 66.61 ns 1.332 ns 3.087 ns 0.69 -
EstimateFrequencyBlockV2Avx 54.37 ns 1.080 ns 1.286 ns 0.56 -
EstimateFrequencyBlockSeg 74.48 ns 1.454 ns 1.941 ns 0.77 -
EstimateFrequencyBlockSegAvx 42.18 ns 0.829 ns 1.078 ns 0.44 -
EstimateFrequencyBlockSegRem 77.74 ns 2.395 ns 7.060 ns 0.85 -
EstimateFrequencyBlockSegRemAvx 43.59 ns 1.151 ns 3.394 ns 0.47 -
Method Mean Error StdDev Ratio Allocated
CompoundEstimateFrequencyAvx 79.84 ns 1.329 ns 2.529 ns 0.83 -
CompoundEstimateFrequencyBlockAvx 43.73 ns 0.682 ns 1.393 ns 0.46 -

Increment

Method Mean Error StdDev Ratio Allocated
Inc 78.08 ns 1.498 ns 3.674 ns 1.00 -
IncAvx 48.26 ns 0.947 ns 1.128 ns 0.62 -
IncBlock 58.91 ns 1.176 ns 1.761 ns 0.75 -
IncBlockAvx 37.75 ns 0.711 ns 1.886 ns 0.49 -
IncBlock2 58.37 ns 1.133 ns 1.660 ns 0.74 -
IncBlock2Avx 36.71 ns 0.731 ns 1.138 ns 0.47 -
IncBlockSeg 60.07 ns 1.195 ns 2.468 ns 0.77 -
IncBlockSegAvx 36.17 ns 0.723 ns 1.147 ns 0.46 -
IncBlockSegRem 60.67 ns 1.212 ns 3.129 ns 0.78 -
IncBlockSegRemAvx 33.69 ns 0.579 ns 0.918 ns 0.43 -

Eviction throughput

image

@bitfaster bitfaster mentioned this pull request Sep 21, 2022
@bitfaster bitfaster marked this pull request as ready for review October 8, 2022 19:38
@bitfaster bitfaster changed the title block block sketch Oct 8, 2022
@bitfaster bitfaster merged commit aa4aa07 into main Oct 8, 2022
@bitfaster bitfaster deleted the users/alexpeck/block branch October 8, 2022 20:29
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.

None yet

1 participant