🐛 The vblank census printed a rate of zero whenever both its reporting arms were live, which is exactly the boot worth reading
Component: `crates/reims-vgpu` — `runtime::drain::census::VblCensus`, plus the measured result forcf77ab7ewritten into `signal_display_refresh_classes`. # The census defect Two arms report — `delivered` and `not_enabled` — and they shared one `last_report_ms`/`last_report_n` pair. Whenever both were live the shared count made every window wrong: an arm reaching its own `n = 1024` subtracted the other arm's 1024 and printed `window_hz=0.0`, and the next report measured its count against a timestamp the other arm had moved. It fails on precisely the boots that matter. A guest that arms VBL one shot at a time is the guest that keeps both arms live, so `window_hz` — the only per-window reading of the rate the compositor is paced at — read as broken on every driven macos-13 boot in the captures. The delivered rate for the measurement below had to be recovered by differencing consecutive `delivered=` fields across lines. The window is now per arm. `since_n` was deleted rather than repaired: an arm reports on every multiple of `VBL_REPORT_EVERY` of its own count and then stores that count, so the gap is always exactly `VBL_REPORT_EVERY` and computing it was the only thing that could be wrong. Deriving beats duplicating and comparing. # Whatcf77ab7ewas actually worth Six interleaved driven macos-13 boots, binary A/B against the pre-fix pin, quiesced host, sustained-animation probe, no guest panic on any boot and a correct desktop on both arms: presented frames/s delivered Hz (final window) old A1 100.0 92.8 old A3 101.5 107.8 new B1 99.0 110.0 new B2 111.0 112.5 old A2 60.0 43.8 new B3 59.0 67.5 Delivery rises on the new ordering in both populations, and in the fast one the arms are nearly disjoint against a 118 Hz grid ceiling — the mechanism showing up where it should, since a guest re-arming every 8.33 ms races an 8.47 ms grid and its turnaround lands past the grid point often. **It does not explain the boot-to-boot regime split, and cf77ab7e's message claimed it did.** The guest latches either a ~60 Hz or a ~120 Hz display link early and holds it, and the split came out 2 fast to 1 slow on *both* arms, unchanged. The slow arm is not a delivery shortfall this ordering repairs: B3 received 54 % more VBL than A2 and presented the same 59 frames a second, so a guest in that state is not asking for more. Whatever picks the latch is upstream and is still open. The doc now says so where the next reader will meet it. `us/draw` is not usable as the null control it was meant to be here — it reads 14.08 mean on the new binary against 15.25 on the old, across a change that touches no draw, gather or store rail. Host GPU clocks cannot be pinned on this machine (`gpupin.sh` needs root), the part idles at 180 MHz against a 3090 MHz cap, and that ramp is the most likely carrier. Treated as noise, not as a win. Tests: `the_two_reporting_vbl_arms_do_not_share_one_window` drives both arms over one timeline and asserts each reports 125 Hz over its own window. Verified to fail against a hand-restored shared pair, reproducing the real log's `window_hz=0.0` verbatim; the probe was applied and removed by editing, never by git. Two earlier drafts of this test passed against the probe and were rewritten rather than kept — one never drove the second arm to its own 1024, the other conflated the shared timestamp with the shared count. Verified: 1898 lib tests plus every integration target green serially; clippy `-D warnings` clean on all three arms. Not verified: the census fix has not been through a live boot — its effect is a log field, and the boots above were taken with the old, broken `window_hz`. arm64/Metal untested on this Linux host as ever. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
cf77ab7e9e
commit
1f36dddce4
3 files changed
+101
-13
No files matched your search
@@ -54,11 +54,30 @@ const VBL_REPORT_EVERY: u64 = 1024;
|
||||
/// cannot be added without the array growing with it.
|
||||
const VBL_ARMS: usize = VBL_NOT_ENABLED + 1;
|
||||
|
||||
/// # `window_hz` is per reporting arm, and used not to be
|
||||
///
|
||||
/// Two arms report — `delivered` and `not_enabled` — and they shared one
|
||||
/// `last_report_ms`/`last_report_n` pair. Whenever both were live in the same
|
||||
/// boot the shared counter made every window wrong: an arm reporting at its own
|
||||
/// `n = 1024` subtracted the *other* arm's 1024 and printed `window_hz=0.0`, and
|
||||
/// the next report measured its count against a timestamp the other arm had
|
||||
/// moved. A boot alternating the two produced a column of zeroes and a column of
|
||||
/// rates over windows that never happened.
|
||||
///
|
||||
/// That is not a cosmetic log defect. `window_hz` is the only per-window reading
|
||||
/// of the rate the guest's compositor is paced at, and it read as broken exactly
|
||||
/// on the boots worth reading — a guest that arms VBL one shot at a time is the
|
||||
/// guest that makes both arms report. The delivered rate had to be recovered by
|
||||
/// differencing consecutive `delivered=` fields across lines instead.
|
||||
///
|
||||
/// So the window is per arm. `since_n` went with the fix rather than being
|
||||
/// repaired: an arm reports on every multiple of [`VBL_REPORT_EVERY`] of its own
|
||||
/// count and then stores that count, so the gap is always exactly
|
||||
/// `VBL_REPORT_EVERY` and computing it was the thing that could be wrong.
|
||||
#[derive(Default)]
|
||||
pub(crate) struct VblCensus {
|
||||
arms: [std::sync::atomic::AtomicU64; VBL_ARMS],
|
||||
last_report_ms: std::sync::atomic::AtomicU64,
|
||||
last_report_n: std::sync::atomic::AtomicU64,
|
||||
last_report_ms: [std::sync::atomic::AtomicU64; VBL_ARMS],
|
||||
}
|
||||
|
||||
impl VblCensus {
|
||||
@@ -88,13 +107,14 @@ impl VblCensus {
|
||||
if !reports || !n.is_multiple_of(VBL_REPORT_EVERY) {
|
||||
return None;
|
||||
}
|
||||
let since_ms = now_ms.saturating_sub(self.last_report_ms.swap(now_ms, Relaxed));
|
||||
let since_n = n.saturating_sub(self.last_report_n.swap(n, Relaxed));
|
||||
let since_ms = now_ms.saturating_sub(self.last_report_ms[arm].swap(now_ms, Relaxed));
|
||||
// Window rate, not a lifetime average: the lifetime figure carries the
|
||||
// pre-online stretch forever and would read low long after the display
|
||||
// came up.
|
||||
// came up. The count in the window is `VBL_REPORT_EVERY` by construction
|
||||
// — this line exists because this arm's own count just reached a
|
||||
// multiple of it — so the only variable is how long that took.
|
||||
let hz = if since_ms > 0 {
|
||||
(since_n * 1000) as f64 / since_ms as f64
|
||||
(VBL_REPORT_EVERY * 1000) as f64 / since_ms as f64
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
@@ -5201,17 +5201,38 @@ pub(crate) fn display_event_enabled<H: HostMemory>(host: &H, gpa: u64, event_mas
|
||||
/// waited a further full interval, so its delivery rate aliased to every other
|
||||
/// grid point — 60 Hz out of an advertised 120.
|
||||
///
|
||||
/// That is the boot-to-boot regime split, measured over six driven macos-13
|
||||
/// boots. Claims land at 117.6-118.4 Hz in every one of them, so the limiter and
|
||||
/// its phase lock were never the problem; what varied was how much of that grid
|
||||
/// reached the guest:
|
||||
/// # What it is worth, and the thing it does not explain
|
||||
///
|
||||
/// Six interleaved driven macos-13 boots, binary A/B (the ordering has no env
|
||||
/// switch), quiesced host. Delivered rate is taken from the gap between
|
||||
/// consecutive `arm=delivered` census lines, which are exactly 1024 deliveries
|
||||
/// apart — the `delivered=` field on the last line is quantised to that cadence
|
||||
/// and `window_hz` is unusable here, see [`census::VblCensus`].
|
||||
///
|
||||
/// ```text
|
||||
/// delivered/claimed presented frames/s draws/s
|
||||
/// 61-67 % 109 ~29 700
|
||||
/// 28-39 % 59 ~15 000
|
||||
/// presented frames/s delivered Hz (final window)
|
||||
/// old A1 100.0 92.8
|
||||
/// old A3 101.5 107.8
|
||||
/// new B1 99.0 110.0
|
||||
/// new B2 111.0 112.5
|
||||
/// old A2 60.0 43.8
|
||||
/// new B3 59.0 67.5
|
||||
/// ```
|
||||
///
|
||||
/// Delivery rises on the new ordering in both populations, and in the fast one
|
||||
/// the arms are nearly disjoint against a 118 Hz grid ceiling. That is the
|
||||
/// mechanism showing up where it should: a guest re-arming every 8.33 ms races
|
||||
/// an 8.47 ms grid, so its turnaround lands past the grid point often, and it is
|
||||
/// precisely those ticks the old ordering spent.
|
||||
///
|
||||
/// **It does not explain the boot-to-boot regime split, and the first version of
|
||||
/// this doc claimed it did.** The guest latches either a ~60 Hz or a ~120 Hz
|
||||
/// display link early in the boot and holds it, and the split came out 2 fast to
|
||||
/// 1 slow on *both* arms — unchanged. The slow arm is not a delivery shortfall
|
||||
/// this ordering can repair: B3 received 54 % more VBL than A2 and presented the
|
||||
/// same 59 frames a second, so a guest in that state is not asking for more.
|
||||
/// Whatever picks the latch is upstream of everything here and is still open.
|
||||
///
|
||||
/// Reading the mask first cannot deliver faster than the advertised rate —
|
||||
/// [`claim_display_vbl`] still gates every delivery on a full interval having
|
||||
/// elapsed since the last one. It only stops the device spending intervals on
|
||||
|
||||
@@ -3227,6 +3227,53 @@ fn a_continuously_armed_guest_is_still_capped_at_the_advertised_rate() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Both reporting arms measure their own window, and neither resets the other's.
|
||||
///
|
||||
/// A guest that arms VBL one shot at a time keeps `delivered` and `not_enabled`
|
||||
/// both live, so both report — and they shared one `last_report` pair, which made
|
||||
/// every window wrong precisely on the boots worth reading. The symptom in a real
|
||||
/// log is `window_hz=0.0`: an arm reaching its own 1024 subtracted the other
|
||||
/// arm's 1024 and got a zero-length count.
|
||||
#[test]
|
||||
fn the_two_reporting_vbl_arms_do_not_share_one_window() {
|
||||
use crate::runtime::drain::{VblCensus, VBL_DELIVERED, VBL_NOT_ENABLED};
|
||||
let c = VblCensus::default();
|
||||
|
||||
// A one-shot guest takes both arms on the same timeline — a tick either
|
||||
// found it armed or did not — so both cross 1024 over one 8 ms grid and both
|
||||
// report at the same instant. Each is 1024 events over its own 8192 ms, so
|
||||
// both lines must read 125 Hz; with one shared pair whichever reports second
|
||||
// subtracts the first's count and prints the `window_hz=0.0` that a real
|
||||
// driven boot is full of.
|
||||
let mut served = None;
|
||||
let mut declined = None;
|
||||
for i in 1..=1024u64 {
|
||||
if let Some(l) = c.note(VBL_DELIVERED, i * 8) {
|
||||
served = Some(l);
|
||||
}
|
||||
if let Some(l) = c.note(VBL_NOT_ENABLED, i * 8) {
|
||||
declined = Some(l);
|
||||
}
|
||||
}
|
||||
for (line, arm) in [
|
||||
(served.expect("delivered reports at its own 1024"), "delivered"),
|
||||
(
|
||||
declined.expect("not_enabled reports at its own 1024"),
|
||||
"not_enabled",
|
||||
),
|
||||
] {
|
||||
assert!(line.contains(&format!("arm={arm}")), "{line}");
|
||||
assert!(
|
||||
!line.contains("window_hz=0.0"),
|
||||
"{arm} had the other arm's count subtracted from it: {line}"
|
||||
);
|
||||
assert!(
|
||||
line.contains("window_hz=125.0"),
|
||||
"{arm} saw 1024 events over 8192 ms, which is 125 Hz: {line}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// After online is acked, a stale ONLINE bit (bit2) left in pending is
|
||||
/// suppressed by the present/VBL signalers instead of re-delivered — else the
|
||||
/// guest re-runs process_online → connectionChange → boot-progress overlay.
|
||||
|
||||
Reference in new issue
Block a user