Repository navigation
ledger: take default thread counts from available_parallelism - #16515
Merged
Merged
Conversation
Problem: the replay verification pool and the rocksdb compaction default wrap `num_cpus::get()` in `NonZeroUsize::new(..).expect(..)`, while `std::thread::available_parallelism` already returns a `NonZeroUsize`. Summary of Changes Use `available_parallelism`, falling back to one thread like `num_cpus` does when the count is unknown.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #16515 +/- ##
=========================================
- Coverage 82.5% 82.3% -0.2%
=========================================
Files 956 956
Lines 374013 374015 +2
=========================================
- Hits 308618 308165 -453
- Misses 65395 65850 +455 🚀 New features to boost your workflow:
|
kskalski
marked this pull request as ready for review
October 29, 2026 10:06
DSharifi
reviewed
Oct 29, 2026
DSharifi
left a comment
There was a problem hiding this comment.
Can we also change the two last remaining usages of num_cpus and kill the dependency to it in the solana-ledger crate?
agave on ks/available_parallelism [$] is 📦 v4.5.0-alpha.4 via 🦀 v1.99.1
❯ rg num_cpus ledger/
ledger/src/blockstore_db.rs
1231: NonZeroUsize::new((num_cpus::get() / 4).max(1)).expect("thread count is non-zero")
ledger/Cargo.toml
55:num_cpus = { workspace = true }
ledger/src/bigtable_upload.rs
33: let num_blocks_to_upload_in_parallel = num_cpus::get() / 2;
Problem: `solana-ledger` depends on `num_cpus` only for the rocksdb flush thread default and the bigtable upload parallelism, which `std::thread::available_parallelism` covers. Summary of Changes Take both defaults from `available_parallelism` and remove `num_cpus` from `solana-ledger`.
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 replay verification pool and the rocksdb compaction default wrap
num_cpus::get()inNonZeroUsize::new(..).expect(..), whilestd::thread::available_parallelismalready returns aNonZeroUsize.Summary of Changes
Use
available_parallelism, falling back to one thread likenum_cpusdoes when the count is unknown.Testing
CI