Files
reims-vgpu/scripts/sustained-animation-probe/anim.html
T
Anees Iqbal 4506c690eb 🔧 The animation probe forces layer promotion rather than hinting it, because the hint left the instrument bimodal by 24%
Component: scripts/sustained-animation-probe (host-side probe page; no device
code touched, no pathway-specific behavior).

What changed
------------
`anim.html`'s eight bands were promoted to composited layers by
`will-change: transform`, which is advisory — a compositor is free to decline
it. Ten driven macos-13 boots of one pinned binary, same snapshot, same probe,
same quiesced host, split into two tight clusters and landed nowhere between
them: 417.9-429.0 draws per presented frame against 267.7-268.5, and a
`present_hz` median of 39.1-41.7 against 49.0-50.6. Eight of ten drew the first.
Which cluster a boot drew was uncorrelated with the constant under test.

That 24% gap is larger than any device effect measured against this probe, so
the instrument could not resolve a real 17% change, and would credit the cluster
to whichever arm happened to draw it. That is not hypothetical: a cap sweep read
as a clean curve with a peak, and the repeat of one arm disagreed with itself by
more than the whole spread.

So the page stops hinting. `.band` carries `backface-visibility: hidden` and
`tick()` writes `translate3d(x%, 0, 0)` in place of `translateX(x%)`.

Both halves are load-bearing, and this is the trap in the obvious fix: `tick()`
assigns `style.transform` every frame, so a `transform: translateZ(0)` written
into the CSS rule is overwritten on the first frame and the change reads as
having been made while doing nothing. The 3D transform has to be in the JS.

Why this is the collapsed cluster's cause
-----------------------------------------
A band that is not promoted is repainted into its parent rather than composited,
which is fewer and larger draws — matching the collapsed cluster's 1.57x lower
draws per frame, its higher `draw_cover_loaded_partial_scissor` share, and its
*higher* present rate on *fewer* draws. It is the guest asking for less work per
frame, not this device delivering more.

Verification
------------
Not verified. This is a hypothesis about why the clusters exist, implemented;
the reading that confirms it is three driven macos-13 boots all landing in the
promoted cluster, and it has not been taken yet. A follow-up commit carries the
result and retracts this if the split survives.

No Rust changed, so no clippy arm, feature matrix or test run applies. Boots
taken before this commit are not comparable to boots taken after it, whichever
way the reading goes.

`drain_duty draws` over `window_publish fresh` remains the discriminator, and
AGENTS.md still says to classify a boot before comparing two — this narrows what
the classification has to reject, it does not remove the need to look.
2026-08-11 03:36:38 +03:00

129 lines
5.2 KiB
HTML

<!doctype html>
<!--
A sustained, full-rate compositor load for the guest, served from the HOST.
Why this page exists: `hammer.sh` drives the window server in bursts and sleeps
between them, so ~60 % of its wall clock has zero draws and its `present_hz`
median reads 2.8 Hz on a device that sustains ~79. A frame-rate test page run
by hand showed that; this is that workload made reproducible — no internet, no
page that can change under the measurement, and a fixed amount of work per
frame so two boots are comparable.
Everything is deterministic: the step is per *frame*, never per wall-clock
millisecond, so a slow boot and a fast boot draw the same content per frame and
differ only in how many frames they get through. Nothing here reads the clock
except the on-screen counter, which is display only.
-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>reims-vgpu sustained animation</title>
<style>
html, body { margin: 0; padding: 0; background: #101014; overflow: hidden; }
/* Full-viewport bands, each a separately composited layer, so the window
server composites N surfaces per frame rather than repainting one. That is
the shape this device serves.
Promotion is forced, not hinted. `will-change: transform` alone is advisory
and the compositor may decline it: ten boots of one binary split into two
tight clusters, ~420 draws per presented frame and ~268, with a 24 %
`present_hz` gap between them and nothing in between — larger than any
device effect measured against this probe. The collapsed cluster is bands
repainted into their parent instead of composited. `backface-visibility`
here plus the 3D transform in `tick()` take the promotion out of the
compositor's discretion. Both halves are required: this rule cannot carry a
`transform`, because `tick()` overwrites the inline one every frame. */
.band {
position: absolute; left: 0; width: 100%; height: 11%;
will-change: transform;
backface-visibility: hidden;
}
.box {
position: absolute; top: 8%; height: 84%; width: 12vh;
border-radius: 12px;
}
#fps {
position: absolute; right: 12px; bottom: 8px; z-index: 10;
font: 16px -apple-system, Helvetica, sans-serif; color: #9f9;
}
canvas { position: absolute; left: 0; bottom: 12%; width: 100%; height: 22%; }
</style>
<body>
<canvas id="c" width="1024" height="192"></canvas>
<div id="fps">warming up</div>
<script>
// Eight bands of moving boxes. Each band is its own composited layer and moves
// at its own rate, so no two frames are a repeat of an earlier pair and the
// compositor cannot elide one.
const BANDS = 8;
const BOXES_PER_BAND = 6;
const bands = [];
for (let b = 0; b < BANDS; b++) {
const el = document.createElement('div');
el.className = 'band';
el.style.top = (b * 12 + 1) + '%';
for (let i = 0; i < BOXES_PER_BAND; i++) {
const box = document.createElement('div');
box.className = 'box';
box.style.left = (i * 100 / BOXES_PER_BAND) + '%';
box.style.background = `hsl(${(b * 45 + i * 7) % 360} 80% 55%)`;
el.appendChild(box);
}
document.body.appendChild(el);
bands.push(el);
}
// A canvas repainted every frame, so the guest also uploads texture content
// rather than only re-compositing existing surfaces. Both rails matter and a
// pure-transform page exercises only one.
const ctx = document.getElementById('c').getContext('2d');
const fpsEl = document.getElementById('fps');
let frame = 0;
let windowStart = performance.now();
let windowFrames = 0;
function tick() {
frame++;
// Per-frame step, not per-millisecond: identical content per frame number on
// every boot. 360 frames is one full traversal at 1/360th of the width.
const phase = (frame % 360) / 360;
for (let b = 0; b < BANDS; b++) {
// Alternating direction, and a per-band multiplier that is coprime with the
// band count so the layers never line up into one repeating composite.
const dir = b % 2 === 0 ? 1 : -1;
const x = dir * ((phase * (b + 3)) % 1) * 100;
// `translate3d` and not `translateX`: the 3D form is what keeps the band on
// the composited path every frame. See the `.band` rule above.
bands[b].style.transform = `translate3d(${x}%, 0, 0)`;
}
const w = ctx.canvas.width, h = ctx.canvas.height;
ctx.fillStyle = '#101014';
ctx.fillRect(0, 0, w, h);
ctx.lineWidth = 3;
for (let i = 0; i < 24; i++) {
ctx.strokeStyle = `hsl(${(frame * 2 + i * 15) % 360} 90% 60%)`;
ctx.beginPath();
for (let x = 0; x <= w; x += 16) {
const y = h / 2 + Math.sin((x / w) * 6.283 * 3 + (frame + i * 9) / 12) * (h / 2 - 8);
if (x === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y);
}
ctx.stroke();
}
// Display only. The device-side census is the measurement; this is here so a
// human watching the VM can see the page is live.
windowFrames++;
const now = performance.now();
if (now - windowStart >= 1000) {
fpsEl.textContent = (windowFrames * 1000 / (now - windowStart)).toFixed(1) +
' fps · frame ' + frame;
windowStart = now; windowFrames = 0;
}
requestAnimationFrame(tick);
}
requestAnimationFrame(tick);
</script>
</body>