Skip to content

Commit

Permalink
chore: fvm, integration: remove num_cpus (#1988)
Browse files Browse the repository at this point in the history
`std::thread::available_parallelism` is the right function to call now.

Also remove `INITIAL_RESERVE_BALANCE` which was unused.
  • Loading branch information
Stebalien authored Feb 9, 2024
1 parent 5cd204d commit 10842cb
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion fvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ derive_more = "0.99.17"
replace_with = "0.1.7"
filecoin-proofs-api = { version = "16", default-features = false }
rayon = "1"
num_cpus = "1.15.0"
fvm-wasm-instrument = "0.4.0"
yastl = "0.1.2"
static_assertions = "1.1.0"
Expand Down
7 changes: 4 additions & 3 deletions fvm/src/kernel/filecoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ use crate::{syscall_error, DefaultKernel, Kernel};
use super::prelude::*;

lazy_static! {
static ref NUM_CPUS: usize = num_cpus::get();
static ref INITIAL_RESERVE_BALANCE: TokenAmount = TokenAmount::from_whole(300_000_000);
static ref AVAILABLE_PARALLELISM: usize = std::thread::available_parallelism()
.map(Into::into)
.unwrap_or(8);
}

pub trait FilecoinKernel: Kernel {
Expand Down Expand Up @@ -176,7 +177,7 @@ where
}
log::debug!("batch verify seals start");
let out = items.par_drain(..)
.with_min_len(vis.len() / *NUM_CPUS)
.with_min_len(vis.len() / *AVAILABLE_PARALLELISM)
.map(|(seal, timer)| {
let start = GasTimer::start();
let verify_seal_result = std::panic::catch_unwind(|| verify_seal(seal));
Expand Down
1 change: 0 additions & 1 deletion testing/conformance/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ base64 = "0.21.2"
flate2 = { version = "1.0" }
colored = "2"
either = "1.8.1"
num_cpus = "1.15.0"
walkdir = "2.3"
regex = { version = "1.8" }
ittapi-rs = { version = "0.3.0", optional = true }
Expand Down
3 changes: 2 additions & 1 deletion testing/conformance/tests/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::io::BufReader;
use std::iter;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::thread::available_parallelism;

use anyhow::{anyhow, Context as _};
use async_std::{stream, sync, task};
Expand Down Expand Up @@ -47,7 +48,7 @@ lazy_static! {
.map(|s| {
let s = s.to_str().unwrap();
s.parse().expect("parallelism must be an integer")
}).unwrap_or_else(num_cpus::get).min(48);
}).or_else(|| available_parallelism().map(Into::into).ok()).unwrap_or(8).min(48);

/// By default a post-condition error is fatal and stops all testing. We can use this env var to relax that
/// and let the test carry on (optionally with a warning); there's a correctness check against the post condition anyway.
Expand Down

0 comments on commit 10842cb

Please sign in to comment.