Skip to content

Use AVX2 for dense in-place XOR - #550

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

Use AVX2 for dense in-place XOR#550
perfloop-agent wants to merge 2 commits into
RoaringBitmap:masterfrom
perfloop:perfloop-pr-open-je71hpbx27

Conversation

@perfloop-agent

Copy link
Copy Markdown
Contributor

Description

Use AVX2 for the high-cardinality bitmap-container XOR store pass and add dense XOR coverage.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds 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?

  • Added a runtime-dispatched AVX2 in-place XOR helper for dense bitmap containers.
  • Added dense XOR benchmarks and tests for bitmap, threshold, copy-on-write, AVX2, and scalar fallback paths.

Why was it changed?

  • The bitmap-result path counted XOR cardinality with AVX2, then rewrote the same container one word at a time.

How was it changed?

  • Use unaligned AVX2 loads, XORs, and stores on supported amd64 CPUs; retain the Go loop for appengine, non-AVX2 amd64, and arm64.
  • Leave cardinality counting and array-result conversion unchanged.

Testing

  • go test ./...
  • go test -tags=appengine
  • GOARCH=arm64 go build .
  • GOARCH=386 go build .
  • test -z "$(gofmt -s -l $(find . -name '*.go' -type f))" && go tool unconvert ./...

Checks: 5 passed.

Formatting

  • Checked with gofmt -s -l as part of the formatting check above.

Fuzzing

  • Not run; this only changes fixed-width bitmap XOR storage.

Performance Impact

The AVX2 path is used only for the high-cardinality bitmap result on supported amd64 CPUs. Other paths retain the portable store loop.

Workload: Bitmap.Xor on 50 dense matching containers

Metric Before After Change
ns/op 65345 21612 66.9% lower

Workload: Bitmap.Xor with 1 matching dense container on amd64 AVX2

Metric Before After Change
ns/op 1250 374.9 70% lower

Workload: Bitmap.Xor with 50 matching dense containers on amd64 AVX2

Metric Before After Change
ns/op 64389 20054 68.9% lower

Workload: Bitmap.Xor with 256 matching dense containers on amd64 AVX2

Metric Before After Change
ns/op 383903 157206 59.1% lower

Breaking Changes

  • None.

Related Issues

  • None.

Additional Notes

  • None.

Generated by Perfloop. Human sponsor: Tomás Senart. 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