Skip to content

Conversation

remyoudompheng
Copy link
Contributor

📚 Description

Calling repeatedly PARI fffrobenius function involves redundant computations that can be avoided by reusing already computed powers.

This is a follow-up to #35316 improving the performance of Frobenius on first call:

sage: p = next_prime(2**120)
....: K = GF(p**120, 'a')
....: x = K.random_element()
sage: %time _ = [x.frobenius(i) for i in (0, 20, 40, 60, 80, 100)]
Sage 9.8
CPU times: user 9.73 s, sys: 8 ms, total: 9.73 s
Sage 10 beta 8
CPU times: user 6.84 s, sys: 194 µs, total: 6.84 s
After patch
CPU times: user 681 ms, sys: 0 ns, total: 681 ms
When cached (10.0beta8)
30.9 ms ± 155 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

sage: K = GF(5**240, 'a')
....: x = K.random_element()
sage: %time _ = [x.frobenius(i) for i in range(240)]
Sage 9.8
CPU times: user 1.72 s, sys: 1.12 ms, total: 1.73 s
Sage 10.0beta8
CPU times: user 1.02 s, sys: 1.02 ms, total: 1.02 s
After patch
CPU times: user 219 ms, sys: 12 µs, total: 219 ms
When cached (10.0beta8)
168 ms ± 391 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

📝 Checklist

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation accordingly.

Calling repeatedly PARI fffrobenius function involves
redundant computations that can be avoided by reusing
already computed powers.
@github-actions
Copy link

github-actions bot commented Apr 7, 2023

Documentation preview for this PR is ready! 🎉
Built with commit: eba0431

Copy link
Member

@mezzarobba mezzarobba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thank you!

@vbraun vbraun merged commit efbaa0d into sagemath:develop Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants