Skip to content

Commit 4a2f8ca

Browse files
Prithvi-Webclaude
andcommitted
test(governor): a hold the machine held back is measured again on the machine's own evidence, and the wait for room ends only on room that lasts
The macOS leg of run 40204757033 failed holds_nineteen_percent_of_this_machine_for_ten_seconds: "mean of the last half 0.1393 is outside ±0.05 of 0.19 (the machine was idle for 0.0572 of it)". The native code is unchanged since the last green run. The runner was overloaded for the whole hold: the sampling thread was woken more than a whole 100 ms period late at four samples of the second half, and later than asked at most of the rest. The workers used what the controller allowed (0.1391 of 0.1434), so the shortfall was in what the controller allowed, on a machine with almost nothing idle. The old rule measured a hold again only when the mean idle share of the second half was within the band (0.05), so 0.057 failed the test on its first try. A hold short of the band is now measured again when the second half shows a full machine in either of two ways, each at least twice (once may be a blip: macOS read 1.000 here at one moment of a half that was 0.76 idle): - a machine reading at or over the controller's own line (MACHINE_FULL_SHARE), at which the controller holds its duty rather than wind it up against work that is not its own; - the sampling thread woken a whole period late, which means no core was free for it. The hold report keeps each machine reading it took (machine_busy, Rust only: skipped when the report is serialized for Node, whose keys nativeLoader pins). The wait for room before the next hold now ends only after three readings in a row with room: with eight busy loops on this Mac's eight cores, one reading of 0.40 idle in 50 s used to end it. This changes only when a hold is measured again. The last of the three attempts is still held to the band whatever the machine did, and its message now says how many readings found the machine full and how many wakeups came late, and names only the signs it saw. A governor that really under-holds still fails: with the controller's duty capped at a quarter it held 0.038 of 0.19 on this Mac, and the test failed on the band with the machine 0.85 idle. Checked: 17 hand mutants of the predicate, the wait, the message and the report field, each red and restored by SHA-256. The hold test on this Mac (8 cores): 10 of 10 passed at once under 4 busy loops; 5 of 5 failed honestly under 10, after three attempts, each naming a machine full at nearly every reading; and under 10 busy loops for the first 8 s of each run, 6 of 6 held 0.10 to 0.14 at the first attempt, measured again and passed at 0.19. The second halves of those six first holds were 0.18 to 0.29 idle, so the old rule would have failed all six at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent b788ae9 commit 4a2f8ca

3 files changed

Lines changed: 439 additions & 27 deletions

File tree

‎native/treemap-core/crates/tm-governor/src/loadgen.rs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,14 @@ pub struct HoldReport {
232232
/// when it published none or exposes none. A hold under its target on a
233233
/// machine with no idle CPU measured the machine, not the governor.
234234
pub machine_idle_last_half: Option<f64>,
235+
/// The whole machine's busy share at each sample, as the OS published it: `None` at a
236+
/// sample it published nothing new for (macOS publishes about once a second) and where it
237+
/// exposes none. [`machine_idle_last_half`](Self::machine_idle_last_half) is one minus the
238+
/// mean of the second half's; the readings themselves say how many of them found the
239+
/// machine full, which the controller acts on one reading at a time and a mean cannot
240+
/// show (`MACHINE_FULL_SHARE`). Rust-only, like [`intervals`](Self::intervals).
241+
#[serde(skip_serializing)]
242+
pub machine_busy: Vec<Option<f64>>,
235243
}
236244

237245
/// Runs a synthetic load on `governor` for `seconds` and measures the share
@@ -281,6 +289,7 @@ pub fn hold(governor: &Governor, seconds: f64, sampler: &mut dyn CpuSampler) ->
281289
let closing = governor.snapshot();
282290
HoldReport {
283291
machine_idle_last_half: machine_idle_last_half(&machine_busy),
292+
machine_busy,
284293
..summarise(target, series, cores, closing.workers, closing.duty)
285294
}
286295
}
@@ -390,6 +399,7 @@ fn summarise(
390399
allowed_last_half,
391400
workers_last_half,
392401
machine_idle_last_half: None,
402+
machine_busy: Vec::new(),
393403
}
394404
}
395405

0 commit comments

Comments
 (0)