diff --git a/tests/causal.rs b/tests/causal.rs index 338ae45..5be55dc 100644 --- a/tests/causal.rs +++ b/tests/causal.rs @@ -310,7 +310,14 @@ fn controller_produces_report() { smarm::init(smarm::Config::exact(2)).run(|| { let stop = Arc::new(AtomicBool::new(false)); let stop2 = stop.clone(); + // run_experiments snapshots the site registry once at entry; the + // worker must have executed its first `causal_site!` (lazy + // registration) before the call, or stage-x misses the sweep — a + // race this test loses deterministically on a 1-core box whenever a + // sibling test has already paid the tsc_hz calibration. + let (ready_tx, ready_rx) = smarm::channel::<()>(); let worker = smarm::spawn(move || { + let mut ready = Some(ready_tx); while !stop2.load(Ordering::Relaxed) { { let _g = smarm::causal_site!("stage-x"); @@ -319,8 +326,12 @@ fn controller_produces_report() { } } smarm::progress!("items"); + if let Some(tx) = ready.take() { + let _ = tx.send(()); + } } }); + ready_rx.recv().unwrap(); let results = smarm::causal::run_experiments(&smarm::causal::ExperimentPlan { speedups_pct: vec![0, 50],