Repository navigation
Union run containers by run instead of by value - #575
Open
gitRasheed wants to merge 1 commit into
Open
gitRasheed wants to merge 1 commit into
gitRasheed wants to merge 1 commit into
Conversation
runContainer16.inplaceUnion added the other container one value at a time. It now inserts up to 16 runs in place and merges above that. toArrayContainer allocates once, iorRun16 merges above 4 runs, and the union and intersect helpers check the next run before searching.
gitRasheed
force-pushed
the
perf/run-union
branch
from
October 10, 2026 20:14
3d65f79 to
cdbff48
Compare
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
runContainer16.inplaceUnionadded the other container one value at a time. An in-placeOron run containers got slower with every value. It now inserts up to 16 runs in place and merges above that, likeinplaceIntersectdoes.Type of Change
Changes Made
What was changed?
inplaceUnioninserts runs in place or merges.unioncopies runs in blocks.toArrayContainerallocates once.iorRun16merges above 4 runs.Why was it changed?
An in-place
Orover every adjacent pair inweather_sept_85_srttook 85 ms.How was it changed?
A few runs are cheaper to insert than a full merge. Many runs are cheaper to merge. Without the in-place path, folding small bitmaps into a large accumulator was 2.3x slower than master on c7i.
Testing
go test ./...passes on c7i.xlarge and c8g.xlarge. The root package also passes with-tags=gofuzz.Formatting
go fmt,make unconvertandgit diff --checkare clean.Fuzzing
smat, 300 seconds: 1.5M executions, no failures.
Performance Impact
Real datasets after
RunOptimize, less time than master (geometric mean):Sorted datasets gain the most. The in-place pass over
weather_sept_85_srtdrops from 85 ms to 3.0 ms.Some small shapes are slower, mostly operands whose runs the receiver already holds. They cost a few µs more, up to 7.6 µs instead of 3.8 µs on c7i. Skipping runs the receiver already contains before merging would avoid this. I left it out to keep the PR small.
Breaking Changes
None.