diag(runtime): wake-path counters in SchedulerStats + RuntimeStats::wake_diag; RQDIAG/DIAG lines in rq_runtime and general (target 5, finding 17)

This commit is contained in:
claude-asm-audit
2026-08-21 12:22:46 +00:00
parent 77938cd31d
commit 7001f04b65
3 changed files with 117 additions and 10 deletions
+19 -4
View File
@@ -433,9 +433,19 @@ fn bench_pp_tokio_multi() -> (u64, u128) {
// 5. spawn_pair_control — section 4 minus the messages
// ---------------------------------------------------------------------------
/// Target-5 instrumentation: emit the runtime's wake-path counters for one
/// run when SMARM_WAKE_DIAG is set. Off by default so sweep.py output is
/// unchanged.
fn wake_diag(section: &str, threads: usize, rt: &smarm::runtime::Runtime, us: u128) {
if std::env::var_os("SMARM_WAKE_DIAG").is_some() {
println!("DIAG,{section},{threads},{us},{}", rt.stats().wake_diag());
}
}
fn bench_ctl_smarm(threads: usize) -> (u64, u128) {
let start = Instant::now();
smarm::runtime::init(bench_cfg(threads)).run(|| {
let rt = smarm::runtime::init(bench_cfg(threads));
rt.run(|| {
for _ in 0..PP_ROUNDS {
let hb = smarm::spawn(|| {});
let ha = smarm::spawn(|| {});
@@ -443,7 +453,9 @@ fn bench_ctl_smarm(threads: usize) -> (u64, u128) {
hb.join().unwrap();
}
});
(PP_ROUNDS, start.elapsed().as_micros())
let us = start.elapsed().as_micros();
wake_diag("spawn_pair_control", threads, &rt, us);
(PP_ROUNDS, us)
}
fn bench_ctl_tokio_current() -> (u64, u128) {
@@ -488,7 +500,8 @@ const PP_STEADY: u64 = 10_000;
fn bench_steady_smarm(threads: usize) -> (u64, u128) {
let start = Instant::now();
smarm::runtime::init(bench_cfg(threads)).run(|| {
let rt = smarm::runtime::init(bench_cfg(threads));
rt.run(|| {
let (tx_ab, rx_ab) = smarm::channel::<u64>();
let (tx_ba, rx_ba) = smarm::channel::<u64>();
let echo = smarm::spawn(move || {
@@ -504,7 +517,9 @@ fn bench_steady_smarm(threads: usize) -> (u64, u128) {
}
echo.join().unwrap();
});
(PP_STEADY, start.elapsed().as_micros())
let us = start.elapsed().as_micros();
wake_diag("ping_pong_steady", threads, &rt, us);
(PP_STEADY, us)
}
async fn steady_tokio_body() {
+5
View File
@@ -90,6 +90,7 @@ struct Sample {
us: u128,
hits: u64,
displacements: u64,
diag: String,
}
fn yield_storm(threads: usize, slot: bool, actors: usize, yields: usize) -> Sample {
@@ -116,6 +117,7 @@ fn yield_storm(threads: usize, slot: bool, actors: usize, yields: usize) -> Samp
us,
hits: stats.slot_hits(),
displacements: stats.slot_displacements(),
diag: stats.wake_diag(),
}
}
@@ -159,6 +161,7 @@ fn ping_pong_pairs(threads: usize, slot: bool, pairs: usize, roundtrips: usize)
us,
hits: stats.slot_hits(),
displacements: stats.slot_displacements(),
diag: stats.wake_diag(),
}
}
@@ -185,6 +188,7 @@ fn spawn_storm(threads: usize, slot: bool, spawns: usize) -> Sample {
us,
hits: stats.slot_hits(),
displacements: stats.slot_displacements(),
diag: stats.wake_diag(),
}
}
@@ -253,6 +257,7 @@ fn main() {
mid.us,
per_s
);
println!("RQDIAG,{},{},{},{},{}", variant(), slot_str, name, t, mid.diag);
if slot {
println!(
"RQSLOT,{},{},{},{},{}",