Use num_cpus to get number of cores

next
Sayan Nandan 3 years ago
parent 4bd717b899
commit f9f49aee0b

@ -14,8 +14,6 @@ jobs:
curl https://sh.rustup.rs -sSf | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Test
run: |
make test
run: make test
- name: Stress test
run: |
make stress
run: make stress

1
Cargo.lock generated

@ -1046,6 +1046,7 @@ dependencies = [
"env_logger",
"libstress",
"log",
"num_cpus",
"rand",
"skytable",
"sysinfo",

@ -17,3 +17,4 @@ env_logger = "0.8.4"
log = "0.4.14"
rand = "0.8.4"
crossbeam-channel = "0.5.1"
num_cpus = "1.13.0"

@ -56,12 +56,10 @@ fn main() {
// get the rng and refresh sysinfo
let mut rng = thread_rng();
// we only need to refresh memory and CPU info; don't waste time syncing other things
let to_refresh = RefreshKind::new().with_memory().with_cpu();
let to_refresh = RefreshKind::new().with_memory();
let mut sys = System::new_with_specifics(to_refresh);
sys.refresh_specifics(to_refresh);
let core_count = sys
.get_physical_core_count()
.exit_error("Failed to get physical core count");
let core_count = num_cpus::get();
let max_workers = core_count * 2;
trace!(
"This host has {} logical cores. Will spawn a maximum of {} threads",

Loading…
Cancel
Save