Files
reims-vgpu/scripts/browser-probe
Anees IqbalandClaude 1acac3d31d 🐛 The device advertised 120 Hz and delivered VBL at 125
`crates/reims-vgpu` display VBL limiter (`runtime/drain/mod.rs`,
`model/regs.rs`, `observe/sink.rs`, `lib.rs`) plus an instrument caveat in
`scripts/browser-probe/gpu-probe.html`. Affects every pathway; measured on
x86 macOS / Linux Vulkan.

Two constants reach the guest by two routes: `DISPLAY_REFRESH_HZ = 120` goes
into the mode timing table it reads, and the VBL limiter paces the interrupt it
is actually woken by. The limiter was a hardcoded `DISPLAY_VBL_MIN_INTERVAL_MS
= 8`, which is 125 Hz. The guest paces to the interrupt, not the table, so it
latched 125 — a driven Safari measured its own frame rate at exactly 125 Hz
while our timing table claimed 120. Two comments in the same file disagreed
about which was intended, one calling 8 ms "approximately 120 Hz" and the other
"a healthy 125 Hz".

120 Hz is 8333 us and is **not expressible on an integer-millisecond grid**, so
the units were part of the defect rather than incidental to it: an 8 ms period
also carries +/-12.5% quantisation by construction. The limiter now works in
microseconds via a new `observe::elapsed_us()` on the same process-monotonic
clock, and `DISPLAY_VBL_MIN_INTERVAL_US` is **derived** from
`DISPLAY_REFRESH_HZ` rather than restated, so the two cannot drift apart again.
`t=` stamps stay in milliseconds so line-class censuses keep working.

Live verification, boot before and after: `display_vbl` read `window_hz=125.0
grid_hz=125.0` and now reads `window_hz=120.0 grid_hz=120.0` against 8192
delivered VBLs.

Tests: one added, 1212 -> 1213 passing, 0 failed (vulkan arm,
`--test-threads=1`). It asserts the *identity* — delivered cadence equals
advertised refresh — rather than either value, so it stays true if the
advertised rate changes and cannot itself go stale; a second assertion pins
that a whole-millisecond interval could not express the answer. Mutation
verified: restoring the 8 ms grid fails it with "advertising 120 Hz but
delivering 125.0 Hz (interval 8000 us)". Clippy clean with `-D warnings` on the
vulkan arm; `cargo check --target aarch64-apple-darwin --features backend-metal`
unchanged at 19 warnings, 0 errors.

Also documents a limit of our own probe that this exposed: browsers clamp
`performance.now()` (Safari to ~1 ms), so a true 8.333 ms interval arrives as
8/8/9 and the median-derived `refresh_hz` reports 125 for a display genuinely
at 120. The probe cannot tell those two apart and now says so; the host-side
`display_vbl` census is the instrument for that question.

Not verified: **no performance claim.** Guest-side long-frame counts across
runs were 15/24/28/8/10/42 with fps 118-119 and one run at 59.5, so run-to-run
variance dominates any effect this could have and the post-change run's higher
count is not evidence either way. The basis for this change is contract
consistency — advertise what we deliver — not measured frame pacing.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-02 00:14:34 +03:00
..