Skip to content

factor: seed Pollard's rho deterministically - #121

Open
sylvestre wants to merge 2 commits into
uutils:mainfrom
sylvestre:rho-deterministic-seed
Open

sylvestre wants to merge 2 commits into
uutils:mainfrom
sylvestre:rho-deterministic-seed

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

Use a SplitMix64 generator instead of the OS-seeded RNG for the rho start and offset values. The generator is created for each target and seeded from it, so factoring a number does the same work on every call, whatever the thread factored before.

Use a SplitMix64 generator instead of the OS-seeded RNG for the rho start
and offset values. The generator is created for each target and seeded
from it, so factoring a number does the same work on every call, whatever
the thread factored before.
Copilot AI lite review requested due to automatic review settings September 25, 2026 08:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codspeed

codspeed Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by ×4.5

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 23 untouched benchmarks
⏩ 9 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ three 39-bit primes (u128) 480.2 ms 107.7 ms ×4.5

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing sylvestre:rho-deterministic-seed (7becc10) with main (866bc2c)

Open in CodSpeed

Footnotes

  1. 9 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@codecov

codecov Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.97872% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.12%. Comparing base (3f5db7d) to head (7becc10).
⚠️ Report is 77 commits behind head on main.

Files with missing lines Patch % Lines
src/buffer.rs 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #121      +/-   ##
==========================================
+ Coverage   78.64%   86.12%   +7.48%     
==========================================
  Files          13       17       +4     
  Lines        2585     3972    +1387     
  Branches      230      265      +35     
==========================================
+ Hits         2033     3421    +1388     
+ Misses        552      548       -4     
- Partials        0        3       +3     
Flag Coverage Δ
macos_latest 86.05% <82.97%> (+8.41%) ⬆️
ubuntu_latest 85.62% <82.97%> (+7.44%) ⬆️
windows_latest 15.25% <0.00%> (+0.55%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/factor.rs Outdated
Rename RhoSeed to SplitMix64 and give it its own module, with references
to the algorithm (Steele, Lea and Flood, OOPSLA 2014) and to Vigna's
reference implementation. Check it against the reference outputs.
Copilot AI review requested due to automatic review settings September 26, 2026 17:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@xtqqczze

Copy link
Copy Markdown
Contributor

We should run tests for a big-endian target in CI:

cargo +nightly miri test --target s390x-unknown-linux-gnu

Comment thread src/splitmix64.rs
pub(crate) struct SplitMix64(u64);

impl SplitMix64 {
pub(crate) fn new(seed: u64) -> Self {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

xoshiro crate handles endianness explicitly:

impl SplitMix64 {
    /// Seed a `SplitMix64` from a `u64`.
    pub fn from_seed_u64(seed: u64) -> SplitMix64 {
        let mut x = [0; 8];
        LittleEndian::write_u64(&mut x, seed);
        SplitMix64::from_seed(x)
    }
}

@xtqqczze

Copy link
Copy Markdown
Contributor

Tests pass under Miri for a big-endian architecture:

$cargo +nightly miri test --tests splitmix64 --target s390x-unknown-linux-gnu 
running 2 tests
test splitmix64::tests::reference_values ... ok
test splitmix64::tests::reproducible ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 136 filtered out; finished in 0.31s

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.

3 participants