Repository navigation
roaring64: fewer bitmap operations in BSI Add and Increment - #610
Merged
Merged
Conversation
addPlanes computed x^y twice per plane and allocated a temporary for carry&(x^y). Compute the sum bit in place in x, and reuse the carry bitmap for carry&(x^y), which equals carry&^(x^y^carry). Skip planes where there is no carry and the other operand's plane is empty, and stop once only the empty sign plane of a non-negative operand is left. Increment stops as soon as the carry dies out. Add BenchmarkBSIAdd.
Xor can install a carry container into the value plane. AndNot on that carry then cleared the sum bit for column IDs above 2^32.
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.
Follow-up to #609.
Changes
x, sox^yis no longer computed twice per plane.carry&(x^y)is computed in the carry bitmap itself (it equalscarry &^ (x^y^carry)), which saves an allocation per plane.bis wider thanother, andIncrementnow stops as soon as the carry dies out.BenchmarkBSIAdd: 100k columns, cloningboutside the timer.Benchmark (Apple M4 Max, mean of 6 runs)
Testing
go test ./roaring64passes. I also ran a local randomized check (not included) againstbig.Intover 5000 rounds: mixed widths from 1 to 62 bits, mixed signs, fixed-width and auto-sized BSIs, adding a BSI to itself, and repeatedIncrementon subsets that include new columns. It passes on master and on this branch.