Skip to content

Avoid goroutine fan-out in SumBigValues - #552

Open
perfloop-agent wants to merge 2 commits into
RoaringBitmap:masterfrom
perfloop:perfloop-pr-open-gvg19vasze
Open

Avoid goroutine fan-out in SumBigValues#552
perfloop-agent wants to merge 2 commits into
RoaringBitmap:masterfrom
perfloop:perfloop-pr-open-gvg19vasze

Conversation

@perfloop-agent

Copy link
Copy Markdown
Contributor

Description

Avoids creating a goroutine for every bit slice in roaring64.BSI.SumBigValues.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds new functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Performance improvement
  • Code refactoring
  • Documentation update
  • Test improvements
  • Build/CI changes

Changes Made

What was changed?

  • Traverse bit slices synchronously and reuse one big.Int term.
  • Added coverage for filtered, wide signed sums and a focused benchmark.

Why was it changed?

  • Per-bit cardinality intersections are small, so goroutine, channel, and closure setup costs more than the work.

How was it changed?

  • Shift each cardinality into the reusable term, add ordinary bit planes, and subtract the sign plane.

Testing

go test ./...

Checks: 3 passed.

Formatting

gofmt -s -l reports no files.

Fuzzing

Not run; this only changes aggregate arithmetic and scheduling.

Performance Impact

The benchmark uses a 63-bit BSI with 128 values. The traversal is intentionally serial, favoring small per-bit intersections over per-bit scheduling.

Workload: SumBigValues on a 63-bit BSI with 128 values

Metric Before After Change
ns/op 34102 1872 94.5% lower
B/op 5297 144 97.3% lower
allocs/op 132 5 96.2% lower

Running Benchmarks

go test ./roaring64 -run '^$' -bench '^BenchmarkBSI64SumBigValues$' -benchmem

Performance Analysis

Reusing the term avoids building a result channel and a separate big.Int for each bit plane.

Breaking Changes

None.

Related Issues

None.

Additional Notes

None.


Generated by Perfloop. Measurements and checks.

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.

1 participant