fix: --max-threads now correctly applies thread count to Rayon pool#2082
Open
Gosha250311 wants to merge 1 commit intonexus-xyz:mainfrom
Open
fix: --max-threads now correctly applies thread count to Rayon pool#2082Gosha250311 wants to merge 1 commit intonexus-xyz:mainfrom
Gosha250311 wants to merge 1 commit intonexus-xyz:mainfrom
Conversation
…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>
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.
Problem
The --max-threads flag was silently ignored due to two bugs:
Memory clamping fired automatically whenever --max-threads was set,
overriding the user's request (on 8GB RAM: floor(8*0.75/4) = 1 thread)
num_workers was never passed to the Rayon thread pool in the subprocess,
so Rayon always used its default (1 thread)
Fix
Testing
65 unit tests + 5 integration tests pass, 0 failures
9 new tests added to cover the fix