Skip to content

fix: --max-threads now correctly applies thread count to Rayon pool#2082

Open
Gosha250311 wants to merge 1 commit intonexus-xyz:mainfrom
Gosha250311:main
Open

fix: --max-threads now correctly applies thread count to Rayon pool#2082
Gosha250311 wants to merge 1 commit intonexus-xyz:mainfrom
Gosha250311:main

Conversation

@Gosha250311
Copy link

Problem

The --max-threads flag was silently ignored due to two bugs:

  1. Memory clamping fired automatically whenever --max-threads was set,
    overriding the user's request (on 8GB RAM: floor(8*0.75/4) = 1 thread)

  2. num_workers was never passed to the Rayon thread pool in the subprocess,
    so Rayon always used its default (1 thread)

Fix

  1. Memory clamp now only runs when --check-memory is explicitly passed
  2. num_workers is now forwarded through pipeline → engine → subprocess → Rayon

Testing

65 unit tests + 5 integration tests pass, 0 failures
9 new tests added to cover the fix

…y clamp

Two bugs prevented --max-threads from taking effect:

1. Memory clamping fired automatically whenever --max-threads was set
   (condition was `max_threads.is_some() || check_mem`). On machines
   with ≤8 GB RAM the formula `floor(RAM * 0.75 / 4 GB)` evaluates to 1,
   silently overriding the user's value and causing the dashboard to always
   show "Threads: 1". The guard is now gated on --check-memory only.

2. The Rayon thread pool (used by nexus-sdk's Stwo prover inside each
   proving subprocess) was never configured from num_workers. Added a
   --num-threads flag to the hidden prove-fib-subprocess subcommand;
   prove_and_validate forwards the value when spawning the subprocess,
   and prove_fib_subprocess calls rayon::ThreadPoolBuilder::build_global
   at startup so the prover uses exactly the requested thread count.

Also adds unit tests for the num_workers computation logic and integration
tests confirming both --max-threads and --num-threads are accepted by clap.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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