uutils / uutils/num-prime

SQUFOF for large u128 factorization is very slow compared to SIQS

Open
#107 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
33
Forks
16
Avg merge
8h 14m
Merged PRs (30d)
4

Description

In https://github.com/Pr0methean/FactorBot/blob/7f49a6a899357e8b6bdd9084b25c9b75b49f358e/src/algebraic.rs#L2271, I use yamaquasi's implementation of SIQS to factories numbers between 1u128<<85 and u128::MAX, because the SQUFOF implementation provided by num-prime is much slower.

A good benchmark to reproduce this issue would probably be 319014718988379810428474270189615055511, because it is 13835058055282163729 (the next prime after 3u128<<62) * 23058430092136939559 (the next prime after 5u128<<62). Another option is 0xfffffffffffffffff33333332bdf7d55, which is 0xccccccccccccaa27 * 0x14000000000003623 and was found by ChatGPT as an estimate of the largest u128 biprime that has a smaller factor above 3u128<<62 and a larger factor above 5u128<<62. If you also want to benchmark on a non-adversarial random distribution, try thread_rng().gen() | ((1u128 << 127) + 1) as input.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the comparison from FactorBot's src/algebraic.rs#L2271 using the two supplied semiprimes and a random u128 input. Inspect num-prime's SQUFOF implementation and compare its timings with yamaquasi's SIQS. Done means large u128 inputs factor substantially faster without breaking existing factorization behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
performance
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.