Pathway: x86 macOS / Linux Vulkan. New probe under `scripts/`; no device code.
`sustained-animation-probe` has stopped being able to measure this device on
macos-13. The guest produces ~26 800 draws and ~76 presented frames a second
whatever the device does underneath, and the drain worker sits at duty 0.83 —
it has idle time. A measured 3.9 us/chain saving in the pipeline span moved
`draws_s` by less than 0.1 %, and `slot_us` rose 77 -> 129 ms/s with
`ring_retire_blocks` 291 -> 496: the worker spent exactly what it saved
waiting, because there was no more guest work to do with it.
A probe the device cannot fall behind reports "no effect" for a real win and
for a real regression alike. That is the failure this replaces, and it is not
fixed by running the old probe longer or more often.
`gpu-load-probe` makes each guest frame heavier rather than asking for more
frames — which is also the only thing a page can do, since the frame rate is
the guest's own display cadence. Three dials, because they land on three
different rails and a change can help one and hurt another:
layers=N composited surfaces -> the writeback / store rail
verts=K per-frame WebGL bufferData -> the guest buffer gather rail
tex=W per-frame 2D canvas repaint -> the sampled-image rail
The gather axis is the one nothing else here reaches. On a compositing load
`buffer_guest_gather_bytes` is 5.8 GB/s over 427 000 transfer regions a
second — the largest GPU cost left in the device now the writeback scatters in
one dispatch — and a CSS page barely exercises it. A WebGL canvas that
re-uploads its whole vertex buffer every frame does exactly that, and the
shader is deliberately trivial so the cost lands on the gather rather than on
fragments.
Determinism follows `anim.html`'s rule and for its reason: every step is per
frame, nothing in the content reads the clock, so two boots draw identical
content per frame and differ only in how many frames they get through. Layer
promotion is forced with `backface-visibility` plus a 3D transform rather than
hinted with `will-change`, which that page measured to be advisory often enough
to split boots of one binary into two clusters 24 % apart.
The URL is written to `<outdir>/load-url.txt`, so a result read later says
which load produced it. Two boots at different dials are two workloads, not two
readings.
Verification performed:
- `bash -n` on the script; the shim `kb/harness/gpuload.sh` (gitignored)
drops it into `ab.sh` as `AB_PROBE` the way `anim.sh` does
Not verified: **this probe has not been run against a guest yet.** It is
written to the same interface and the same serving pattern as
`sustained-animation-probe`, whose shape it copies deliberately, but no boot
has confirmed Safari renders the page, that WebGL is available on the macos-13
rail, or what the dials are worth in counters. That is the next thing to do
with it, and until then no number may be quoted from it.
Co-Authored-By: Claude <noreply@anthropic.com>
194 lines
8.2 KiB
HTML
194 lines
8.2 KiB
HTML
<!doctype html>
|
|
<!--
|
|
A guest workload with a dial on each of this device's three big rails, served
|
|
from the HOST.
|
|
|
|
Why this exists, and why it is not just `anim.html` with more boxes.
|
|
`sustained-animation-probe` is a compositing load, and on a macos-13 rail it
|
|
has **saturated**: the guest produces ~26 800 draws a second and ~76 presented
|
|
frames whatever the device does underneath. Three consecutive device changes
|
|
measured against it — a 3.9 us/chain pipeline saving among them — moved
|
|
`draws_s` by less than 0.1 %, because the drain worker sits at duty 0.83 and
|
|
spends the time it saves waiting for guest work rather than doing more of it.
|
|
A probe a device cannot fall behind cannot rank a device change.
|
|
|
|
So this page is built to be *heavier per frame* rather than to ask for more
|
|
frames. The guest's frame rate is capped by its own display cadence and no
|
|
page can raise it; what a page can raise is what each of those frames costs.
|
|
|
|
Three axes, dialled independently by query string, because they land on three
|
|
different rails and a change that helps one can hurt another:
|
|
|
|
?layers=N N separately composited full-width bands. Each is a surface
|
|
the window server composites and this device writes back, so
|
|
this is the `store` / `render_writeback` rail — the one the
|
|
compute scatter serves.
|
|
|
|
?verts=K A WebGL canvas that re-uploads a K-vertex buffer every frame
|
|
and draws it. This is the **guest buffer gather** rail:
|
|
`buffer_guest_gather_bytes` and `buffer_guest_gather_regions`,
|
|
which on a compositing load is 5.8 GB/s over 427 000 transfer
|
|
regions a second and is the largest GPU cost left in the
|
|
device. A CSS load barely touches it; nothing else here does.
|
|
|
|
?tex=W A 2D canvas of W x W repainted every frame, so the guest
|
|
uploads fresh texture content — the sampled-image rail.
|
|
|
|
Defaults are the *light* end of each, so a caller always states the load it
|
|
asked for and a boot's URL is the record of what it measured.
|
|
|
|
Determinism, same rule as `anim.html` and for the same reason: every step is
|
|
per *frame* and nothing in the content reads the clock, so a slow boot and a
|
|
fast boot draw identical content per frame and differ only in how many frames
|
|
they get through. The on-screen counter is display only and is excluded from
|
|
the geometry.
|
|
-->
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>reims-vgpu gpu load</title>
|
|
<style>
|
|
html, body { margin: 0; padding: 0; background: #08080c; overflow: hidden; }
|
|
/* Promotion is forced, not hinted — `will-change` alone is advisory and the
|
|
compositor declines it often enough to split boots of one binary into two
|
|
clusters with a 24 % present-rate gap. `backface-visibility` here plus the
|
|
3D transform the tick applies take it out of the compositor's discretion.
|
|
This rule cannot carry a `transform`: the tick overwrites the inline one
|
|
every frame. See `sustained-animation-probe/anim.html`, which found this. */
|
|
.band {
|
|
position: absolute; left: 0; width: 100%;
|
|
will-change: transform;
|
|
backface-visibility: hidden;
|
|
}
|
|
.box { position: absolute; top: 6%; height: 88%; border-radius: 10px; }
|
|
#hud {
|
|
position: absolute; right: 10px; bottom: 6px; z-index: 20;
|
|
font: 14px -apple-system, Helvetica, sans-serif; color: #9f9;
|
|
}
|
|
#gl, #tex { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
|
|
#tex { opacity: 0.35; }
|
|
</style>
|
|
<body>
|
|
<canvas id="gl"></canvas>
|
|
<canvas id="tex"></canvas>
|
|
<div id="hud">warming up</div>
|
|
<script>
|
|
const P = new URLSearchParams(location.search);
|
|
const num = (k, d) => Math.max(0, parseInt(P.get(k) ?? d, 10) || 0);
|
|
const LAYERS = num('layers', 8);
|
|
const BOXES = num('boxes', 6);
|
|
const VERTS = num('verts', 0);
|
|
const TEX = num('tex', 0);
|
|
|
|
// ---------------------------------------------------------------- layers ----
|
|
// Each band is its own composited surface moving at its own rate, so no two
|
|
// frames repeat an earlier pair and the compositor cannot elide one.
|
|
const bands = [];
|
|
for (let b = 0; b < LAYERS; b++) {
|
|
const el = document.createElement('div');
|
|
el.className = 'band';
|
|
el.style.top = (b * (100 / Math.max(LAYERS, 1))) + '%';
|
|
el.style.height = (100 / Math.max(LAYERS, 1)) + '%';
|
|
for (let i = 0; i < BOXES; i++) {
|
|
const box = document.createElement('div');
|
|
box.className = 'box';
|
|
box.style.left = (i * 100 / Math.max(BOXES, 1)) + '%';
|
|
box.style.width = (80 / Math.max(BOXES, 1)) + '%';
|
|
box.style.background = `hsl(${(b * 37 + i * 11) % 360} 80% 55%)`;
|
|
el.appendChild(box);
|
|
}
|
|
document.body.appendChild(el);
|
|
bands.push(el);
|
|
}
|
|
|
|
// ------------------------------------------------------------------ webgl ---
|
|
// The point of this axis is the **buffer upload**, not the shading: a fresh
|
|
// `bufferData` every frame is what makes the guest hand this device a large
|
|
// buffer window it has to gather into device-local memory. The shader is
|
|
// deliberately trivial so the cost lands on the gather and not on fragments.
|
|
let gl = null, glBuf = null, glData = null, glCount = 0;
|
|
if (VERTS > 0) {
|
|
const c = document.getElementById('gl');
|
|
c.width = 1024; c.height = 768;
|
|
gl = c.getContext('webgl', { antialias: false, depth: false, alpha: false });
|
|
}
|
|
if (gl) {
|
|
const vs = gl.createShader(gl.VERTEX_SHADER);
|
|
gl.shaderSource(vs, 'attribute vec2 p;varying vec3 v;void main(){v=vec3(p*0.5+0.5,0.6);gl_Position=vec4(p,0.0,1.0);}');
|
|
gl.compileShader(vs);
|
|
const fs = gl.createShader(gl.FRAGMENT_SHADER);
|
|
gl.shaderSource(fs, 'precision mediump float;varying vec3 v;void main(){gl_FragColor=vec4(v,1.0);}');
|
|
gl.compileShader(fs);
|
|
const prog = gl.createProgram();
|
|
gl.attachShader(prog, vs); gl.attachShader(prog, fs); gl.linkProgram(prog);
|
|
gl.useProgram(prog);
|
|
glCount = VERTS - (VERTS % 3); // whole triangles only
|
|
glData = new Float32Array(glCount * 2);
|
|
glBuf = gl.createBuffer();
|
|
gl.bindBuffer(gl.ARRAY_BUFFER, glBuf);
|
|
const loc = gl.getAttribLocation(prog, 'p');
|
|
gl.enableVertexAttribArray(loc);
|
|
gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);
|
|
gl.viewport(0, 0, 1024, 768);
|
|
} else {
|
|
const c = document.getElementById('gl');
|
|
if (c) c.style.display = 'none';
|
|
}
|
|
|
|
// -------------------------------------------------------------- texture -----
|
|
let tctx = null;
|
|
if (TEX > 0) {
|
|
const c = document.getElementById('tex');
|
|
c.width = TEX; c.height = TEX;
|
|
tctx = c.getContext('2d');
|
|
} else {
|
|
const c = document.getElementById('tex');
|
|
if (c) c.style.display = 'none';
|
|
}
|
|
|
|
// ----------------------------------------------------------------- tick -----
|
|
let frame = 0;
|
|
function tick() {
|
|
frame++;
|
|
// Bands. `translate3d` keeps the layer promoted; the per-band rate is a
|
|
// different integer per band so the set never repeats.
|
|
for (let b = 0; b < bands.length; b++) {
|
|
const x = ((frame * (b + 3)) % 400) - 200;
|
|
bands[b].style.transform = `translate3d(${x}px,0,0)`;
|
|
}
|
|
|
|
if (gl) {
|
|
// Rewrite every vertex each frame — a buffer the guest must hand over
|
|
// again, which is the whole point of this axis. Integer-stepped, so the
|
|
// content of frame N is the same on every boot.
|
|
for (let i = 0; i < glCount; i++) {
|
|
const t = (i * 7 + frame * 3) % 2048;
|
|
glData[i * 2] = (t / 1024) - 1;
|
|
glData[i * 2 + 1] = (((i * 13 + frame * 5) % 2048) / 1024) - 1;
|
|
}
|
|
gl.bufferData(gl.ARRAY_BUFFER, glData, gl.DYNAMIC_DRAW);
|
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
gl.drawArrays(gl.TRIANGLES, 0, glCount);
|
|
}
|
|
|
|
if (tctx) {
|
|
// A full repaint, so the whole surface is fresh content rather than a
|
|
// damaged strip the guest could upload partially.
|
|
const s = TEX;
|
|
tctx.fillStyle = `hsl(${frame % 360} 60% 30%)`;
|
|
tctx.fillRect(0, 0, s, s);
|
|
for (let i = 0; i < 24; i++) {
|
|
tctx.fillStyle = `hsl(${(frame * 3 + i * 15) % 360} 80% 55%)`;
|
|
const q = ((frame * (i + 1)) % s);
|
|
tctx.fillRect(q, (i * s / 24) | 0, s / 6, s / 24);
|
|
}
|
|
}
|
|
|
|
if ((frame & 63) === 0) {
|
|
document.getElementById('hud').textContent =
|
|
`f=${frame} layers=${LAYERS}x${BOXES} verts=${glCount} tex=${TEX}`;
|
|
}
|
|
requestAnimationFrame(tick);
|
|
}
|
|
requestAnimationFrame(tick);
|
|
</script>
|