From 246ab4403a5d91f864bd07ccd8214d7c8e5c19df Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sun, 8 Nov 2026 06:50:31 -0800 Subject: [PATCH] :memo: Record that a present path can miss a refresh at a low frame rate [ci skip] The answer of a present waited for the window's draw of it, and on an RTX 5080 Laptop GPU every frame of a 30-frames-a-second probe came a refresh late while its uncapped run did not: the GPU clocks down between frames, and the composite and the draw each took about ten times their time under load. The lesson says how to spot the next one: measure at a capped low rate too, and read the per-present timing lines for the step that grows as the rate falls. --- docs/lessons.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/lessons.md b/docs/lessons.md index e5709a83b..398932272 100644 --- a/docs/lessons.md +++ b/docs/lessons.md @@ -54,6 +54,7 @@ one. A new trap found the same way goes here. - A snapshot of the guest's page tables shows the processes that happen to be on the CPUs. The probe that read a macOS guest's PTEs over BAR 2 through QMP walks each vCPU's current CR3 at one instant, and it found every user page there uncached (the guest PAT's UC-) in every arm, the same 1010 pages each time, while the bench encoding into write-combined spans ran: the bench was not on a CPU at that instant, and the pages were another process's. A reading of xnu's fault path that missed its block-map path for physically contiguous objects (`vm_fault`'s `pmap_map_block_addr`, which maps in the object's own cache mode) seemed to agree, and the write-combined spans were reverted and restored the same day: with them draws.10k encoded in 1.05-1.3 ms on the Radeon 780M host, without them in 7.7 ms (**measured**, 2026-11-07). How to spot the next one: before a page-table snapshot rules out a mapping, check that the snapshot holds the process that makes it (its CR3, or the same pages in it in the arm that should differ), and trust the A/B of the figure the mapping is for over a reading of the kernel. - A guest-side command under `timeout` never runs on macOS, and the harness reads the miss as a timeout. macOS has no `timeout(1)` (it is GNU coreutils'), so a copy of a boot harness that ran `timeout 30 kmutil showloaded` in the guest over SSH got the shell's "command not found" (status 127) and reported "kexts: FAIL: kmutil timed out" on every release from 11.7.10 to 26.7.2. It looked like the harness it was copied from, whose kext check had failed on a real wait (the guest's first `sudo` held kmutil's start for about 155 s, measured with a polled background job), so it was waived as that known fault for a day of boots; run as `perl -e 'alarm 30; exec @ARGV' kmutil showloaded`, it listed the loaded kexts at once (**measured**, 2026-11-08, 11.7.11 on llvmpipe). Bound a command in a macOS guest with `perl -e 'alarm N; exec @ARGV'`, or on the host side of the SSH. How to spot the next one: a check that fails the same way on every guest release, whose command goes through `timeout` on the guest's side; run the command bare once and read its status. - A VM made from an existing disk is a new Mac to its macOS when its OpenCore image presents a new UUID, and that new Mac does not shut down. `reims-ctl create --disk` with no image made one presenting a Mac of its own, and every `reims-ctl stop` of a macOS 26.7.2 disk waited out its 180 s and powered the VM off, since Setup Assistant (`-MiniBuddyYes`) was up from about 10 s after boot and it ignores Control-Option-Command-Power and the power button. Our kexts kept answering throughout, so it looked like a guest hang. The disk's user preferences held `com.apple.loginwindow` `MiniBuddyLaunch` = 1 for any host and 0 in the ByHost file of the Mac it ran on. ByHost files are keyed by `IOPlatformUUID`, which is OpenCore's `SystemUUID`, and the new UUID had none, so loginwindow took the any-host 1. Presenting the disk's own Mac, read from the image beside it, the stop shut the guest down in 9 s (**measured**, 2026-11-08, Radeon 780M host; `create.rs`, `disks_mac`). A copy of the disk of a VM reims-ctl has still gets a Mac of its own, since it can run beside that VM and two VMs presenting one serial number, MLB and ROM would be one Mac to Apple's services. What remains: a stop still powers off at its timeout whenever Setup Assistant is up, as on a new install's first boot until it is finished, on a disk with no image beside it, on such a copy, and with MiniBuddy's panes after some updates (`scripts/internal/guest-minibuddy-off.sh`). Nothing the host can send without the guest's password ends it. The keys and the ACPI power button (QMP's `system_powerdown`) both went unanswered for the whole 180 s. QMP's other power requests (`system_reset`, `quit`) are a power-off, and a macOS guest runs no guest agent. Only `sudo shutdown -h now` inside the guest shut it down, in 6 s (**measured** 2026-11-07). How to spot the next one: a guest that ignores a shutdown request; read `ioreg -rd1 -c IOPlatformExpertDevice`'s UUID against the UUIDs in `~/Library/Preferences/ByHost`, and look for `Setup Assistant -MiniBuddyYes` in `ps`. +- Host GPU work on a present's path that fits a refresh under load can miss it at a low frame rate. The present's answer waited for the window's draw of it, and on an RTX 5080 Laptop GPU the guest's 30-frames-a-second probe saw every frame a refresh late (2.7 refreshes from commit to presentedTime at 120 Hz, against 1.6 at 60 Hz on a 780M), while in its uncapped run each present was answered at the first refresh after its show: between frames the GPU clocks down, and WindowServer's composite took 4.4 ms of its time and the window's draw 4.9 ms, against 0.5 ms each at 120 frames a second (**measured** 2026-11-08, macOS 26.6.1, 3840 x 2400). The answer now comes at the refresh after the show (`graphics::present`). How to spot the next one: measure a present path's latency at a capped low rate as well as uncapped, and look at the host's per-present timing lines (`reims_vgpu::graphics::present_timing` at debug) for the step whose time grows as the rate falls. ## Tools and worktrees