Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PreviousSet and PreviousClear functions #178

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

lukesandberg
Copy link

@lukesandberg lukesandberg commented Nov 15, 2024

Add PreviousSet and PreviousClear functions

These are analogous to NextSet and NextClear but probing in the opposite direction.

Fixes #86

These are analogous to NextClear and NextSet but scan backwards.

The current implementations are naive.
On an Apple M2 they produces these results:

BenchmarkBitsetOps/NextSet-8       	 2537938	       470.0 ns/op
BenchmarkBitsetOps/NextClear-8     	 2564336	       468.1 ns/op
BenchmarkBitsetOps/PreviousSet-8   	   19930	     59924 ns/op
BenchmarkBitsetOps/PreviousClear-8 	   19912	     61002 ns/op

A future commit should improve upon this.
On an Apple M2 our benchmark produces these results:

BenchmarkBitsetOps/NextSet-8       	 2552749	       468.1 ns/op
BenchmarkBitsetOps/NextClear-8     	 2571921	       466.9 ns/op
BenchmarkBitsetOps/PreviousSet-8   	 1760882	       682.4 ns/op
BenchmarkBitsetOps/PreviousClear-8 	 1763605	       680.0 ns/op

Which greatly improves on the prior results of

    BenchmarkBitsetOps/PreviousSet-8           19930             59924 ns/op
    BenchmarkBitsetOps/PreviousClear-8         19912             61002 ns/op
The missing coverage was probing multiple words and failing to find anything.
bitset.go Outdated Show resolved Hide resolved
bitset.go Outdated Show resolved Hide resolved
@lemire
Copy link
Member

lemire commented Nov 15, 2024

@lukesandberg How did you verify that the bound check elimination trick worked?

@lemire
Copy link
Member

lemire commented Nov 15, 2024

Running tests.

…PreviousClear and PreviousSet

There is no impact on performance, just a clean up.
@lukesandberg
Copy link
Author

Removed the bounds check elimination since it was non functional.

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.

get top bit set?
2 participants