Opt-in: end root-view windows where the title's mapped memory ends (no task claim) #45

Closed
github-bot wants to merge 0 commits from github-bot/gh-45 into main AGit
Owner

@⁠FeelsGoodMan2 on GitHub · 2026-12-02 19:00 UTC · original
FeelsGoodMan2:window-tails → main · +0 −0 · 0 files · 115 commits · closed without merging

Summary

  • Claimed Task ID: none. This is not a roadmap task and it touches crates/vesper-gpu/src/shadow.rs, which ROADMAP.md lists in the Maintainer Active Queue. I am opening it anyway so the measurements and the patch are visible; close it if it is in the way, or tell me which task ID to file it under and I will rework it to fit.
  • What this PR changes: one setting, off unless set. Without it nothing changes.
    • VESPER_TAIL_MAPPED=1 (acts only together with VESPER_WINDOW_TAILS=1): a window of title memory made for an ask without a length (a root view) ends with the stretch of mapped views that holds the ask, on a 1 MiB grid, instead of at the end of its 4 MiB cell. When the title maps past such a window, the asks get a longer one. Every root-view bind (root_view, root_uav, root_srv_table) checks that its window holds the ask's mapped stretch and looks again if it does not.
  • Rebased onto v0.9.3 and made smaller. The branch is merged with main at v0.9.3. The second setting this PR used to carry (VESPER_DEAD_WINDOWS, a sweep that let go of windows over memory the title released) is removed: main lets go of windows over unmapped title memory itself now (evict_unmapped, the unmapped flag, mapped_idle_evictable), so the sweep would only duplicate it. descriptor.rs and descriptor/host.rs are no longer touched. The diff against main is 4 files, +747/-6.
  • One part goes against a rule of main, on purpose, and I can take it out. With the cut on, a short window that the title's mapping outgrew is let go once no list, heap pass or descriptor slot holds it (outgrown_let_go). main never lets go of a mapped window a shader wrote (mapped_idle_evictable), so without this such a window would stay for good after it was replaced by a longer one. In the runs below it let go of 25 to 33 windows (36 to 47 MB) a run, so its effect is small; say so if you would rather not have it.

Why

On v0.9.3 the copies of windows outside buffers are still the largest piece of host copies while driving on a 32 GB PC: 5.1 to 5.4 GB after about 3 minutes in the world in the two runs with the setting off. Root-view windows reach to the end of their cell, past what the title has mapped. This looks related to #3.

AI Assistance Disclosure

  • No AI coding tools were used
  • AI coding tools were used: Claude Code (Claude Fable 5.2 and Claude Opus 5.5) wrote the code, the tests and this description, and ran the measurements with me driving. I checked the picture by eye during the runs listed below; I have not reviewed every line by hand.

Benchmark Comparison

Hardware: RX 7800 XT 16 GB, 32 GB RAM. Build: diagnostics build (--profile diag --features diagnostics) of this branch merged with v0.9.3, not the release build. Profile: native 1440p, HW RT (2560x1440, render scale 1.0, hardware BVH on), the settings of the last launch script with the values the v0.9.3 README lists for its presets laid over them, VESPER_MESH_LAUNCH=0 as on RX 7000 cards; this is not the launcher's own preset file. Before = setting off, after = setting on, same binary, same save, route driven by hand, cache warmed, one run each, back to back without restarting the PC.

Metric Before (setting off) After (setting on)
Time in the world (s) 172 197
p50 FPS / ms 20.3 / 49.2 20.9 / 47.9
p95 Frame Time (ms) 96.5 88.3
p99 ms (1% Low FPS) 123.4 (8.1) 117.2 (8.5)
Frames >100 ms (%) 4.20 3.10
Max >100 ms Streak (s) 3.63 3.55
Peak Private RAM (MB) 30,710 29,642
Peak shared GPU memory (MB, nonlocal of shared_mem_breakdown) 6,134 4,712

At equal numbers of draws the median frame time is the same in both runs (35.6 / 44.3 / 50.2 / 58.5 / 80.2 ms off against 36.3 / 44.8 / 50.0 / 56.4 / 79.6 ms on, for frames with under 6,000, 6,000 to 8,000, 8,000 to 10,000, 10,000 to 12,000 and over 12,000 draws), so I read the small differences in the table as the route, not as a gain.

Memory at the end of each run (the runs are not equally long):

At the end Off (172 s) Off, earlier run (218 s) On (197 s)
Windows outside buffers (MB) 5,373 5,052 3,559
Host copies of title memory (MB) 8,310 7,984 6,491
Shared GPU memory, nonlocal (MB) 6,134 5,862 4,541
Private (MB) 30,710 31,406 29,495
Working set (MB) 20,245 20,859 22,805
Free physical memory (MB) 1,282 616 656

The "earlier run" with the setting off is listed for memory only: it was the first run after the cache was made and loaded its pipelines during play (p50 17.4 FPS), so its frame times do not compare.

With the setting on, the diagnostics line at the end of the run read: 1,517 windows cut, 2,251 MB left out; 2,455 times outgrown by what the title mapped, 25 outgrown windows let go (38 MB); windows too short for their stretch: 0 at first lookup, 0 after looking again, 0 in a list's slot cache.

Three more runs with the setting on, same binary, profile, save and route, made after a restart of the PC (so not back to back with the runs above): 218, 239 and 246 s in the world, p50 19.3 / 20.7 / 20.5 FPS, p95 98.6 / 89.5 / 90.9 ms, p99 121.7 / 117.5 / 112.0 ms, 4.67 / 2.99 / 2.96 % of frames over 100 ms. Their diagnostics lines: 2,061 / 1,935 / 1,959 windows cut, 2,901 / 2,786 / 2,823 MB left out, 33 / 28 / 25 outgrown windows let go.

Because the runs differ in length, here is memory at the same time since entering the world, as the range over the runs (2 with the setting off, 4 with it on; at 215 s 1 off and 3 on):

Time in the world Windows outside buffers (MB), off on Private (MB), off on Shared GPU memory (MB), off on
60 s 4,090 to 4,389 2,742 to 3,025 28,019 to 28,347 26,719 to 27,510 4,520 to 5,248 3,508 to 3,888
120 s 3,238 to 4,347 2,098 to 3,158 28,108 to 28,906 26,890 to 28,577 3,907 to 5,185 2,974 to 3,989
170 s 4,304 to 5,223 3,049 to 3,657 30,137 to 30,443 28,632 to 29,246 4,981 to 6,080 3,937 to 4,518
215 s 5,214 3,559 to 4,667 31,232 29,577 to 30,837 6,099 4,594 to 5,703

So at the same time in the world the runs with the setting on hold, on average, 1.1 to 1.5 GB less in windows, 1.0 to 1.4 GB less shared GPU memory and 0.9 to 1.4 GB less private memory, with frame times unchanged. Memory keeps growing with time in the world in both cases: the longer runs with the setting on end with a private peak of 30.9 to 31.1 GB. Free physical memory did not go up and the working set is larger with the setting on (at 170 s: 21.8 to 24.2 GB on against 18.2 to 20.0 GB off). I have not found out why; the PC is at its limit in every run, so the system may be leaving in memory what it would otherwise trim from the process, but I did not measure that.

What went wrong on the way, and what is not verified

  • Shader-written state when a window is outgrown. If a root unordered view wrote into a short window and those writes were not copied back to title memory, the longer window that replaces it is filled from title memory and does not have them. main's own tails mode has the same property; the cut makes outgrowing more frequent (2,455 to 3,503 times a run). I saw nothing wrong in the picture, by eye.
  • The first run of plain v0.9.3 on a new cache spent its first two minutes at about 2 FPS; the following runs did not. I took that as first-run loading and did not look further.

Mandatory Verification Checklist

  • Diff obeys AGENTS.md, stays inside claimed VSP-XX files, and avoids the Maintainer Active Queue (ROADMAP.md) — no: no claim, and shadow.rs is in the Maintainer Active Queue (see Summary)
  • cargo xtask policy and cargo test -p xtask --locked pass cleanly (asset policy: 334 files ok; xtask: 9 passed)
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings passes with 0 warnings — no, and not because of this PR: on my PC cargo clippy -p vesper-gpu --all-targets --locked -- -D warnings fails on plain main at v0.9.3 with 7 lints in host.rs, descriptor/host.rs, host/gpu_timings.rs and pool.rs, and fails with the same 7 on this branch; none is in a file this PR touches. The CI Clippy job on this PR reports those 7 and line 830 of crates/vesper-loader/src/pc_prompts.rs; the same job fails on main at v0.9.3 too, where its log shows pc_prompts.rs line 830.
  • cargo xtask test-fast and cargo test --workspace --locked -- --test-threads=1 pass — cargo xtask test-fast passes; the whole-workspace run I did not do, and the vesper-gpu tests do not get through in one process on my PC, with or without this PR: cargo test -p vesper-gpu --locked --lib -- --test-threads=1 ends with an access violation (0xc0000005) in texback::tests::texture_readback_reuses_the_buffer_only_after_the_list_resets, on plain main at v0.9.3 (513 tests pass before it) and on this branch (522 pass before it; the 9 more are this PR's tests). That test passes when run alone, and with it skipped the run ends the same way a few tests later, in texture::ahead::tests::a_placed_texture_is_filled_ahead_of_the_lists. Run one module per process, every vesper-gpu test passes on this branch: 622 passed, 35 ignored, 0 failed (670 / 35 / 0 with --features diagnostics); plain v0.9.3 run the same way: 613 / 35 / 0. In CI the test jobs stop at warm_bad_fingerprint_override_again_and_help in apps/vesper, as they do on main at v0.9.3, before they reach this crate.
  • Safety gates remain enabled (VESPER_WAIT_RESIDENT=textures, indirect clamping intact) and steady-state visuals are verified clean (by eye, in the runs above)
  • Contains zero proprietary assets, keys, dumps, screenshots, or third-party studio/franchise names
  • Ready for 3 independent peer reviews — open for review; "What went wrong on the way, and what is not verified" above lists what is still missing

🤖 Generated with Claude Code

**@⁠FeelsGoodMan2** on GitHub · 2026-12-02 19:00 UTC · [original](https://github.com/monte-alt/vesper/pull/45) `FeelsGoodMan2:window-tails` → `main` · +0 −0 · 0 files · 115 commits · closed without merging ## Summary - **Claimed Task ID:** none. This is not a roadmap task and it touches `crates/vesper-gpu/src/shadow.rs`, which `ROADMAP.md` lists in the Maintainer Active Queue. I am opening it anyway so the measurements and the patch are visible; close it if it is in the way, or tell me which task ID to file it under and I will rework it to fit. - **What this PR changes:** one setting, **off unless set**. Without it nothing changes. - `VESPER_TAIL_MAPPED=1` (acts only together with `VESPER_WINDOW_TAILS=1`): a window of title memory made for an ask without a length (a root view) ends with the stretch of mapped views that holds the ask, on a 1 MiB grid, instead of at the end of its 4 MiB cell. When the title maps past such a window, the asks get a longer one. Every root-view bind (`root_view`, `root_uav`, `root_srv_table`) checks that its window holds the ask's mapped stretch and looks again if it does not. - **Rebased onto `v0.9.3` and made smaller.** The branch is merged with `main` at `v0.9.3`. The second setting this PR used to carry (`VESPER_DEAD_WINDOWS`, a sweep that let go of windows over memory the title released) is **removed**: `main` lets go of windows over unmapped title memory itself now (`evict_unmapped`, the `unmapped` flag, `mapped_idle_evictable`), so the sweep would only duplicate it. `descriptor.rs` and `descriptor/host.rs` are no longer touched. The diff against `main` is 4 files, +747/-6. - **One part goes against a rule of `main`, on purpose, and I can take it out.** With the cut on, a short window that the title's mapping outgrew is let go once no list, heap pass or descriptor slot holds it (`outgrown_let_go`). `main` never lets go of a mapped window a shader wrote (`mapped_idle_evictable`), so without this such a window would stay for good after it was replaced by a longer one. In the runs below it let go of 25 to 33 windows (36 to 47 MB) a run, so its effect is small; say so if you would rather not have it. ### Why On `v0.9.3` the copies of windows outside buffers are still the largest piece of host copies while driving on a 32 GB PC: 5.1 to 5.4 GB after about 3 minutes in the world in the two runs with the setting off. Root-view windows reach to the end of their cell, past what the title has mapped. This looks related to #3. ## AI Assistance Disclosure - [ ] No AI coding tools were used - [x] AI coding tools were used: Claude Code (Claude Fable 5.2 and Claude Opus 5.5) wrote the code, the tests and this description, and ran the measurements with me driving. I checked the picture by eye during the runs listed below; I have not reviewed every line by hand. ## Benchmark Comparison Hardware: RX 7800 XT 16 GB, 32 GB RAM. Build: **diagnostics build** (`--profile diag --features diagnostics`) of this branch merged with `v0.9.3`, not the release build. Profile: **native 1440p, HW RT** (2560x1440, render scale 1.0, hardware BVH on), the settings of the last launch script with the values the `v0.9.3` README lists for its presets laid over them, `VESPER_MESH_LAUNCH=0` as on RX 7000 cards; this is not the launcher's own preset file. Before = setting off, after = setting on, same binary, same save, route driven by hand, cache warmed, one run each, back to back without restarting the PC. | Metric | Before (setting off) | After (setting on) | |---|---:|---:| | Time in the world (s) | 172 | 197 | | p50 FPS / ms | 20.3 / 49.2 | 20.9 / 47.9 | | p95 Frame Time (ms) | 96.5 | 88.3 | | p99 ms (1% Low FPS) | 123.4 (8.1) | 117.2 (8.5) | | Frames >100 ms (%) | 4.20 | 3.10 | | Max >100 ms Streak (s) | 3.63 | 3.55 | | Peak Private RAM (MB) | 30,710 | 29,642 | | Peak shared GPU memory (MB, `nonlocal` of `shared_mem_breakdown`) | 6,134 | 4,712 | At equal numbers of draws the median frame time is the same in both runs (35.6 / 44.3 / 50.2 / 58.5 / 80.2 ms off against 36.3 / 44.8 / 50.0 / 56.4 / 79.6 ms on, for frames with under 6,000, 6,000 to 8,000, 8,000 to 10,000, 10,000 to 12,000 and over 12,000 draws), so I read the small differences in the table as the route, not as a gain. Memory at the end of each run (the runs are not equally long): | At the end | Off (172 s) | Off, earlier run (218 s) | On (197 s) | |---|---:|---:|---:| | Windows outside buffers (MB) | 5,373 | 5,052 | 3,559 | | Host copies of title memory (MB) | 8,310 | 7,984 | 6,491 | | Shared GPU memory, `nonlocal` (MB) | 6,134 | 5,862 | 4,541 | | Private (MB) | 30,710 | 31,406 | 29,495 | | Working set (MB) | 20,245 | 20,859 | 22,805 | | Free physical memory (MB) | 1,282 | 616 | 656 | The "earlier run" with the setting off is listed for memory only: it was the first run after the cache was made and loaded its pipelines during play (p50 17.4 FPS), so its frame times do not compare. With the setting on, the diagnostics line at the end of the run read: 1,517 windows cut, 2,251 MB left out; 2,455 times outgrown by what the title mapped, 25 outgrown windows let go (38 MB); windows too short for their stretch: 0 at first lookup, 0 after looking again, 0 in a list's slot cache. **Three more runs with the setting on**, same binary, profile, save and route, made after a restart of the PC (so not back to back with the runs above): 218, 239 and 246 s in the world, p50 19.3 / 20.7 / 20.5 FPS, p95 98.6 / 89.5 / 90.9 ms, p99 121.7 / 117.5 / 112.0 ms, 4.67 / 2.99 / 2.96 % of frames over 100 ms. Their diagnostics lines: 2,061 / 1,935 / 1,959 windows cut, 2,901 / 2,786 / 2,823 MB left out, 33 / 28 / 25 outgrown windows let go. Because the runs differ in length, here is memory at the same time since entering the world, as the range over the runs (2 with the setting off, 4 with it on; at 215 s 1 off and 3 on): | Time in the world | Windows outside buffers (MB), off | on | Private (MB), off | on | Shared GPU memory (MB), off | on | |---|---:|---:|---:|---:|---:|---:| | 60 s | 4,090 to 4,389 | 2,742 to 3,025 | 28,019 to 28,347 | 26,719 to 27,510 | 4,520 to 5,248 | 3,508 to 3,888 | | 120 s | 3,238 to 4,347 | 2,098 to 3,158 | 28,108 to 28,906 | 26,890 to 28,577 | 3,907 to 5,185 | 2,974 to 3,989 | | 170 s | 4,304 to 5,223 | 3,049 to 3,657 | 30,137 to 30,443 | 28,632 to 29,246 | 4,981 to 6,080 | 3,937 to 4,518 | | 215 s | 5,214 | 3,559 to 4,667 | 31,232 | 29,577 to 30,837 | 6,099 | 4,594 to 5,703 | So at the same time in the world the runs with the setting on hold, on average, 1.1 to 1.5 GB less in windows, 1.0 to 1.4 GB less shared GPU memory and 0.9 to 1.4 GB less private memory, with frame times unchanged. Memory keeps growing with time in the world in both cases: the longer runs with the setting on end with a private peak of 30.9 to 31.1 GB. **Free physical memory did not go up and the working set is larger with the setting on** (at 170 s: 21.8 to 24.2 GB on against 18.2 to 20.0 GB off). I have not found out why; the PC is at its limit in every run, so the system may be leaving in memory what it would otherwise trim from the process, but I did not measure that. ### What went wrong on the way, and what is not verified - **Shader-written state when a window is outgrown.** If a root unordered view wrote into a short window and those writes were not copied back to title memory, the longer window that replaces it is filled from title memory and does not have them. `main`'s own tails mode has the same property; the cut makes outgrowing more frequent (2,455 to 3,503 times a run). I saw nothing wrong in the picture, by eye. - The first run of plain `v0.9.3` on a new cache spent its first two minutes at about 2 FPS; the following runs did not. I took that as first-run loading and did not look further. ## Mandatory Verification Checklist - [ ] Diff obeys `AGENTS.md`, stays inside claimed `VSP-XX` files, and avoids the Maintainer Active Queue (`ROADMAP.md`) — **no: no claim, and `shadow.rs` is in the Maintainer Active Queue (see Summary)** - [x] `cargo xtask policy` and `cargo test -p xtask --locked` pass cleanly (asset policy: 334 files ok; xtask: 9 passed) - [ ] `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` passes with 0 warnings — **no, and not because of this PR:** on my PC `cargo clippy -p vesper-gpu --all-targets --locked -- -D warnings` fails on plain `main` at `v0.9.3` with 7 lints in `host.rs`, `descriptor/host.rs`, `host/gpu_timings.rs` and `pool.rs`, and fails with the same 7 on this branch; none is in a file this PR touches. The CI Clippy job on this PR reports those 7 and line 830 of `crates/vesper-loader/src/pc_prompts.rs`; the same job fails on `main` at `v0.9.3` too, where its log shows `pc_prompts.rs` line 830. - [ ] `cargo xtask test-fast` and `cargo test --workspace --locked -- --test-threads=1` pass — **`cargo xtask test-fast` passes; the whole-workspace run I did not do, and the `vesper-gpu` tests do not get through in one process on my PC, with or without this PR:** `cargo test -p vesper-gpu --locked --lib -- --test-threads=1` ends with an access violation (`0xc0000005`) in `texback::tests::texture_readback_reuses_the_buffer_only_after_the_list_resets`, on plain `main` at `v0.9.3` (513 tests pass before it) and on this branch (522 pass before it; the 9 more are this PR's tests). That test passes when run alone, and with it skipped the run ends the same way a few tests later, in `texture::ahead::tests::a_placed_texture_is_filled_ahead_of_the_lists`. Run one module per process, every `vesper-gpu` test passes on this branch: 622 passed, 35 ignored, 0 failed (670 / 35 / 0 with `--features diagnostics`); plain `v0.9.3` run the same way: 613 / 35 / 0. In CI the test jobs stop at `warm_bad_fingerprint_override_again_and_help` in `apps/vesper`, as they do on `main` at `v0.9.3`, before they reach this crate. - [x] Safety gates remain enabled (`VESPER_WAIT_RESIDENT=textures`, indirect clamping intact) and steady-state visuals are verified clean (by eye, in the runs above) - [x] Contains zero proprietary assets, keys, dumps, screenshots, or third-party studio/franchise names - [ ] Ready for **3 independent peer reviews** — open for review; "What went wrong on the way, and what is not verified" above lists what is still missing 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A window of title memory made for an ask without a length (a root view)
reached to the end of its 4 MiB cell whatever was mapped there. With
VESPER_TAIL_MAPPED=1 it ends with the stretch of views that holds the
ask, on a 1 MiB grid, and is replaced by a longer one when the title
maps past it. Every root-view bind checks that its window holds the
ask's stretch and looks again if it does not.

With VESPER_DEAD_WINDOWS=1 windows over memory the title has released
are let go: the slots that still view them are made null and made again
if the memory comes back.

Both are off unless set; nothing changes without them.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 19:17:09 +00:00
With VESPER_DEAD_WINDOWS=1 a slot's view asked for just before the title
mapped its memory was refused a window and read nothing until the next
sweep; with hardware ray tracing that stopped the card on entering the
world in the release build. Asks are now refused only inside the range
of a window the sweep let go, and when the title maps such memory again
its slots are made again before the next submission.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Conflicts in draw.rs (root_uav): main's uav_capable() check kept, with
the branch's root_slots_fresh() call and find_root at the bind.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Since v0.9.2 main changed the window code and lets go of windows over
unmapped title memory itself (evict_unmapped, the unmapped flag,
mapped_idle_evictable). The conflict is resolved by keeping what this
branch still adds and dropping what main now covers:

- kept: VESPER_TAIL_MAPPED (root-view windows end where the title's
  mapped memory ends), the check that a root view's window reaches its
  mapped stretch, the per-thread lookup fix, their tests and the
  diagnostics line;
- dropped: the dead-window sweep (VESPER_DEAD_WINDOWS) with its
  descriptor-slot hooks; descriptor.rs and descriptor/host.rs are main's
  again;
- added: with the cut on, a short window that the title's mapping
  outgrew is let go once nothing holds it, because main no longer lets
  go of a mapped window a shader wrote.

The cut stays opt-in and off by default.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot closed this pull request 2026-12-05 07:57:29 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.