perf(prover): default rayon to available_parallelism#2727
Open
tamirhemo wants to merge 2 commits into
Open
Conversation
This was referenced Apr 20, 2026
SMT (hyper-threading) siblings cause excessive crossbeam work-stealing contention that dominates ~30% of CPU prove time. Defaulting the rayon global thread pool to num_cpus::get_physical() instead of logical cores reduces this to ~12%. Benchmark results on AMD Threadripper 7970X (32 physical / 64 logical): fib: 35,380ms → 28,026ms (-20.8%) keccak: 42,847ms → 35,936ms (-16.1%) big: 47,697ms → 38,664ms (-18.9%) The change is in slop_futures::rayon::init_global_pool(), called eagerly from cpu_worker_builder(). Users can still override via RAYON_NUM_THREADS environment variable. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
num_cpus::get_physical() reads /proc/cpuinfo which is not namespaced in containers — it always returns the host's physical core count, ignoring cgroup CPU quotas (docker --cpus, K8s resources.limits.cpu). Use min(available_parallelism, get_physical()) instead: - available_parallelism reads cgroup v1/v2 quota files, so it respects container CPU limits - get_physical caps to avoid SMT oversubscription on bare metal - RAYON_NUM_THREADS still overrides everything Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1ca8644 to
377d9f6
Compare
b2a6833 to
31ac2a3
Compare
available_parallelism
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.
Summary
min(available_parallelism, physical_cores)instead of logical coresRAYON_NUM_THREADSenvironment variableBenchmark results (AMD Threadripper 7970X, 32 physical / 64 logical)
Profile diff (fib)
crossbeam_epoch::with_handle: 17.4% → 7.9% (down 55%)crossbeam_epoch::try_advance: 7.6% → 1.5% (down 80%)crossbeam_deque::steal: 5.3% → 2.9% (down 45%)Changes
slop/crates/futures/src/rayon.rs—init_global_pool()now public, defaults to physical corescrates/prover/src/worker/builder.rs— callsinit_global_pool()at start ofcpu_worker_builder()Stack
tamir/perf-mimalloc— E2: optional mimalloc allocatorTest plan
RAYON_NUM_THREADSunset → prover uses physical core countRAYON_NUM_THREADS=64→ prover uses 64 threads (override works)🤖 Generated with Claude Code