diff --git a/Cargo.lock b/Cargo.lock index 3e25898f0d..b269d0bba5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -464,6 +464,17 @@ dependencies = [ "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "core_affinity" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "crc" version = "1.8.1" @@ -2157,6 +2168,7 @@ dependencies = [ "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "core_affinity 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3456,6 +3468,7 @@ dependencies = [ "checksum cookie_store 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46750b3f362965f197996c4448e4a0935e791bf7d6631bfce9ee0af3d24c919c" "checksum core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "286e0b41c3a20da26536c6000a280585d519fd07b3956b43aed8a79e9edce980" "checksum core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "716c271e8613ace48344f723b60b900a93150271e5be206212d052bbc0883efa" +"checksum core_affinity 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6d162c6e463c31dbf78fefa99d042156c1c74d404e299cfe3df2923cb857595b" "checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" diff --git a/core/Cargo.toml b/core/Cargo.toml index 1733ee8000..e0eb480ad9 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -25,6 +25,7 @@ bs58 = "0.2.0" byteorder = "1.3.1" chrono = { version = "0.4.0", features = ["serde"] } crc = { version = "1.8.1", optional = true } +core_affinity = "0.5.9" hashbrown = "0.2.0" indexmap = "1.0" itertools = "0.8.0" diff --git a/core/src/poh_service.rs b/core/src/poh_service.rs index d7c52fcd55..4d353119ac 100644 --- a/core/src/poh_service.rs +++ b/core/src/poh_service.rs @@ -2,6 +2,7 @@ //! "ticks", a measure of time in the PoH stream use crate::poh_recorder::PohRecorder; use crate::service::Service; +use core_affinity; use solana_sdk::poh_config::PohConfig; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; @@ -33,6 +34,9 @@ impl PohService { if poh_config.hashes_per_tick.is_none() { Self::sleepy_tick_producer(poh_recorder, &poh_config, &poh_exit_); } else { + if let Some(cores) = core_affinity::get_core_ids() { + core_affinity::set_for_current(cores[0]); + } Self::tick_producer(poh_recorder, &poh_exit_); } poh_exit_.store(true, Ordering::Relaxed);