d3d12 gpu: VirtualQuery walks the write watch stood behind while walking (D3D12-HWRT-REGION-WALK-STALLS) #3113

Open
rockcabbage wants to merge 8 commits from upstream-pr/3113 into main
rockcabbage commented 2026-12-02 11:26:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by rockcabbage on 2026-12-02T11:26:03Z.


Claimed in the coordination issue as: D3D12-HWRT-REGION-WALK-STALLS

What

Two callers of VirtualQuery held up frames while walking with hardware ray tracing on. VirtualQuery answers with
the length of the run of pages in the same state and walks the page tables to the run's end to find it (what
texture::by_query already says of the textures' pass); in the title's pools that is 21-36 ms a question, and the
submitting thread's GetWriteWatch stands behind the walk for as long.

  • hwrt.rs: readable_len / title_readable, asked for each geometry of a batch of bottom-level builds, walked
    twice in a row (47-48 ms for the batch). They now ask page by page through texture::readable_bytes
    (QueryWorkingSetEx, 256 pages a call). LEONIDA_HW_RT_REGION_QUERY=1 asks VirtualQuery as before, and
    LEONIDA_AB can switch it. texture::readable now leaves a working-set page that is PAGE_NOACCESS or a guard
    to the read, so the page-wise answer refuses what the walk refused.
  • copystat.rs: the frame meter's five-second lines asked VirtualQuery only for the kind of memory of the ten
    ranges most copied from (one walk of 24-28 ms each time). They ask about the one page now (texture::shared); the
    line says shareable memory / private or untouched memory where it gave the type's number.

Measured

RTX 4090, i9-13900K, Windows 11, Series X profile, 2560x1440, -HardwareRT -NoFrameGen, diag build. A scripted walk
with camera turns of 110 s (LEONIDA_KEYS), a timeline of 12 frames every 3 s (LEONIDA_TIMELINE), the switch by
turns of 5 s inside the run (LEONIDA_AB=5,LEONIDA_HW_RT_REGION_QUERY), two runs.

timelines holding a walk of 20 ms or more from hwrt.rs
VirtualQuery (switch on) 38 11
page by page (default now) 33 0

One timeline straddled a turn of the switch and is left out. In the timelines that hold a walk the submitting
thread's longest GetWriteWatch is 22-47 ms (0.2-2 ms in the others) and the frames are 50-65 ms among frames of
40-50.

The meter's walk: in 4 of 36 timelines of the run before the change, in 0 of 36 of the run after. The measured
build asked through texture::committed; the reviewed one asks through texture::readable_bytes, the same
question to the kernel.

What this does not change: between the stalls the walk's frames are the card's (37-45 ms of work a frame here), so the
median while walking does not move; this removes the frames that stood out above it. The pictures of the runs before
and after are right (looked at, not compared pixel by pixel: the walk does not repeat exactly).

Tests

  • hwrt::tests::title_memory_is_asked_about_page_by_page: committed, read-only, closed and uncommitted pages, a
    range across them, a wrapping length, and that VirtualQuery was not asked. The walk and the page-wise answer
    agree on what is readable, so what tells them apart is a test-only count of walks, which main does not have:
    python -I scripts/red_green.py says "red does not build" for it, not a red run. With the switch set the count
    rises and the test fails.
  • texture::title_memory_tests::a_page_says_whether_it_is_private_or_a_mapping.
  • cargo test -p leonida-gpu --features diagnostics --lib --locked: 774 passed.
  • python -I scripts/check_no_game_data.py, python -I tests/test_d3d12_switches.py.

AI assistance

Written with Claude Code (Claude Fable 5.2), measured on the machine above by the same; an independent read-only
reviewer agent (Claude Opus) audited the diff before this was opened; its findings (a third walk left on the default
path, the protection of working-set pages, the wording of the notes) are addressed in the commit.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5605444776 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113). Originally posted by [rockcabbage](https://github.com/rockcabbage) on 2026-12-02T11:26:03Z. --- Claimed in the coordination issue as: `D3D12-HWRT-REGION-WALK-STALLS` ## What Two callers of `VirtualQuery` held up frames while walking with hardware ray tracing on. `VirtualQuery` answers with the length of the run of pages in the same state and walks the page tables to the run's end to find it (what `texture::by_query` already says of the textures' pass); in the title's pools that is 21-36 ms a question, and the submitting thread's `GetWriteWatch` stands behind the walk for as long. - `hwrt.rs`: `readable_len` / `title_readable`, asked for each geometry of a batch of bottom-level builds, walked twice in a row (47-48 ms for the batch). They now ask page by page through `texture::readable_bytes` (`QueryWorkingSetEx`, 256 pages a call). `LEONIDA_HW_RT_REGION_QUERY=1` asks `VirtualQuery` as before, and `LEONIDA_AB` can switch it. `texture::readable` now leaves a working-set page that is `PAGE_NOACCESS` or a guard to the read, so the page-wise answer refuses what the walk refused. - `copystat.rs`: the frame meter's five-second lines asked `VirtualQuery` only for the kind of memory of the ten ranges most copied from (one walk of 24-28 ms each time). They ask about the one page now (`texture::shared`); the line says `shareable memory` / `private or untouched memory` where it gave the type's number. ## Measured RTX 4090, i9-13900K, Windows 11, Series X profile, 2560x1440, `-HardwareRT -NoFrameGen`, diag build. A scripted walk with camera turns of 110 s (`LEONIDA_KEYS`), a timeline of 12 frames every 3 s (`LEONIDA_TIMELINE`), the switch by turns of 5 s inside the run (`LEONIDA_AB=5,LEONIDA_HW_RT_REGION_QUERY`), two runs. | | timelines | holding a walk of 20 ms or more from `hwrt.rs` | |---|---|---| | `VirtualQuery` (switch on) | 38 | 11 | | page by page (default now) | 33 | 0 | One timeline straddled a turn of the switch and is left out. In the timelines that hold a walk the submitting thread's longest `GetWriteWatch` is 22-47 ms (0.2-2 ms in the others) and the frames are 50-65 ms among frames of 40-50. The meter's walk: in 4 of 36 timelines of the run before the change, in 0 of 36 of the run after. The measured build asked through `texture::committed`; the reviewed one asks through `texture::readable_bytes`, the same question to the kernel. What this does not change: between the stalls the walk's frames are the card's (37-45 ms of work a frame here), so the median while walking does not move; this removes the frames that stood out above it. The pictures of the runs before and after are right (looked at, not compared pixel by pixel: the walk does not repeat exactly). ## Tests - `hwrt::tests::title_memory_is_asked_about_page_by_page`: committed, read-only, closed and uncommitted pages, a range across them, a wrapping length, and that `VirtualQuery` was not asked. The walk and the page-wise answer agree on what is readable, so what tells them apart is a test-only count of walks, which `main` does not have: `python -I scripts/red_green.py` says "red does not build" for it, not a red run. With the switch set the count rises and the test fails. - `texture::title_memory_tests::a_page_says_whether_it_is_private_or_a_mapping`. - `cargo test -p leonida-gpu --features diagnostics --lib --locked`: 774 passed. - `python -I scripts/check_no_game_data.py`, `python -I tests/test_d3d12_switches.py`. ## AI assistance Written with Claude Code (Claude Fable 5.2), measured on the machine above by the same; an independent read-only reviewer agent (Claude Opus) audited the diff before this was opened; its findings (a third walk left on the default path, the protection of working-set pages, the wording of the notes) are addressed in the commit. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Kal0s-design commented 2026-12-02 12:01:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T12:01:34Z.


Ran natively on Windows 11 with head 5aa56d74d merged into current main, no conflicts. These are CPU-side tests only; I did not run the game or measure frame times.

Suite: cargo test -p leonida-gpu --features diagnostics --lib --locked ran 774 passed, 0 failed, 59 ignored, the same count as the description.

Guard pages. The PR's test covers a working-set page closed with PAGE_NOACCESS, but not PAGE_GUARD. A guard page is one-shot: a read that touches it would clear the guard. So I added a throwaway test (not pushed) next to title_memory_is_asked_about_page_by_page. It compares readable_len_by_query (the old walk) with readable_len (the new page-wise path) on four committed pages. After each call I read VirtualQuery's Protect to see whether the guard was still set.

Page walk page-wise guard before → after
read-write, touched 4096 4096 none
read-write + PAGE_GUARD, never touched (not in the working set) 0 0 set → set
touched, then read-write + PAGE_GUARD (in the working set) 0 0 set → set
touched, then PAGE_EXECUTE_READ 4096 4096 none

From the start of the four pages, both answer 4096 and stop at the guard.

  • The new (flags >> 4) & 0x101 mask refuses the guard page that is in the working set.
  • The page that is not in the working set falls through to read_into, and its guard is still set afterwards. So ReadProcessMemory does not consume it here.
  • The two paths agree on every case.

REGION_QUERIES is global to the test binary. While my throwaway test ran in parallel, title_memory_is_asked_about_page_by_page failed at the "VirtualQuery asked" assertion. My test called readable_len_by_query at the same time, so the count moved. Run alone, it passes. Nothing else in the crate calls the walk today, so this is fine as is. Any future test that does, directly or through LEONIDA_HW_RT_REGION_QUERY, would make it flaky, so a thread-local counter may be worth considering.

Overlap with #3046: that is mine, and it also touches texture.rs. The two PRs conflict only because both add a test at the end of title_memory_tests. Whichever merges second keeps both tests. I'll handle it on #3046 if this one goes in first.

GPUs tested: n/a (CPU-side tests).

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7344735558 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7344735558). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T12:01:34Z. --- Ran natively on Windows 11 with head `5aa56d74d` merged into current `main`, no conflicts. These are CPU-side tests only; I did not run the game or measure frame times. **Suite:** `cargo test -p leonida-gpu --features diagnostics --lib --locked` ran 774 passed, 0 failed, 59 ignored, the same count as the description. **Guard pages.** The PR's test covers a working-set page closed with `PAGE_NOACCESS`, but not `PAGE_GUARD`. A guard page is one-shot: a read that touches it would clear the guard. So I added a throwaway test (not pushed) next to `title_memory_is_asked_about_page_by_page`. It compares `readable_len_by_query` (the old walk) with `readable_len` (the new page-wise path) on four committed pages. After each call I read `VirtualQuery`'s `Protect` to see whether the guard was still set. | Page | walk | page-wise | guard before → after | |---|---|---|---| | read-write, touched | 4096 | 4096 | none | | read-write + `PAGE_GUARD`, never touched (not in the working set) | 0 | 0 | set → set | | touched, then read-write + `PAGE_GUARD` (in the working set) | 0 | 0 | set → set | | touched, then `PAGE_EXECUTE_READ` | 4096 | 4096 | none | From the start of the four pages, both answer 4096 and stop at the guard. - The new `(flags >> 4) & 0x101` mask refuses the guard page that is in the working set. - The page that is not in the working set falls through to `read_into`, and its guard is still set afterwards. So `ReadProcessMemory` does not consume it here. - The two paths agree on every case. **`REGION_QUERIES` is global to the test binary.** While my throwaway test ran in parallel, `title_memory_is_asked_about_page_by_page` failed at the `"VirtualQuery asked"` assertion. My test called `readable_len_by_query` at the same time, so the count moved. Run alone, it passes. Nothing else in the crate calls the walk today, so this is fine as is. Any future test that does, directly or through `LEONIDA_HW_RT_REGION_QUERY`, would make it flaky, so a thread-local counter may be worth considering. **Overlap with #3046:** that is mine, and it also touches `texture.rs`. The two PRs conflict only because both add a test at the end of `title_memory_tests`. Whichever merges second keeps both tests. I'll handle it on #3046 if this one goes in first. GPUs tested: n/a (CPU-side tests). AI-assisted: yes (Claude Code).
MoonEyes commented 2026-12-02 12:41:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:41:40Z.


This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).

Could you, or anyone with a working setup, post a run report on the current head merged onto current main:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone for comparison, if you can.

Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345730882 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7345730882). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T12:41:40Z. --- This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists). Could you, or anyone with a working setup, post a run report on the **current head** merged onto current `main`: - the head SHA and the `main` SHA it was merged onto; - GPU, driver and OS; - at least 300 s in the world after loading; - device lost / crashes (count), and rendered fps (median) if you have them; - the same run on `main` alone for comparison, if you can. Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough. AI-assisted (Claude Code).
rockcabbage commented 2026-12-02 13:37:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by rockcabbage on 2026-12-02T13:37:37Z.


Run report, head merged onto current main.

  • Head 5aa56d74d merged onto main bf7886746 (merge 019adca0c, no conflicts), diag build (build-nvidia.ps1).
  • RTX 4090 (driver 621.24), i9-13900K, 64 GB, Windows 11; Series X profile, 2560x1440, -HardwareRT -NoFrameGen.
  • One start each from the same save, 440 s, the last 330 s in the world counted (LEONIDA_FRAME_TIMES), no input after the menus (the title's idle camera).
frames median p90 p99 device lost crashes
head on main 7,261 43.1 ms (23.2 fps) 54.2 81.1 0 0
main alone 8,083 39.9 ms (25.1 fps) 48.5 74.4 0 0

Both closed normally at the end. The two medians do not tell the change apart from main: starts with the same binary and settings stood between 36 and 52 ms on this PC over the day (two back to back: 42.4 and 52.0), and these runs stand still, where the walks this change removes do not occur (they come with bottom-level builds while moving; the in-run comparison in the description is the measure of that). Pictures of both runs looked at at 200 s and 430 s: the scene is right in each.

AI-assisted (Claude Code, Claude Fable 5.2); run on the machine above.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7347179488 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7347179488). Originally posted by [rockcabbage](https://github.com/rockcabbage) on 2026-12-02T13:37:37Z. --- Run report, head merged onto current `main`. - Head `5aa56d74d` merged onto `main` `bf7886746` (merge `019adca0c`, no conflicts), diag build (`build-nvidia.ps1`). - RTX 4090 (driver 621.24), i9-13900K, 64 GB, Windows 11; Series X profile, 2560x1440, `-HardwareRT -NoFrameGen`. - One start each from the same save, 440 s, the last 330 s in the world counted (`LEONIDA_FRAME_TIMES`), no input after the menus (the title's idle camera). | | frames | median | p90 | p99 | device lost | crashes | |---|---|---|---|---|---|---| | head on `main` | 7,261 | 43.1 ms (23.2 fps) | 54.2 | 81.1 | 0 | 0 | | `main` alone | 8,083 | 39.9 ms (25.1 fps) | 48.5 | 74.4 | 0 | 0 | Both closed normally at the end. The two medians do not tell the change apart from `main`: starts with the same binary and settings stood between 36 and 52 ms on this PC over the day (two back to back: 42.4 and 52.0), and these runs stand still, where the walks this change removes do not occur (they come with bottom-level builds while moving; the in-run comparison in the description is the measure of that). Pictures of both runs looked at at 200 s and 430 s: the scene is right in each. AI-assisted (Claude Code, Claude Fable 5.2); run on the machine above.
lixonik commented 2026-12-02 14:44:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T14:44:27Z.


Quick heads-up while checking [NEEDS-GAME-RUN] PRs: head 5aa56d74d now has a merge conflict in d3d12/crates/leonida-gpu/src/texture.rs against current main (acc350745), so it will need a rebase/merge onto main before it can be merged.

AI-assisted: yes (Antigravity).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7349058013 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7349058013). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T14:44:27Z. --- Quick heads-up while checking `[NEEDS-GAME-RUN]` PRs: head `5aa56d74d` now has a merge conflict in `d3d12/crates/leonida-gpu/src/texture.rs` against current `main` (`acc350745`), so it will need a rebase/merge onto `main` before it can be merged. AI-assisted: yes (Antigravity).
rockcabbage commented 2026-12-02 15:36:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by rockcabbage on 2026-12-02T15:36:53Z.


Rebased state: main merged into the branch (the conflict in texture.rs was two tests added at the same place; both kept). New head fa1460b6b, which contains main acc350745; it still merges cleanly onto main 3c106eb2f (checked with git merge-tree, not run in game at that commit).

Run report for head fa1460b6b:

  • Diag build (build-nvidia.ps1); cargo test -p leonida-gpu --features diagnostics --lib --locked: 779 passed.
  • RTX 4090, i9-13900K, 64 GB, Windows 11; Series X profile, 2560x1440, -HardwareRT -NoFrameGen.
  • 330 s from a save in the world, with a scripted walk and camera turns from 120 s to 230 s.
  • Device lost: 0. No panic or error line in the log.
  • Median frame 47.0 ms (21.3 fps), 10th to 90th percentile 41.2 to 60.2 ms over the five-second lines. Starts with the same settings on this PC stand between 38 and 52 ms, so this is inside that spread; main alone was not run again at this commit (the earlier report's main run gave 39.9 ms against 43.1 for the head of that time).
  • Five pictures over the run (walking, turning, the camera pulled back) were looked at: the scene is right.

AI-assisted: yes (Claude Code, Claude Fable 5.2).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7350625476 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7350625476). Originally posted by [rockcabbage](https://github.com/rockcabbage) on 2026-12-02T15:36:53Z. --- Rebased state: `main` merged into the branch (the conflict in `texture.rs` was two tests added at the same place; both kept). New head `fa1460b6b`, which contains `main` `acc350745`; it still merges cleanly onto `main` `3c106eb2f` (checked with `git merge-tree`, not run in game at that commit). Run report for head `fa1460b6b`: - Diag build (`build-nvidia.ps1`); `cargo test -p leonida-gpu --features diagnostics --lib --locked`: 779 passed. - RTX 4090, i9-13900K, 64 GB, Windows 11; Series X profile, 2560x1440, `-HardwareRT -NoFrameGen`. - 330 s from a save in the world, with a scripted walk and camera turns from 120 s to 230 s. - Device lost: 0. No panic or error line in the log. - Median frame 47.0 ms (21.3 fps), 10th to 90th percentile 41.2 to 60.2 ms over the five-second lines. Starts with the same settings on this PC stand between 38 and 52 ms, so this is inside that spread; `main` alone was not run again at this commit (the earlier report's `main` run gave 39.9 ms against 43.1 for the head of that time). - Five pictures over the run (walking, turning, the camera pulled back) were looked at: the scene is right. AI-assisted: yes (Claude Code, Claude Fable 5.2).
nyceminem commented 2026-12-02 17:18:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by nyceminem on 2026-12-02T17:18:54Z.


Measured on another machine: the meter's five-second walk shows up as a periodic hitch during ordinary walking too (no hardware ray tracing), and this PR removes it.

Setup: RTX 5070 (driver 616.64), Ryzen 7 7700X, Windows 11, diag build, launcher default (Series X, 2560x1440 output, -Lowest 1080, DLSS frame generation 2x) with LEONIDA_FG_LIMIT_FPS=0. Same save, about 4 minutes of manually driven running with camera turns per side. Per-frame data from LEONIDA_FRAME_TIMES.

  • Before: main 3c106eb2f, measured in the phases of a run where a local test switch kept the five-second lines on (LEONIDA_AB=10,..., 124 s, 2,395 frames).
  • After: main 3c106eb2f + this PR, one run (252 s, 4,866 frames).
before after
frames over 140 ms 9.7 / min 1.2 / min
phase-locked to a ~5.2 s period yes (Rayleigh Z = 17.2, p < 0.005; 41-48 % of beats hit) no (Z = 1.4 at 5.2 s; 6 % of beats)
p99 frame time 118.5 ms 101.3 ms
average FPS / median frame 19.45 / 49.1 ms 19.34 / 49.0 ms

In the same before-run, the phases with the five-second lines skipped also lost most of the beat (frames over 140 ms on 6 of 22 beats against 16 of 21 with them on). As the PR says, the median does not move; only the frames above it go.

Caveats: single runs per side, manual routes, and the before-side phases are not contiguous. Two independent read-only reviewer agents checked the numbers blind (runs labelled without their identities).

AI-assisted: the measurements, analysis and this comment were made with Claude Code (Claude Opus 5.5), with separate read-only reviewer agents (Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7353174357 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7353174357). Originally posted by [nyceminem](https://github.com/nyceminem) on 2026-12-02T17:18:54Z. --- Measured on another machine: the meter's five-second walk shows up as a periodic hitch during ordinary walking too (no hardware ray tracing), and this PR removes it. **Setup:** RTX 5070 (driver 616.64), Ryzen 7 7700X, Windows 11, diag build, launcher default (Series X, 2560x1440 output, `-Lowest 1080`, DLSS frame generation 2x) with `LEONIDA_FG_LIMIT_FPS=0`. Same save, about 4 minutes of manually driven running with camera turns per side. Per-frame data from `LEONIDA_FRAME_TIMES`. - **Before:** `main` 3c106eb2f, measured in the phases of a run where a local test switch kept the five-second lines on (`LEONIDA_AB=10,...`, 124 s, 2,395 frames). - **After:** `main` 3c106eb2f + this PR, one run (252 s, 4,866 frames). | | before | after | |---|---|---| | frames over 140 ms | 9.7 / min | 1.2 / min | | phase-locked to a ~5.2 s period | yes (Rayleigh Z = 17.2, p < 0.005; 41-48 % of beats hit) | no (Z = 1.4 at 5.2 s; 6 % of beats) | | p99 frame time | 118.5 ms | 101.3 ms | | average FPS / median frame | 19.45 / 49.1 ms | 19.34 / 49.0 ms | In the same before-run, the phases with the five-second lines skipped also lost most of the beat (frames over 140 ms on 6 of 22 beats against 16 of 21 with them on). As the PR says, the median does not move; only the frames above it go. **Caveats:** single runs per side, manual routes, and the before-side phases are not contiguous. Two independent read-only reviewer agents checked the numbers blind (runs labelled without their identities). AI-assisted: the measurements, analysis and this comment were made with Claude Code (Claude Opus 5.5), with separate read-only reviewer agents (Claude Opus 5.5).
MoonEyes commented 2026-12-02 18:18:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:18:31Z.


Verification of #3113 (third party, code review on Linux; not built: Windows-only leonida-gpu)

  • Head verified: fa1460b6bdf502c6d46ae2cd2479f6a8a916275b (5 files, +166/-15). This is the head after main was
    merged in to resolve the texture.rs conflict.
  • Merge base acc350745. git merge-tree --write-tree origin/main pr/3113 against main 45dc41f95 is clean
    (34 commits behind).
  • CI: no check runs on this head (fork workflows waiting for approval).
  • python -I scripts/check_no_game_data.py on the 5 files: exit 0.
  • Gate: rockcabbage's in-game run on fa1460b6b, plus nyceminem's second machine (RTX 5070). Kal0s-design ran
    the unit suite on the previous head 5aa56d74d.

Review

  • Root cause: VirtualQuery walks the page tables to the end of a run, which takes 21-36 ms in the title's pools,
    and GetWriteWatch on the submitting thread queues behind it. The PR stops asking VirtualQuery on the two
    hot callers:

    • hwrt::readable_len (hwrt.rs:466-479) now uses texture::readable_bytes, which is QueryWorkingSetEx
      for up to 256 pages per call, with no walk;
    • copystat::log uses texture::shared, one page per call.

    The old path is kept behind LEONIDA_HW_RT_REGION_QUERY=1 for A/B. That is the same remedy texture::by_query
    already applies to the textures' pass, so it is consistent and not a new workaround.

  • Correctness of readable (texture.rs:2812-2850): a page outside the working set (never touched or trimmed)
    falls back to a one-byte read_into, so committed-but-not-resident memory still counts as readable, as it did
    under VirtualQuery. The new protection check (flags >> 4) & 0x101 == 0 excludes PAGE_NOACCESS (0x01)
    and PAGE_GUARD (0x100) in the 11-bit Win32Protection field. That is correct, and it also tightens the
    textures' pass, which used to count a resident PAGE_NOACCESS page as readable. The new test covers it
    ("a page closed after it was touched").

  • readable_bytes (texture.rs:2873-2880): there * 4096 - at % 4096 when the run stops early, saturating to 0.
    The test checks both the offset (at + 100) and the stop at an uncommitted page.

  • Test title_memory_is_asked_about_page_by_page asserts that REGION_QUERIES does not move, so it fails if the
    default path walks again. This is a real guard for the change. shared gets a private-against-mapping test.

  • Unrelated churn: switches.md:46 flips the LEONIDA_KEYS row's column (regenerated table). It is harmless,
    but it is outside the topic.

Process

  • Claim and AI disclosure (Claude Fable 5.2, Claude Opus reviewer) are present. findings.md records the
    measurement with the machine and the A/B switch, as AGENTS.md asks.

Verdict: ready (not built here). It only needs the fork CI approved.

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7354339019 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7354339019). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:18:31Z. --- **Verification of #3113 (third party, code review on Linux; not built: Windows-only `leonida-gpu`)** - Head verified: `fa1460b6bdf502c6d46ae2cd2479f6a8a916275b` (5 files, +166/-15). This is the head after `main` was merged in to resolve the `texture.rs` conflict. - Merge base `acc350745`. `git merge-tree --write-tree origin/main pr/3113` against `main` `45dc41f95` is clean (34 commits behind). - CI: no check runs on this head (fork workflows waiting for approval). - `python -I scripts/check_no_game_data.py` on the 5 files: exit 0. - Gate: rockcabbage's in-game run on `fa1460b6b`, plus nyceminem's second machine (RTX 5070). Kal0s-design ran the unit suite on the previous head `5aa56d74d`. **Review** - Root cause: `VirtualQuery` walks the page tables to the end of a run, which takes 21-36 ms in the title's pools, and `GetWriteWatch` on the submitting thread queues behind it. The PR stops asking `VirtualQuery` on the two hot callers: - `hwrt::readable_len` (`hwrt.rs:466-479`) now uses `texture::readable_bytes`, which is `QueryWorkingSetEx` for up to 256 pages per call, with no walk; - `copystat::log` uses `texture::shared`, one page per call. The old path is kept behind `LEONIDA_HW_RT_REGION_QUERY=1` for A/B. That is the same remedy `texture::by_query` already applies to the textures' pass, so it is consistent and not a new workaround. - Correctness of `readable` (`texture.rs:2812-2850`): a page outside the working set (never touched or trimmed) falls back to a one-byte `read_into`, so committed-but-not-resident memory still counts as readable, as it did under `VirtualQuery`. The new protection check `(flags >> 4) & 0x101 == 0` excludes `PAGE_NOACCESS` (0x01) and `PAGE_GUARD` (0x100) in the 11-bit `Win32Protection` field. That is correct, and it also tightens the textures' pass, which used to count a resident `PAGE_NOACCESS` page as readable. The new test covers it ("a page closed after it was touched"). - `readable_bytes` (`texture.rs:2873-2880`): `there * 4096 - at % 4096` when the run stops early, saturating to 0. The test checks both the offset (`at + 100`) and the stop at an uncommitted page. - Test `title_memory_is_asked_about_page_by_page` asserts that `REGION_QUERIES` does not move, so it fails if the default path walks again. This is a real guard for the change. `shared` gets a private-against-mapping test. - Unrelated churn: `switches.md:46` flips the `LEONIDA_KEYS` row's column (regenerated table). It is harmless, but it is outside the topic. **Process** - Claim and AI disclosure (Claude Fable 5.2, Claude Opus reviewer) are present. `findings.md` records the measurement with the machine and the A/B switch, as AGENTS.md asks. **Verdict: ready** (not built here). It only needs the fork CI approved. AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
MoonEyes commented 2026-12-02 18:21:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:21:43Z.


RUN (in game, batch of seventeen render-path pull requests), each head merged with git merge --no-ff onto main 3c106eb2f, in one build: #3111 15b579756, #2948 5284c6eae, #2698 1f188c4f7, #2946 44bf554fe, #3001 d924cbb65, #2832 0c861595a, #2915 58e8535cf, #2822 d359a2f85, #2896 c9c6b103d, #2983 8278ef1b9, #3115 ba5121192, #2945 d2c08c14f, #2975 74512d658, #2951 26da88e8e, #2800 b6ebcedd4, #2893 7c7e99b48, #3113 fa1460b6b (and #3097 0d7a451ab, merged since). RTX 4060 8 GB, driver 610.88, Windows 11. Series S, -Resolution 1080, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (43 samples) median 14.6, mean 12.7
Rendered fps, last 120 s median 13.7
Time under 5 fps in the world 13 % (short drops, lowest sample 0.3 fps)

The drops under 5 fps line up with shaders being translated while walking (about 500 translations in the last 330 s): this batch changes the shader translation, so the shader cache built by earlier runs did not apply and the pipeline precompile alone took about 45 minutes. The batch-5 run on the same machine and route had no sample under 5 fps (median 16.4). I read this as cold-cache stutter, not as a regression of a single pull request, but this run cannot tell them apart.

Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.

Limits: one run; arrival in the world was driven by keys and not checked on pictures. A first attempt of this batch is not counted: the run script gave up waiting for the game window after 40 minutes of precompile.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7354445288 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7354445288). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:21:43Z. --- RUN (in game, batch of seventeen render-path pull requests), each head merged with `git merge --no-ff` onto main `3c106eb2f`, in one build: #3111 `15b579756`, #2948 `5284c6eae`, #2698 `1f188c4f7`, #2946 `44bf554fe`, #3001 `d924cbb65`, #2832 `0c861595a`, #2915 `58e8535cf`, #2822 `d359a2f85`, #2896 `c9c6b103d`, #2983 `8278ef1b9`, #3115 `ba5121192`, #2945 `d2c08c14f`, #2975 `74512d658`, #2951 `26da88e8e`, #2800 `b6ebcedd4`, #2893 `7c7e99b48`, #3113 `fa1460b6b` (and #3097 `0d7a451ab`, merged since). RTX 4060 8 GB, driver 610.88, Windows 11. Series S, `-Resolution 1080`, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world. | What | Result | |---|---| | Device lost / device removed | 0 | | Exceptions, panics, hang watchdog, GPU stall, title suspended | 0 | | Process alive at the end | yes, stopped by the time limit | | Rendered fps, last 240 s (43 samples) | median 14.6, mean 12.7 | | Rendered fps, last 120 s | median 13.7 | | Time under 5 fps in the world | 13 % (short drops, lowest sample 0.3 fps) | The drops under 5 fps line up with shaders being translated while walking (about 500 translations in the last 330 s): this batch changes the shader translation, so the shader cache built by earlier runs did not apply and the pipeline precompile alone took about 45 minutes. The batch-5 run on the same machine and route had no sample under 5 fps (median 16.4). I read this as cold-cache stutter, not as a regression of a single pull request, but this run cannot tell them apart. Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it. Limits: one run; arrival in the world was driven by keys and not checked on pictures. A first attempt of this batch is not counted: the run script gave up waiting for the game window after 40 minutes of precompile. AI-assisted (Claude Code).
fiestorra commented 2026-12-02 23:41:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T23:41:04Z.


VERIFY-3113 — Windows nativo: red then green en las dos mitades del cambio

Own commit 5aa56d74d — copystat.rs (16), hwrt.rs (+80), texture.rs

Ran at the head

cargo test -p leonida-gpu --lib title_memory_is_asked_about_page_by_page    1 passed
  hwrt::tests::title_memory_is_asked_about_page_by_page ... ok
cargo test -p leonida-gpu --lib a_page_says_whether_it_is_private           1 passed
  texture::title_memory_tests::a_page_says_whether_it_is_private_or_a_mapping ... ok

Negative control (synthetic): I made texture::shared(at) return Some(false) unconditionally, rebuilt and ran:

FAILED: a_page_says_whether_it_is_private_or_a_mapping
assertion `left == right` failed

It bites.

What the change is: the write watch's readable range is now measured VirtualQuery-per-page (readable_len_by_query), walking the run of pages instead of trusting one query's answer for the whole range — and a page can now say whether it is private memory or a mapping (shared(at)), with readable_bytes sitting on both. The distinction matters because a mapped page and a private one behave differently for a write watch: one is the title's own memory and the other is somebody's file.

What I could not test: the walk over the title's real address space — the tests drive the predicates with pages they describe, and the game's own layout is what the change is for.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7362300848 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7362300848). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T23:41:04Z. --- ## VERIFY-3113 — Windows nativo: `red then green` en las dos mitades del cambio | | | |---|---| | Own commit | `5aa56d74d` — `copystat.rs` (16), `hwrt.rs` (+80), `texture.rs` | **Ran at the head** ``` cargo test -p leonida-gpu --lib title_memory_is_asked_about_page_by_page 1 passed hwrt::tests::title_memory_is_asked_about_page_by_page ... ok cargo test -p leonida-gpu --lib a_page_says_whether_it_is_private 1 passed texture::title_memory_tests::a_page_says_whether_it_is_private_or_a_mapping ... ok ``` **Negative control (synthetic)**: I made `texture::shared(at)` return `Some(false)` unconditionally, rebuilt and ran: ``` FAILED: a_page_says_whether_it_is_private_or_a_mapping assertion `left == right` failed ``` **It bites.** **What the change is**: the write watch's readable range is now measured **`VirtualQuery`-per-page** (`readable_len_by_query`), **walking the run of pages instead of trusting one query's answer for the whole range** — and a page can now say **whether it is private memory or a mapping** (`shared(at)`), with `readable_bytes` sitting on both. **The distinction matters because a mapped page and a private one behave differently for a write watch**: one is the title's own memory and the other is somebody's file. **What I could not test**: the walk over the title's real address space — **the tests drive the predicates with pages they describe**, and the game's own layout is what the change is for. Written with an AI assistant.
x2Tweek commented 2026-12-03 06:47:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by x2Tweek on 2026-12-03T06:47:41Z.


Data point for this PR: on main, readable_len is the largest BLAS CPU cost on the recording threads with hardware RT on.

Setup: RTX 5090 32 GB, driver 621.40, i9-14900KS, Windows 11 26300. Diag build of main d9b618f10 plus one unrelated local change (a BLAS buffer pool, off/on below; it does not touch readable_len). Timers are added around readable_len and the other BLAS preparation steps (wall time, diagnostics only). The run uses -HardwareRT, Series X profile, 4K output, DLSS quality. The character walks with the camera turning continuously (look keys through LEONIDA_KEYS_FILE), for 300 s in the world per run.

run readable_len (VirtualQuery, as on main) whole BLAS flush quant24 + meshlet decode BLAS built
1 30.0 s 6.7 s 0.4 s 31.3k
2 20.6 s 15.0 s 0.4 s 36.6k
3 19.7 s 6.0 s 0.5 s 37.7k
4 18.4 s 11.9 s 0.4 s 39.1k

That is 6-10 % of the wall time, on the thread that records, for the page question alone. It costs more than all the rest of the BLAS preparation together, which matches the walk this PR removes. I have not yet run this PR's head with the same timers, so I give no "after" number here; I will add it if that helps.

AI-assisted: runs, timers and write-up with Claude Opus 5.5 (Claude Code); the numbers are the runtime's own log lines.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7370239872 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7370239872). Originally posted by [x2Tweek](https://github.com/x2Tweek) on 2026-12-03T06:47:41Z. --- **Data point for this PR: on `main`, `readable_len` is the largest BLAS CPU cost on the recording threads with hardware RT on.** Setup: RTX 5090 32 GB, driver 621.40, i9-14900KS, Windows 11 26300. Diag build of `main` `d9b618f10` plus one unrelated local change (a BLAS buffer pool, off/on below; it does not touch `readable_len`). Timers are added around `readable_len` and the other BLAS preparation steps (wall time, diagnostics only). The run uses `-HardwareRT`, Series X profile, 4K output, DLSS quality. The character walks with the camera turning continuously (look keys through `LEONIDA_KEYS_FILE`), for 300 s in the world per run. | run | `readable_len` (VirtualQuery, as on main) | whole BLAS flush | quant24 + meshlet decode | BLAS built | |---|---|---|---|---| | 1 | 30.0 s | 6.7 s | 0.4 s | 31.3k | | 2 | 20.6 s | 15.0 s | 0.4 s | 36.6k | | 3 | 19.7 s | 6.0 s | 0.5 s | 37.7k | | 4 | 18.4 s | 11.9 s | 0.4 s | 39.1k | That is 6-10 % of the wall time, on the thread that records, for the page question alone. It costs more than all the rest of the BLAS preparation together, which matches the walk this PR removes. I have not yet run this PR's head with the same timers, so I give no "after" number here; I will add it if that helps. AI-assisted: runs, timers and write-up with Claude Opus 5.5 (Claude Code); the numbers are the runtime's own log lines.
MoonEyes commented 2026-12-03 07:01:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T07:01:13Z.


This pull request has a merge conflict with current main (d9b618f10), so it can't be run in game or merged as it is. Could you merge the latest main into it (or rebase onto it) and resolve the conflict? Once the head is updated, the in-game gate run can be done on the new head.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7370499706 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7370499706). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T07:01:13Z. --- This pull request has a merge conflict with current `main` (`d9b618f10`), so it can't be run in game or merged as it is. Could you merge the latest `main` into it (or rebase onto it) and resolve the conflict? Once the head is updated, the in-game gate run can be done on the new head. AI-assisted (Claude Code).
OreoFR commented 2026-12-03 07:09:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-03T07:09:42Z.


Merge check on current main d9b618f10, head fa1460b6b: git merge --no-ff conflicts only in d3d12/docs/switches.md, on the header count line. Main says 684/644, this PR says 682/642. The other four files merge cleanly, with no code conflict. Regenerating the page with python -I tools/d3d12_switches.py --out d3d12/docs/switches.md after merging main resolves it. For an in-game A/B on an RTX 4070 Laptop (Series S, hardware RT, native 1080), I'll resolve it locally that way and post the numbers here. (oreofr-agent, AI-assisted)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7370665376 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7370665376). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-03T07:09:42Z. --- Merge check on current main `d9b618f10`, head `fa1460b6b`: `git merge --no-ff` conflicts only in `d3d12/docs/switches.md`, on the header count line. Main says 684/644, this PR says 682/642. The other four files merge cleanly, with no code conflict. Regenerating the page with `python -I tools/d3d12_switches.py --out d3d12/docs/switches.md` after merging main resolves it. For an in-game A/B on an RTX 4070 Laptop (Series S, hardware RT, native 1080), I'll resolve it locally that way and post the numbers here. (oreofr-agent, AI-assisted)
OreoFR commented 2026-12-03 08:03:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-03T08:03:50Z.


RUN: #3113 vs main, in-game A/B with hardware RT on the Series S profile (Verified by OreoFR)

  • Head: fa1460b6bdf502c6d46ae2cd2479f6a8a916275b. Main: d9b618f10150f275c30088e4769c1acbf1d8d689.
  • Merge: local --no-ff merge 75cf8c6f3, not pushed. The only conflict was the count line of d3d12/docs/switches.md, regenerated with tools/d3d12_switches.py --out; the code merged cleanly.
  • GPU: RTX 4070 Laptop 8 GB, driver 621.40, Windows 11.
  • Build: build-nvidia.ps1 (diag). Both builds carry the same local measuring patch in host/frametime.rs, counting frames over 50 ms and in 55-65 ms per 5 s line. It is not part of the PR.
  • Recipe:
    • -SeriesS -HardwareRT -Resolution 1080 -NoDlss -NoFrameGen -PrecompileUsed, BAR 0, texture budget 1024;
    • a fresh data copy per run, 330 s walking, stats over the last 240 s;
    • three 150 s warm-ups first (A, B, A), not counted;
    • then A B A B, with A = main and B = main + #3113.
  • Prediction, written before the runs: fewer frames over 50 ms and in 55-65 ms with B, and about the same median.
run fps median ms worst ms >50 ms 55-65 ms >100 ms >1 s device lost/removed, errors
A1 main 20.52 46.4 142 1518 66 39 0 0 / 0 / 0
B1 #3113 20.57 47.5 115 1653 102 10 0 0 / 0 / 0
A2 main 20.38 46.3 143 1602 69 44 0 0 / 0 / 0
B2 #3113 20.38 46.7 319 1788 93 10 0 0 / 0 / 0

A1 → A2 drift: 0.14 fps, 0.1 ms median, 84 frames over 50 ms, 3 in 55-65 ms, 5 over 100 ms.

Verdict (MEASURED, n=2 per arm):

  • Frames over 100 ms drop about 4x, from 39 and 44 to 10 and 10. After loading, B has 0-1 such frames a minute against 9-13 on main. This matches the stall the PR describes.
  • The prediction was wrong on the 50-65 ms band. B has more frames over 50 ms (+10 %) and in 55-65 ms (+44 %), both outside the A-to-A drift.
  • The median is about 0.7 ms higher with B. fps does not change (within drift).
  • No device lost or removed, and no errors.
  • Hypothesis, not checked: the page-by-page walk spreads the long stalls into many slightly slower frames.
  • Net: fewer big hitches, the same fps, a little more 50-65 ms jitter.

The branch needs main merged in (the switches.md count line) before it can merge.

AI-assisted (oreofr-agent)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7371775016 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7371775016). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-03T08:03:50Z. --- **RUN: #3113 vs main, in-game A/B with hardware RT on the Series S profile (Verified by OreoFR)** - **Head:** `fa1460b6bdf502c6d46ae2cd2479f6a8a916275b`. **Main:** `d9b618f10150f275c30088e4769c1acbf1d8d689`. - **Merge:** local `--no-ff` merge `75cf8c6f3`, not pushed. The only conflict was the count line of `d3d12/docs/switches.md`, regenerated with `tools/d3d12_switches.py --out`; the code merged cleanly. - **GPU:** RTX 4070 Laptop 8 GB, driver 621.40, Windows 11. - **Build:** `build-nvidia.ps1` (diag). Both builds carry the same local measuring patch in `host/frametime.rs`, counting frames over 50 ms and in 55-65 ms per 5 s line. It is not part of the PR. - **Recipe:** - `-SeriesS -HardwareRT -Resolution 1080 -NoDlss -NoFrameGen -PrecompileUsed`, BAR 0, texture budget 1024; - a fresh data copy per run, 330 s walking, stats over the last 240 s; - three 150 s warm-ups first (A, B, A), not counted; - then A B A B, with A = main and B = main + #3113. - **Prediction, written before the runs:** fewer frames over 50 ms and in 55-65 ms with B, and about the same median. | run | fps | median ms | worst ms | >50 ms | 55-65 ms | >100 ms | >1 s | device lost/removed, errors | |---|---|---|---|---|---|---|---|---| | A1 main | 20.52 | 46.4 | 142 | 1518 | 66 | 39 | 0 | 0 / 0 / 0 | | B1 #3113 | 20.57 | 47.5 | 115 | 1653 | 102 | 10 | 0 | 0 / 0 / 0 | | A2 main | 20.38 | 46.3 | 143 | 1602 | 69 | 44 | 0 | 0 / 0 / 0 | | B2 #3113 | 20.38 | 46.7 | 319 | 1788 | 93 | 10 | 0 | 0 / 0 / 0 | A1 → A2 drift: 0.14 fps, 0.1 ms median, 84 frames over 50 ms, 3 in 55-65 ms, 5 over 100 ms. **Verdict (MEASURED, n=2 per arm):** - **Frames over 100 ms drop about 4x,** from 39 and 44 to 10 and 10. After loading, B has 0-1 such frames a minute against 9-13 on main. This matches the stall the PR describes. - **The prediction was wrong on the 50-65 ms band.** B has more frames over 50 ms (+10 %) and in 55-65 ms (+44 %), both outside the A-to-A drift. - **The median is about 0.7 ms higher with B.** fps does not change (within drift). - **No device lost or removed, and no errors.** - **Hypothesis, not checked:** the page-by-page walk spreads the long stalls into many slightly slower frames. - **Net:** fewer big hitches, the same fps, a little more 50-65 ms jitter. The branch needs main merged in (the `switches.md` count line) before it can merge. AI-assisted (oreofr-agent)
merzleckeier commented 2026-12-03 08:25:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T08:25:27Z.


Rechecked fa1460b6 on d9b618f1. The two new tests passed in a Windows MSVC build under Wine 11.22. A separate synthetic range starting 123 bytes into its first page and crossing the 256-page query batch boundary returned the same readable prefix with both paths. Both stopped at the first uncommitted page.

The page-wise check also brought untouched data pages into the working set. I alternated the two paths on fresh, committed read-write allocations and collected ten samples per combination. At 256 KiB, the untouched range took a median of 0.8 µs with VirtualQuery and 42.8 µs with the page-wise check. The resident-page count stayed at 0 with VirtualQuery and rose from 0 to 64 with the page-wise check. At 4 MiB, the medians were 0.9 and 349.2 µs and the resident counts afterward were 0 and 1,024 respectively. With pages touched beforehand, the page-wise medians were 3.6 µs at 256 KiB and 32.5 µs at 4 MiB. These timings isolate the readable check on synthetic ranges under Wine.

The local combination with #3297 58386088 conflicted only in the generated switch page. Regeneration passed --check and all 21 catalog tests with #3270 applied.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7372246589 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7372246589). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T08:25:27Z. --- Rechecked `fa1460b6` on `d9b618f1`. The two new tests passed in a Windows MSVC build under Wine 11.22. A separate synthetic range starting 123 bytes into its first page and crossing the 256-page query batch boundary returned the same readable prefix with both paths. Both stopped at the first uncommitted page. The page-wise check also brought untouched data pages into the working set. I alternated the two paths on fresh, committed read-write allocations and collected ten samples per combination. At 256 KiB, the untouched range took a median of 0.8 µs with `VirtualQuery` and 42.8 µs with the page-wise check. The resident-page count stayed at 0 with `VirtualQuery` and rose from 0 to 64 with the page-wise check. At 4 MiB, the medians were 0.9 and 349.2 µs and the resident counts afterward were 0 and 1,024 respectively. With pages touched beforehand, the page-wise medians were 3.6 µs at 256 KiB and 32.5 µs at 4 MiB. These timings isolate the readable check on synthetic ranges under Wine. The local combination with #3297 `58386088` conflicted only in the generated switch page. Regeneration passed `--check` and all 21 catalog tests with #3270 applied. AI-assisted with OpenAI Codex.
merzleckeier commented 2026-12-03 08:38:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T08:38:05Z.


Rechecked 9ba2215a after the merge of main d9b618f1. The PR now merges cleanly and d3d12/docs/switches.md matches a fresh generation byte for byte. A Windows MSVC build of this exact head under Wine 11.22 passed all nine title_memory tests, including the readable-range and private/mapping tests from this PR. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7372533043 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7372533043). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T08:38:05Z. --- Rechecked `9ba2215a` after the merge of `main` `d9b618f1`. The PR now merges cleanly and `d3d12/docs/switches.md` matches a fresh generation byte for byte. A Windows MSVC build of this exact head under Wine 11.22 passed all nine `title_memory` tests, including the readable-range and private/mapping tests from this PR. AI-assisted with OpenAI Codex.
lixonik commented 2026-12-03 09:53:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-03T09:53:04Z.


RUN (in game, RTX 5070 12 GB, Hardware RT, 315 s in-world gate) -- PASS (updated head 9ba2215ad)

  • Head tested: 9ba2215ad merged cleanly (git merge --no-ff) onto main (d9b618f10)
  • Preflight & unit tests (Windows 10 x64):
    • python -I scripts/check_no_game_data.py -- PASS
    • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md -- PASS
    • LEONIDA_D3D12_DEBUG=1 cargo test -p leonida-gpu --lib --locked hwrt:: -- 23/23 PASS (including hwrt::tests::title_memory_is_asked_about_page_by_page)
    • cargo test -p leonida-gpu --lib --locked texture:: -- 25 passed, 0 failed, 5 ignored (including texture::title_memory_tests::mapped_bytes_counts_readable_pages_between_unmapped_ends)
    • cargo build --profile diag --features "diagnostics,dlss,mimalloc" --locked -- PASS
  • In-game run (Windows 10, RTX 5070 12 GB, Series S preset, DLSS, no Frame Generation, Hardware RT (LEONIDA_HW_RT=1, LEONIDA_AMBIENT=0, LEONIDA_RT_RESOLVE=1, LEONIDA_ACTIVATE_RAYS=1), 315 s in world, 452.1 s total, 64 world samples, max 5,364 draws):
    • Runtime errors: 0; device lost: 0
    • Hardware RT active: DXR 1.1 tier 11, 14 lifted ray-query shaders (0 software fallbacks), 5,356 live BLAS (19,593 built, 341,989 refits, 3,589 rehydrated), 5 live TLAS (38,470 builds), BLAS memory 539 MB / 1,073 MB budget (0 evicted), 0 geometries given inactive
    • Frame rate: median 24.5 fps (40.8 ms; slowest tenth 19.3, fastest tenth 25.5); 3000-4999 draws bucket: 24.7 fps (57 samples)

AI-assisted: yes (Antigravity -- Gemini 4 Neon).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7374412653 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7374412653). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-03T09:53:04Z. --- RUN (in game, RTX 5070 12 GB, Hardware RT, 315 s in-world gate) -- PASS (updated head `9ba2215ad`) - Head tested: `9ba2215ad` merged cleanly (`git merge --no-ff`) onto `main` (`d9b618f10`) - Preflight & unit tests (Windows 10 x64): - `python -I scripts/check_no_game_data.py` -- PASS - `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md` -- PASS - `LEONIDA_D3D12_DEBUG=1 cargo test -p leonida-gpu --lib --locked hwrt::` -- 23/23 PASS (including `hwrt::tests::title_memory_is_asked_about_page_by_page`) - `cargo test -p leonida-gpu --lib --locked texture::` -- 25 passed, 0 failed, 5 ignored (including `texture::title_memory_tests::mapped_bytes_counts_readable_pages_between_unmapped_ends`) - `cargo build --profile diag --features "diagnostics,dlss,mimalloc" --locked` -- PASS - In-game run (Windows 10, RTX 5070 12 GB, Series S preset, DLSS, no Frame Generation, Hardware RT (`LEONIDA_HW_RT=1`, `LEONIDA_AMBIENT=0`, `LEONIDA_RT_RESOLVE=1`, `LEONIDA_ACTIVATE_RAYS=1`), 315 s in world, 452.1 s total, 64 world samples, max 5,364 draws): - Runtime errors: 0; device lost: 0 - Hardware RT active: DXR 1.1 tier 11, 14 lifted ray-query shaders (0 software fallbacks), 5,356 live BLAS (`19,593` built, `341,989` refits, `3,589` rehydrated), 5 live TLAS (`38,470` builds), BLAS memory `539 MB` / `1,073 MB` budget (`0` evicted), 0 geometries given inactive - Frame rate: median **24.5 fps** (40.8 ms; slowest tenth 19.3, fastest tenth 25.5); `3000-4999` draws bucket: **24.7 fps** (57 samples) AI-assisted: yes (Antigravity -- Gemini 4 Neon).
merzleckeier commented 2026-12-03 12:26:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T12:26:30Z.


Integration check on b053a181 with #3113 5e45fd65 and #3297 e31ec65b. The code merged cleanly. Regenerating d3d12/docs/switches.md resolved the only conflict and retained all four switches from the pair. All 21 switch catalog tests passed.

In the Windows MSVC build under Wine I exercised the real read_geometries with a synthetic 48-byte transform spanning two pages, including a read-only second page. All four combinations of LEONIDA_HW_RT_REGION_QUERY and LEONIDA_HW_RT_TX_COPY passed. With capture enabled, both memory-check paths saved the exact words and kept them when the backing memory changed in a later frame. Both declined to capture a transform extending into an uncommitted or newly inaccessible page. The sizing query produced no copy and did not invoke VirtualQuery.

The combined build passed 30 HWRT and four texture title-memory tests. The library also passed cargo check without diagnostics. This covers CPU-side capture, memory checks and build compatibility. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7378240872 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7378240872). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T12:26:30Z. --- Integration check on `b053a181` with #3113 `5e45fd65` and #3297 `e31ec65b`. The code merged cleanly. Regenerating `d3d12/docs/switches.md` resolved the only conflict and retained all four switches from the pair. All 21 switch catalog tests passed. In the Windows MSVC build under Wine I exercised the real `read_geometries` with a synthetic 48-byte transform spanning two pages, including a read-only second page. All four combinations of `LEONIDA_HW_RT_REGION_QUERY` and `LEONIDA_HW_RT_TX_COPY` passed. With capture enabled, both memory-check paths saved the exact words and kept them when the backing memory changed in a later frame. Both declined to capture a transform extending into an uncommitted or newly inaccessible page. The sizing query produced no copy and did not invoke `VirtualQuery`. The combined build passed 30 HWRT and four texture title-memory tests. The library also passed `cargo check` without diagnostics. This covers CPU-side capture, memory checks and build compatibility. AI-assisted with OpenAI Codex.
rockcabbage commented 2026-12-03 12:49:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by rockcabbage on 2026-12-03T12:49:11Z.


main merged in again (b053a1813): the only conflict was the generated d3d12/docs/switches.md, taken from main
and regenerated (--check passes). None of #3072, #3297, #3168, #3107 or #3225 had merged, so nothing in main
overlaps the change; main's own mapped_bytes now also leaves out PAGE_GUARD/PAGE_NOACCESS pages, the same
rule as this PR's readable.

Three small commits on top:

  • texture::shared is compiled only with diagnostics or tests: its one caller is the diagnostics-only meter, and the
    default build warned that it was never used.
  • The test's count of VirtualQuery walks is per thread now (thanks @Kal0s-design: a parallel test asking the walk
    moved the process-wide count). With LEONIDA_HW_RT_REGION_QUERY=1 the test still fails at "VirtualQuery asked".
  • A comment's timing now matches findings.md (24-28 ms for the meter's walk).

On the pages brought into the working set (@merzleckeier): yes, a committed page that is not resident is read one
byte to learn whether it is there, so it is faulted in. The BLAS build reads those vertex and index bytes right after
the question, so the fault is paid either way. The exception is the part of the probe beyond what the batch indexes.
That is the same trade texture::committed makes for the textures' pass. Left as it is.

Checks on 5e45fd657 (Windows 11, RTX 4090): cargo check -p leonida-gpu and with --features diagnostics: clean on
the PR's lines; cargo test -p leonida-gpu --lib --locked: 718 passed; with --features diagnostics: 799 passed;
cargo clippy -p leonida-gpu --features diagnostics: nothing on the PR's lines; tests/test_d3d12_switches.py: 21 OK;
scripts/check_no_game_data.py on the five files: exit 0. An independent read-only reviewer agent (Claude Opus)
audited the diff against main; its findings were the dead-code warning, the shared counter and the timing comment,
all fixed above. The rest were notes, not bugs.


Run report for head 5e45fd657 (contains main b053a1813; nothing in main after it at the time of the run).

  • Diag build without DLSS (--features diagnostics), started with play-d3d12.ps1 -HardwareRT -NoFrameGen (the title's own upscaler); cargo test -p leonida-gpu --features diagnostics --lib --locked: 799 passed.
  • RTX 4090, i9-13900K, Windows 11.
  • 440 s with the window up, about 340 s of it in the world from a save: a scripted walk off the deck, a swim and camera turns. First run after a full shader warm for this build.
  • Device lost: 0. Crashes: 0. No panic and no ERROR line in the log; the game closed on request.
  • Median frame 48.8 ms (20.5 fps) over 7510 frames in the world, 10th to 90th percentile of the 5 s windows' medians 35.9 to 63.8 ms; 84 frames over 100 ms, 4 over 1 s (longest 2.6 s). main alone was not run again, so this is a stability report, not a speed comparison.
  • 7 pictures over the run looked at: the scene is right in each (deck, water, under the pier).

AI-assisted: yes (Claude Code; Claude Fable 5.2 directing, Claude Opus 5.5 for the update, reviewer Claude Opus).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7378886252 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3113#issuecomment-7378886252). Originally posted by [rockcabbage](https://github.com/rockcabbage) on 2026-12-03T12:49:11Z. --- `main` merged in again (`b053a1813`): the only conflict was the generated `d3d12/docs/switches.md`, taken from `main` and regenerated (`--check` passes). None of #3072, #3297, #3168, #3107 or #3225 had merged, so nothing in `main` overlaps the change; `main`'s own `mapped_bytes` now also leaves out `PAGE_GUARD`/`PAGE_NOACCESS` pages, the same rule as this PR's `readable`. Three small commits on top: - `texture::shared` is compiled only with diagnostics or tests: its one caller is the diagnostics-only meter, and the default build warned that it was never used. - The test's count of `VirtualQuery` walks is per thread now (thanks @Kal0s-design: a parallel test asking the walk moved the process-wide count). With `LEONIDA_HW_RT_REGION_QUERY=1` the test still fails at "VirtualQuery asked". - A comment's timing now matches findings.md (24-28 ms for the meter's walk). On the pages brought into the working set (@merzleckeier): yes, a committed page that is not resident is read one byte to learn whether it is there, so it is faulted in. The BLAS build reads those vertex and index bytes right after the question, so the fault is paid either way. The exception is the part of the probe beyond what the batch indexes. That is the same trade `texture::committed` makes for the textures' pass. Left as it is. Checks on `5e45fd657` (Windows 11, RTX 4090): `cargo check -p leonida-gpu` and with `--features diagnostics`: clean on the PR's lines; `cargo test -p leonida-gpu --lib --locked`: 718 passed; with `--features diagnostics`: 799 passed; `cargo clippy -p leonida-gpu --features diagnostics`: nothing on the PR's lines; `tests/test_d3d12_switches.py`: 21 OK; `scripts/check_no_game_data.py` on the five files: exit 0. An independent read-only reviewer agent (Claude Opus) audited the diff against `main`; its findings were the dead-code warning, the shared counter and the timing comment, all fixed above. The rest were notes, not bugs. --- Run report for head `5e45fd657` (contains `main` `b053a1813`; nothing in `main` after it at the time of the run). - Diag build without DLSS (`--features diagnostics`), started with `play-d3d12.ps1 -HardwareRT -NoFrameGen` (the title's own upscaler); `cargo test -p leonida-gpu --features diagnostics --lib --locked`: 799 passed. - RTX 4090, i9-13900K, Windows 11. - 440 s with the window up, about 340 s of it in the world from a save: a scripted walk off the deck, a swim and camera turns. First run after a full shader warm for this build. - Device lost: 0. Crashes: 0. No panic and no ERROR line in the log; the game closed on request. - Median frame 48.8 ms (20.5 fps) over 7510 frames in the world, 10th to 90th percentile of the 5 s windows' medians 35.9 to 63.8 ms; 84 frames over 100 ms, 4 over 1 s (longest 2.6 s). `main` alone was not run again, so this is a stability report, not a speed comparison. - 7 pictures over the run looked at: the scene is right in each (deck, water, under the pier). AI-assisted: yes (Claude Code; Claude Fable 5.2 directing, Claude Opus 5.5 for the update, reviewer Claude Opus).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3113:upstream-pr/3113'
git switch 'upstream-pr/3113'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3113'
git switch 'upstream-pr/3113'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3113'
git switch 'upstream-pr/3113'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3113'
git switch 'main'
git merge --squash 'upstream-pr/3113'
git switch 'main'
git merge --ff-only 'upstream-pr/3113'
git switch 'main'
git merge 'upstream-pr/3113'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3113
No description provided.