feat: simplify worker spawning logic and update macOS build workflow
Updates the release workflow to run macOS builds inside a Docker container with explicit registry authentication and adjusted artifact paths. Bumps the obikmer crate version to 1.1.29 and adds *.log to .gitignore. Simplifies NUMA worker spawning by lowering the activation threshold from 0.95 to 0.2, replacing complex stateful tracking with a direct efficiency check, and downgrading progress logging to debug level. Includes general code formatting improvements for readability.
This commit is contained in:
+14
-44
@@ -217,13 +217,9 @@ impl PartitionRunner {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
const SPAWN_THRESHOLD: f64 = 0.95;
|
||||
const SPAWN_THRESHOLD: f64 = 0.2;
|
||||
const TIMER_SECS: u64 = 30;
|
||||
|
||||
let n_cores = std::thread::available_parallelism()
|
||||
.map(|n| n.get())
|
||||
.unwrap_or(1);
|
||||
|
||||
// ── Channels ──────────────────────────────────────────────────────────
|
||||
let (part_tx, part_rx) = unbounded::<usize>();
|
||||
let (activate_tx, activate_rx) = unbounded::<()>();
|
||||
@@ -290,9 +286,8 @@ impl PartitionRunner {
|
||||
let initial_workers = n_nodes.min(max_workers).min(n_total);
|
||||
for _ in 0..initial_workers { activate_tx.send(()).ok(); }
|
||||
let mut n_active = initial_workers;
|
||||
let mut cpu_sample = CpuSample::now();
|
||||
let mut eff_at_last_spawn = 0.0f64; // 0 = no previous spawn to evaluate
|
||||
let mut completed = 0usize;
|
||||
let mut cpu_sample = CpuSample::now();
|
||||
let mut completed = 0usize;
|
||||
|
||||
while completed < n_total {
|
||||
let Ok(event) = event_rx.recv() else { break };
|
||||
@@ -308,15 +303,13 @@ impl PartitionRunner {
|
||||
// Inline check: same logic as a timer tick.
|
||||
maybe_activate(
|
||||
&activate_tx, &mut n_active, max_workers,
|
||||
&mut cpu_sample, &mut eff_at_last_spawn,
|
||||
n_cores, SPAWN_THRESHOLD, completed, n_total,
|
||||
&mut cpu_sample, SPAWN_THRESHOLD, completed, n_total,
|
||||
);
|
||||
}
|
||||
WorkerEvent::TimerTick => {
|
||||
maybe_activate(
|
||||
&activate_tx, &mut n_active, max_workers,
|
||||
&mut cpu_sample, &mut eff_at_last_spawn,
|
||||
n_cores, SPAWN_THRESHOLD, completed, n_total,
|
||||
&mut cpu_sample, SPAWN_THRESHOLD, completed, n_total,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -343,42 +336,19 @@ enum WorkerEvent<R, E> {
|
||||
}
|
||||
|
||||
fn maybe_activate(
|
||||
activate_tx: &crossbeam_channel::Sender<()>,
|
||||
n_active: &mut usize,
|
||||
max_workers: usize,
|
||||
cpu_sample: &mut CpuSample,
|
||||
eff_at_last_spawn: &mut f64,
|
||||
n_cores: usize,
|
||||
threshold: f64,
|
||||
completed: usize,
|
||||
n_total: usize,
|
||||
activate_tx: &crossbeam_channel::Sender<()>,
|
||||
n_active: &mut usize,
|
||||
max_workers: usize,
|
||||
cpu_sample: &mut CpuSample,
|
||||
threshold: f64,
|
||||
completed: usize,
|
||||
n_total: usize,
|
||||
) {
|
||||
if *n_active >= max_workers || completed >= n_total { return; }
|
||||
|
||||
let eff = cpu_sample.cpu_efficiency(n_cores);
|
||||
if eff >= threshold { return; } // CPU already saturated
|
||||
|
||||
// Check that the previous activation was beneficial enough.
|
||||
// Going from k-1 → k workers, the minimum acceptable speedup is (k-1+0.2)/(k-1).
|
||||
// For the very first extra worker (n_active == 1, no previous spawn), skip this
|
||||
// check: eff_at_last_spawn == 0 acts as the sentinel.
|
||||
let last_spawn_was_beneficial = if *eff_at_last_spawn < 1e-9 || eff < 1e-9 {
|
||||
true // first additional worker, or measurement too short: no prior data to evaluate
|
||||
} else {
|
||||
let k_new = *n_active as f64; // worker count after the last spawn
|
||||
let min_gain = 0.2 / k_new;
|
||||
let actual_gain = (eff - *eff_at_last_spawn) / eff;
|
||||
actual_gain >= min_gain
|
||||
};
|
||||
|
||||
if last_spawn_was_beneficial {
|
||||
if cpu_sample.do_i_activate(threshold) {
|
||||
activate_tx.send(()).ok();
|
||||
*eff_at_last_spawn = eff;
|
||||
*n_active += 1;
|
||||
*cpu_sample = CpuSample::now();
|
||||
debug!(
|
||||
"activated worker {}/{} — efficiency {:.0}%",
|
||||
n_active, max_workers, eff * 100.0,
|
||||
);
|
||||
debug!("activated worker {}/{}", n_active, max_workers);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user