Skip to content

Conversation

@pitrou
Copy link
Member

@pitrou pitrou commented Jan 19, 2026

Rationale for this change

Counting the set bits in a null bitmap is an operation that comes often, it can be useful to get a more precise idea of its performance.

What changes are included in this PR?

Add a benchmark for CountSetBits.

Local results (AMD Zen 2):

------------------------------------------------------------------------------
Benchmark                    Time             CPU   Iterations UserCounters...
------------------------------------------------------------------------------
CountSetBits/16           5.42 ns         5.42 ns    128549068 bytes_per_second=2.7515Gi/s
CountSetBits/1024         80.6 ns         80.6 ns      8649312 bytes_per_second=11.8351Gi/s
CountSetBits/131072       9092 ns         9091 ns        77115 bytes_per_second=13.4271Gi/s

Local results (Intel(R) Core(TM) Ultra 7 255H):

------------------------------------------------------------------------------
Benchmark                    Time             CPU   Iterations UserCounters...
------------------------------------------------------------------------------
CountSetBits/16           2.45 ns         2.45 ns    285392946 bytes_per_second=6.08012Gi/s
CountSetBits/1024         28.9 ns         28.9 ns     23618777 bytes_per_second=33.0086Gi/s
CountSetBits/131072       3490 ns         3489 ns       198472 bytes_per_second=34.9862Gi/s

Are these changes tested?

By running said benchmark manually (and by Continuous Benchmarking).

Are there any user-facing changes?

No.

@pitrou
Copy link
Member Author

pitrou commented Jan 19, 2026

@wgtmac @zanmato1984

@pitrou
Copy link
Member Author

pitrou commented Jan 19, 2026

Also @AntoinePrv FYI

@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants