Skip to content

Add a portable count_trailing_zeroes implementation, use it for faster depth_for_size - #146

Merged
spaskalev merged 6 commits into
mainfrom
faster-depth-for-size
Sep 26, 2025
Merged

spaskalev merged 6 commits into
mainfrom
faster-depth-for-size

Conversation

@spaskalev

@spaskalev spaskalev commented Sep 26, 2025 •

Copy link
Copy Markdown
Owner

As suggested in #145 the depth_for_size function can be implemented without the loop. The chosen count_trailing_zeroes is not the fastest one out there but its simplicity makes it preferable.

@spaskalev
spaskalev merged commit b19cb73 into main Sep 26, 2025
6 checks passed
@spaskalev
spaskalev deleted the faster-depth-for-size branch September 26, 2025 17:31
@theVerySharpFlat

Copy link
Copy Markdown
Contributor

As mentioned in #145, the original implementation took 17s on buddy_bench. The intrinsic version I drummed up took 13s. This PR takes 14s. Pretty good considering it's also portable!

@spaskalev

Copy link
Copy Markdown
Owner Author

@theVerySharpFlat thanks for the report and for testing the pr too! It is nice to have more eyes on the code.

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.

2 participants