Skip to content

Commit

Permalink
fix(config): change default for the cpu range in nox (#2140)
Browse files Browse the repository at this point in the history
* fix

* fix fmt
  • Loading branch information
gurinderu committed Mar 8, 2024
1 parent fd6acf6 commit c976373
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/server-config/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::net::IpAddr;
use std::path::{Path, PathBuf};
use std::time::Duration;

use core_manager::CoreRange;
use libp2p::core::Multiaddr;
use libp2p::identity::ed25519::Keypair;
use libp2p::identity::PublicKey;
Expand Down Expand Up @@ -70,6 +71,20 @@ pub fn default_system_cpu_count() -> usize {
}
}

pub fn default_cpus_range() -> Option<CoreRange> {
let total = num_cpus::get_physical();
let left = match total {
c if c > 32 => 3,
c if c > 16 => 2,
c if c > 8 => 1,
_ => 0,
};
Some(
CoreRange::try_from(Vec::from_iter(left..total).as_slice())
.expect("Cpu range can't be empty"),
)
}

pub fn default_websocket_port() -> u16 {
9999
}
Expand Down
1 change: 1 addition & 0 deletions crates/server-config/src/node_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use super::defaults::*;
#[derive(Clone, Deserialize, Serialize, Derivative)]
#[derivative(Debug)]
pub struct UnresolvedNodeConfig {
#[serde(default = "default_cpus_range")]
pub cpus_range: Option<CoreRange>,

#[serde(default = "default_system_cpu_count")]
Expand Down

0 comments on commit c976373

Please sign in to comment.