ui: give the worst-call ordering test margins a stall cannot invert
`the_worst_call_is_one_calls_cost_and_not_the_mean` reads both its orderings off a wall clock, and the margins were too thin to survive the full suite: it failed about one run in three, on an idle box as well as a loaded one. One of the steady handler's ten calls would pick up a ~0.9 ms scheduler stall and overtake the spike it is meant to rank below — `self_us` 5109 / `worst_us` 1405 against the spike's 1398 / 1361. Twenty steady calls instead of ten raise the window cost without raising any single call's, and an 8x spike instead of 3x puts the worst-call margin about four times beyond the stall that broke it. Six consecutive full-suite runs clean, then a full gate chain. The doc comment carries the measured numbers and says to keep both ratios, since the absolute durations are not what the test rests on. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SgstFWtn1RxEJ5kVrpgYwn
This commit is contained in:
@@ -198,27 +198,35 @@ fn disarming_clears_the_window() {
|
||||
);
|
||||
}
|
||||
|
||||
/// The column the mean cannot show: a handler that stalls one frame in ten ranks below a steadier
|
||||
/// one by self time and still has the larger worst call. The two bodies differ by 3x in work per
|
||||
/// the ratio below, which is the margin the ordering rests on — not an absolute duration.
|
||||
/// The column the mean cannot show: a handler that stalls one frame in twenty ranks below a
|
||||
/// steadier one by self time and still has the larger worst call.
|
||||
///
|
||||
/// Both orderings are read off a wall clock, so the margins are what make the test an assertion
|
||||
/// rather than a coin toss, and they are set against a measured stall, not a guess. At 10 steady
|
||||
/// calls against one spike of 3x their size this failed about one run in three inside the full
|
||||
/// suite: one steady call would pick up a ~0.9 ms scheduler stall and overtake the spike's 1.4 ms
|
||||
/// (`self_us` 5109 / `worst_us` 1405 against 1398 / 1361). Twenty steady calls raise the *window*
|
||||
/// cost without raising any single call's, and an 8x spike puts the worst-call margin about four
|
||||
/// times beyond the stall that broke it. Keep both ratios if these numbers are ever tuned; the
|
||||
/// absolute durations do not matter.
|
||||
#[test]
|
||||
fn the_worst_call_is_one_calls_cost_and_not_the_mean() {
|
||||
let mut s = armed();
|
||||
s.run(
|
||||
r#"
|
||||
local function burn(n) local x = 0 for i = 1, n do x = x + i end return x end
|
||||
-- 10 calls of 50k: the larger self time, the smaller single call.
|
||||
-- 20 calls of 50k: the larger self time, the smaller single call.
|
||||
local steady = CreateFrame("Frame", "Steady")
|
||||
steady:SetScript("OnUpdate", function() burn(50000) end)
|
||||
-- One call of 150k, on the first tick only: the smaller self time, the larger single call.
|
||||
-- One call of 400k, on the first tick only: the smaller self time, the larger single call.
|
||||
local spiky = CreateFrame("Frame", "Spiky")
|
||||
spiky:SetScript("OnUpdate", function()
|
||||
if not this.done then this.done = true burn(150000) end
|
||||
if not this.done then this.done = true burn(400000) end
|
||||
end)
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
for _ in 0..10 {
|
||||
for _ in 0..20 {
|
||||
s.tick(0.016);
|
||||
}
|
||||
assert!(s.errors().is_empty(), "{:?}", s.errors());
|
||||
@@ -226,7 +234,7 @@ fn the_worst_call_is_one_calls_cost_and_not_the_mean() {
|
||||
let rows = s.handler_profile();
|
||||
let steady = row(&rows, "Steady", "OnUpdate").expect("the steady handler");
|
||||
let spiky = row(&rows, "Spiky", "OnUpdate").expect("the spiky handler");
|
||||
assert_eq!((steady.calls, spiky.calls), (10, 10));
|
||||
assert_eq!((steady.calls, spiky.calls), (20, 20));
|
||||
assert!(
|
||||
steady.self_us > spiky.self_us,
|
||||
"the steady handler costs more over the window, so it ranks first: {rows:#?}"
|
||||
@@ -243,7 +251,7 @@ fn the_worst_call_is_one_calls_cost_and_not_the_mean() {
|
||||
let spiky_mean = spiky.self_us / f64::from(spiky.calls);
|
||||
assert!(
|
||||
spiky.worst_us > spiky_mean * 2.0,
|
||||
"nine of its ten calls do nothing, so the mean hides the stall by about tenfold: \
|
||||
"nineteen of its twenty calls do nothing, so the mean hides the stall by about twentyfold: \
|
||||
worst {:.1} us against a mean of {spiky_mean:.1} us",
|
||||
spiky.worst_us
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user