Skip to content

ledger: take default thread counts from available_parallelism - #16515

Merged
kskalski merged 2 commits into
anza-xyz:masterfrom
kskalski:ks/available_parallelism
Oct 29, 2026
Merged

kskalski merged 2 commits into
anza-xyz:masterfrom
kskalski:ks/available_parallelism

Conversation

@kskalski

@kskalski kskalski commented Oct 29, 2026 •

Copy link
Copy Markdown

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.

Testing

CI

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-commenter

codecov-commenter commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.3%. Comparing base (0f21aa8) to head (282fe75).
⚠️ Report is 2 commits behind head on master.

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kskalski
kskalski marked this pull request as ready for review October 29, 2026 10:06
@kskalski
kskalski requested a review from DSharifi October 29, 2026 10:06

@DSharifi DSharifi 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.

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`.

@DSharifi DSharifi 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.

Thanks for this cleanup!

@kskalski
kskalski added this pull request to the merge queue Oct 29, 2026
Merged via the queue into anza-xyz:master with commit ca2a4b6 Oct 29, 2026
57 checks passed
@kskalski
kskalski deleted the ks/available_parallelism branch October 29, 2026 12:50
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