-
Notifications
You must be signed in to change notification settings - Fork 186
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
Modular exponentiation with Integer#pow(exponent, modulo) is slow #1999
Comments
On the first program TruffleRuby seems much faster:
On the second program there is no mention of Ruby implementations:
So I guess you mean the last output "Translation of: Crystal of Sidef. Faster version."?
|
Using the CPUSampler clearly shows the bottleneck:
Which shows that the call to
|
JRuby has an implementation of it: https://github.com/jruby/jruby/blob/9.2.8.0/core/src/main/java/org/jruby/RubyInteger.java#L799-L851 |
That seems quite complicated though, I'd rather just have a primitive converting everything to BigInteger and calling |
…#mod_pow` (#1999). PullRequest: truffleruby/1659
This is much better since #2006, now I see:
We could go further by having optimized logic for Fixnum-range modulo for I think for now this is enough, but PRs welcome if someone wants to optimize |
v20.0.0 has an inexplicable performance issue for this code compared to J|Ruby.
https://rosettacode.org/wiki/Long_primes#Ruby
The text was updated successfully, but these errors were encountered: