Files
reims-vgpu/scripts
Anees Iqbal c4309bbeec 🐛 runtime-dead could not name its own QEMU, and called a complete profile missing
Component: `scripts/runtime-dead` (x86 / Vulkan / host-window instrument). No
Rust or C changed; the crate and both shims are untouched.

Three consecutive runs refused to write a report at the guard `the boot's own
profile is missing or empty`. The guard was wrong every time. The last of them
left `reims-996479.profraw` on disk — 4 310 352 bytes, `Maximum function count:
225055584`, `Total count: 4331733340` — a complete measurement of the boot it
had just declared unmeasured. The README's whole "known broken" section, which
had the search space narrowed to "the writer ran and did not finish, on the one
process with a live Vulkan device", was chasing a defect that does not exist.

The cause is the pid. The script found QEMU with

    ps -eo pid,args | grep '[q]emu-system-x86_64' | awk '{print $1}' | head -1

which matches any process whose argv holds that string, not any process that is
it. Three things in this script's own critical path qualify and all three land
inside the loop's two-second polling window: the boot script re-runs qemu-build,
whose ninja link step spawns `cc ... -o .../qemu-system-x86_64 ...` for a 119 MB
binary; qemu-build then makes four short-lived `-device help` probes; and any
other process mentioning the name matches too — a shell running a command
containing it is what finally exposed this. `head -1` returns one of those, none
of which writes a profile under the pid the script then looks for.

What changed:

- `qemu_pids()` matches `/proc/<pid>/exe` rather than a command line. An argv
  match cannot tell a compiler writing that name from a process running it. The
  stale-VM guard had the identical flaw and now shares the helper; it also loses
  the `set -o pipefail` edge where grep-found-nothing was the pipeline's status.
- The measurement pid is re-sampled once the guest answers SSH, when the build
  is finished and the probes are gone, and the run refuses unless exactly one
  QEMU is alive. The early loop survives only to notice a boot that never
  started and to have something to kill on the refusal paths.
- The guard tests counts, not bytes. A probe's dump is 4 310 352 bytes of
  records that are all misses — exactly as large as the measurement — and passed
  `-s` on every failed run. `llvm-profdata show`'s `Maximum function count:`
  reads 0 for every probe and 225 055 584 for a driven boot.

Verified by running it: `--seconds 25 --app Safari` on `006d2216`, exit 0,
`runtime-dead: measuring QEMU pid 1087125` (the re-sample found exactly one),
drive verdict passed, 8 raws merged, report written.

    crates/reims-vgpu/src   3450 functions   1413 never ran   (59.0% ran)
    regions 53.65%   functions 61.13%   lines 53.33%

All six files the first baseline adjudicated as 0.00% reappear at 0.00%. The
instrument agreeing with a conclusion reached the expensive way is why it is
worth having.

The reading also answers the plan's §5, which reserved three modules for
measurement before deciding the in-place import had stranded them. It refuses
all three: `gva_view.rs` 80.35% regions / 26 of 28 functions,
`surface_cache/mod.rs` 72.13% / 49 of 62, `m2v_cache.rs` 62.97% / 40 of 65.
None is a deletion.

Not verified: the arm64 / Metal-direct pathway, which this instrument does not
cover at all (`backend-metal` is cfg'd out of the build). The §5 claim that a
UMA host's armed-window count goes to zero is still unmeasured — this host is a
discrete RTX 5080, where `storage_flush/`'s 21-98% coverage is the dGPU rail
working rather than evidence either way. No timing in this run's drive log is
usable: it was taken minutes after a full instrumented rebuild and presents at a
tenth of the first baseline's rate. Coverage is a count and survives that.
2026-08-07 17:44:24 +03:00
..