mirror of
https://github.com/ParrotXray/Mantis.git
synced 2026-08-24 18:50:28 +09:00
refactor: replace xsk_cpu_base with xsk_cpu_set for round-robin core distribution
This commit is contained in:
parent
cdda2287ed
commit
b410099c5e
@ -34,9 +34,11 @@ home_net = ["140.130.34.0/24"]
|
||||
# tls_keylog_path = "/tmp/tls_keys.log" # NSS key log file for TLS decryption (SSLKEYLOGFILE)
|
||||
|
||||
# CPU affinity (Linux only). Uncomment and tune for your hardware.
|
||||
# Pin XSK packet threads starting from this core (one core per queue pair).
|
||||
# Example: xsk_cpu_base=0 with combined_queue_count=4 uses cores 0-3 for packets.
|
||||
xsk_cpu_base = 0
|
||||
# Distribute XSK packet threads across a core range [start, end] (inclusive).
|
||||
# Threads are assigned round-robin: core = start + (queue_id % (end - start + 1)).
|
||||
# Example: xsk_cpu_set=[0, 3] with combined_queue_count=8 spreads 16 threads
|
||||
# across cores 0-3, with 4 threads per core.
|
||||
xsk_cpu_set = [0, 3]
|
||||
#
|
||||
# Pin ML inference (ONNX spawn_blocking) to this core.
|
||||
# Example: on an 8-core machine, reserve core 7 for inference.
|
||||
|
||||
@ -134,7 +134,7 @@ impl XskManager {
|
||||
pub struct XskPair {
|
||||
direction: Direction,
|
||||
queue_id: u32,
|
||||
xsk_cpu_base: Option<u32>,
|
||||
xsk_cpu_set: Option<[u32; 2]>,
|
||||
umem: Arc<Umem>,
|
||||
fill_queue: FillQueue,
|
||||
comp_queue: CompQueue,
|
||||
@ -207,7 +207,7 @@ impl XskPair {
|
||||
let xsk_pair = Self {
|
||||
direction,
|
||||
queue_id,
|
||||
xsk_cpu_base: config.xsk_cpu_base,
|
||||
xsk_cpu_set: config.xsk_cpu_set,
|
||||
umem: Arc::new(umem),
|
||||
fill_queue,
|
||||
comp_queue,
|
||||
@ -235,8 +235,9 @@ impl XskPair {
|
||||
thread::Builder::new()
|
||||
.name(thread_name.clone())
|
||||
.spawn(move || {
|
||||
if let Some(base) = self.xsk_cpu_base {
|
||||
set_cpu_affinity((base + self.queue_id) as usize);
|
||||
if let Some([start, end]) = self.xsk_cpu_set {
|
||||
let num_cores = (end - start + 1).max(1);
|
||||
set_cpu_affinity((start + self.queue_id % num_cores) as usize);
|
||||
}
|
||||
|
||||
// StreamReassembler is !Send (Rc inside protolens), so create it here.
|
||||
|
||||
@ -36,10 +36,11 @@ pub struct Config {
|
||||
/// Only useful in [external]->NetGuardia->[internal] deployments where the
|
||||
/// internal server can be configured to write TLS session keys.
|
||||
pub tls_keylog_path: Option<String>,
|
||||
/// First CPU core assigned to XSK packet threads. Each queue pair gets one core
|
||||
/// starting from this base (e.g. base=0 with 4 queues pins to cores 0-3).
|
||||
/// CPU core range [start, end] (inclusive) for XSK packet threads.
|
||||
/// Threads are distributed round-robin: core = start + (queue_id % (end - start + 1)).
|
||||
/// Example: [0, 3] with 8 queues spreads 16 threads across cores 0-3 (4 threads each).
|
||||
/// If absent, no affinity is set.
|
||||
pub xsk_cpu_base: Option<u32>,
|
||||
pub xsk_cpu_set: Option<[u32; 2]>,
|
||||
/// CPU core pinned to the ML inference spawn_blocking thread.
|
||||
/// If absent, defaults to the last available core.
|
||||
pub ml_cpu: Option<u32>,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user