Skip to content

Use faster code for remainder by p in qsieve_evaluate_candidate#2626

Merged
fredrik-johansson merged 1 commit intoflintlib:mainfrom
fredrik-johansson:qsievemod
Apr 5, 2026
Merged

Use faster code for remainder by p in qsieve_evaluate_candidate#2626
fredrik-johansson merged 1 commit intoflintlib:mainfrom
fredrik-johansson:qsievemod

Conversation

@fredrik-johansson
Copy link
Copy Markdown
Collaborator

The quadratic sieve spends a decent portion of its time in qsieve_evaluate_candidate which checks the remainder of the candidate i by all factor base primes. There is maybe a better way to implement this function, but a trivial improvement is to replace n_mod2_preinv with a Lemire-Kaser-Kurz remainder. This speeds up the quadratic sieve 5-20%.

Time (single-threaded) to factor nextprime(10^n)*nextprime(10^(n+1)) with fmpz_factor:

         n        old        new   speedup
        10      0.004    0.00402   0.995
        11    0.00131    0.00131   1.000
        12     0.0151     0.0129   1.171
        13     0.0104    0.00886   1.174
        14     0.0107     0.0094   1.138
        15      0.012     0.0105   1.143
        16     0.0192     0.0166   1.157
        17     0.0217     0.0194   1.119
        18     0.0341     0.0283   1.205
        19     0.0317      0.029   1.093
        20      0.046     0.0406   1.133
        21     0.0653     0.0586   1.114
        22     0.0966     0.0879   1.099
        23       0.18      0.161   1.118
        24      0.441      0.383   1.151
        25      0.434      0.402   1.080
        26      0.533      0.456   1.169
        27      0.911      0.795   1.146
        28      1.259      1.112   1.132
        29      2.067      1.927   1.073
        30      2.539      2.269   1.119
        31      7.293      6.666   1.094
        32      7.502      6.671   1.125
        33     14.411     12.894   1.118
        34      23.94     20.594   1.162
        35     41.296      36.51   1.131

@fredrik-johansson fredrik-johansson merged commit f7ed4be into flintlib:main Apr 5, 2026
12 checks passed
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.

1 participant