From a19bd458c4f45bd5b79ae4a1463243f5d739f4cf Mon Sep 17 00:00:00 2001 From: joshua-spacetime Date: Tue, 10 Jun 2025 10:46:52 -0700 Subject: [PATCH] Reserve cores 0 and 1 for the OS (#2851) --- crates/core/src/startup.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/core/src/startup.rs b/crates/core/src/startup.rs index 57d9f7177e..0dc9476032 100644 --- a/crates/core/src/startup.rs +++ b/crates/core/src/startup.rs @@ -1,5 +1,6 @@ use core_affinity::CoreId; use crossbeam_queue::ArrayQueue; +use itertools::Itertools; use spacetimedb_paths::server::{ConfigToml, LogsDir}; use std::path::PathBuf; use std::time::Duration; @@ -194,7 +195,14 @@ pub struct Cores { impl Cores { fn get() -> Option { let cores = &mut core_affinity::get_core_ids() - .filter(|cores| cores.len() >= 8)? + .filter(|cores| cores.len() >= 10)? + .into_iter() + // We reserve the first two cores for the OS. + // This allows us to pin interrupt handlers (IRQs) to these cores, + // particularly those for incoming network traffic, + // preventing them from preempting the main reducer threads. + .filter(|core_id| core_id.id > 1) + .collect_vec() .into_iter(); let total = cores.len() as f64;