Skip to content

Div by 256 -> shift #219

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

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

Conversation

eddiewastaken
Copy link

@eddiewastaken eddiewastaken commented May 14, 2025

TODO notes slowness, so change divide by 256 to right shift by a byte. On x86_64 with gcc, logarithmic gains between 0 bit input (same speed) and 256 bit input (2.65x faster). 1.7x speedup on average

@jgriffiths
Copy link
Contributor

Hi @eddiewastaken thanks for contributing.

I think this change would only be valid if num was an intrinsic type (and the compiler didn't already optimize power of 2 division to shifts). But in this case the type is a boost 256 bit unsigned number parsed from a string, so the optimization doesn't apply (subject to the implementation of the class in boost).

However, it turns out that ga_session::sign_challenge is now unused since the login refactoring in 6222e42 and its follow up work. So, if you'd like to update this PR to remove the sign_challenge method, the uint256_to_base256 call and the boost/multiprecision/cpp_int.hpp include, I'd be happy to merge that!

@eddiewastaken
Copy link
Author

Cool! Done as suggested, and raised with Boost :)

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