Repository navigation
Fix SumBigValues overflow without serializing large sums - #590
Open
perfloop-agent wants to merge 2 commits into
Open
perfloop-agent wants to merge 2 commits into
perfloop-agent wants to merge 2 commits into
Conversation
Signed-off-by: Perfloop Agent <agent@perfloop.ai> Signed-off-by: Tomás Senart <ts@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai> Signed-off-by: Tomás Senart <ts@perfloop.ai>
2 of 8 tasks
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.
Description
Fix
SumBigValuesoverflow by weighting cardinalities inbig.Int, while keeping expensive intersections parallel and avoiding worker setup for small sums.Supersedes our #552, which made large sums slower because it runs the per-plane intersections serially. In a local loop equivalent to that serial path, 2M-row sums were 45–70% slower than master at
-cpu 2(three pairs each for 16-, 63- and 64-bit values). This PR keeps #552's overflow fix and keeps large and scattered sums parallel.Type of Change
Changes Made
big.Int.GOMAXPROCS=1or below 256 plane-container pairs, counting the sign plane. Otherwise, at mostGOMAXPROCSworkers take planes dynamically. Nil filters and returned counts keep their behavior.TestSumBigValuesfor wide positive, negative and filtered sums, plus a parallel-path regression.Testing
The Go test runner passed the
roaring64suite, including the wide signed-sum and parallel-path regressions. A separate differential check, not part of this PR, compared 300 fixed-seed signed fixtures up to 256 bits against a per-columnbig.Inttotal at GOMAXPROCS 1, 2 and 4, including dense, scattered, empty and absent-ID filters.Formatting
Changed Go files are gofmt-formatted, and
go tool unconvert ./...reports no unnecessary conversions.Fuzzing
Not run. The repository's fuzz targets do not cover
roaring64sums.Performance Impact
Selected native rows from the first measured pair at each CPU setting (local run): the first nine rows are before, and the last nine, from the second
rows128/bits63/allrow, are after.In this first pair, the 8M-row scattered case at
-cpu 2was slower (8328368 → 9598339 ns/op); over three pairs its median was 8% faster (table below).Local before → after medians; each row has three paired runs after an excluded warmup.
The largest median loss is 7% (2M rows, 262,143 scattered IDs,
-cpu 2); a separate 1 s run of the same case was 4% faster.The main experiment used Go 1.24.4 on linux/amd64, one caller, and already-built indexes. The 128-row case stores 0..127; other cases use fixed-seed unsigned 16/63-bit or signed 64-bit values. Scattered filters contain uniformly sampled distinct IDs; range filters use a contiguous prefix. Setup is outside the timer.
Prepared native test binaries ran with
-test.run=^$ -test.bench=^BenchmarkBSI64SumBigValues$ -test.cpu=1 -test.benchtime=300ms -test.benchmem, separately repeated with-test.cpu=2and-test.cpu=4, each with matchingGOMAXPROCS.Running Benchmarks
The native benchmark is in
roaring64/bsi64_sum_benchmark_test.go. Reproduction recipe, one concurrency setting per process:Breaking Changes
No public signature changes.
Additional Notes
Measurements use constructed indexes and repeated sums.
Case and evidence
Made by Perfloop. Human sponsor: Tomás Senart. To ask for a change, comment or review in plain words. How Perfloop handles pull requests.