Optimize double-word integer factorization - #2783
Merged
Merged
Conversation
fredrik-johansson
force-pushed
the
llfactor
branch
from
July 26, 2026 11:38
a4b823d to
a8f0c5b
Compare
Collaborator
Author
|
Opus also identified a trivial improvement to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes most of the slowness of
fmpz_factorin the 65-160 bit range observed in #2625. The speedup is largest around 80 bits where we gain nearly 6x on average for random integers. Performance is also slightly improved for 3-4 word integers.Several changes:
Average time per factorization to factor 100 random integers of the given bit size:
Worst-case time for the same 100 inputs:
Tried before to get Opus 4.8 to do this, but it persistently failed to identify the real bottlenecks/solutions; Fable refused to touch this problem (work on integer factorization apparently triggers its safety guardrails); finally Opus 5 got the job done in a few hours.