-
Notifications
You must be signed in to change notification settings - Fork 353
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
Optimize isqrt
#2108
Optimize isqrt
#2108
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general, just this small nit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nice! Thanks for the benchmarks. Let's not complicate things for small savings for small numbers.
I can't follow the exact math right now but if this is well tested and the two of you agree, this is good to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Especially the solution with the Unsigned
trait, very nice
taken out of #2029
somewhat related to #1897
Benchmarked the gas costs and they look much better for big numbers, while only having a small regression for small numbers:
If we want to avoid the increase in the lower numbers really badly, we could try to figure out the points until which the old version is better and manually check if the number is below that threshold, but that's likely to change with different compiler versions, bnum updates, etc.