RT-STREAM-POOL-KEEP-VA-ALIASES: preserve live mappings when mirroring stream pools #1920
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1920"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-25T15:48:24Z.
Claimed in the coordination issue as: RT-STREAM-POOL-KEEP-VA-ALIASES
What and why
A stream-pool extent was checked for an existing mapping at its first byte. A live mapping could start later on either side of the pair. Publishing the entire extent then evicted that mapping, even if the new request only needed the free area before it. The runtime now limits new extents to the intersection of the CPU and GPU gaps. Registration checks both sides under one lock and publishes the pair together. Reusing the other view's mapping also stops at the next live range.
If a competing mapping appears while the copy is allocated, that mapping takes precedence. The unused backing follows the device's existing allocation lifetime.
This is on the stream-pool path reported during world start. The effect on a retail boot has not been measured.
Tested
title_va_alias_test,title_window_plan_testandtitle_window_plan_bounds_testpassed. The new overlap assertion failed against the original alias table.title_va_alias_testandtitle_window_plan_bounds_testpassed.python -I -B scripts/run_semantic_tests.py tests/semantic: 6,261 tests across 489 files, zero failures.GPUs tested: n/a (synthetic CPU tests)
AI-assisted.
Checklist
mainand merges cleanly.Imported from ubiquitarianism/leonida. Originally posted by GGandCo on 2026-11-25T16:32:14Z.
Native Windows/Intel verification of #1920 (7cb696200) together with #1926, on main
b0f3d3998plus local integration fixes:Combined integration, not an isolated A/B of this PR. No successful retail load or performance improvement claimed. The full existing_heap fixture still has a pre-existing first-render-target device-loss failure on this Intel setup, reproduced before these changes; the focused cases above were run separately. No game data included. AI-assisted with OpenAI Codex.
Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-27T06:08:22Z.
Retail data for this path, from the RT-TITLE-WINDOW-RETIRE work (RTX 5080, NVIDIA 621.24, Windows 11,
maind1dff7949plus a local diagnostic that counts windows; AI-assisted, Claude Code). It supports the bug this PR fixes, and it shows one more thing the bounding needs.The bug, measured. 15-minute run with
main's stream-pool path: 4,534 window-backed pool extents, about 2.9 GB in total but only about 1.5 GB of distinct pages; 2,887 overlapped an earlier extent and 2,501 (about 1.6 GB) were orphaned: no alias range answered from them, yet each was still refreshed every submission and charged to the window budget. Only 1 pool request in the run was served by an existing mapping.What bounding alone does. With extents bounded by the free span in both views (the same rule as this PR), overlaps and orphans went to 0, but a request whose bytes run past the free span gets a mapping shorter than itself:
resolve_pool_memorynever checks that the extent covers[va, va + bytes)(bytesis only logged). A V# then becomes a zero-size view (vsharp_addressrefusesroom < bytes), and a root view (resolved withkRootViewBytes, 64 KiB) reads and writes past its copy into whatever the arena holds next. Our first build with bounding died at about 160 s with title read faults (it also had a second bug of ours, in retirement, so the two causes were not separated).What held. Giving such a request one mapping over the request plus every window it reaches (each taken whole, in both views, the replaced windows retired after the next submission), and having
TitleVaAliases::resolve/vsharp_addressgo back to the resolver when the range holding a view's first byte ends before the view does: two 20-minute runs into the world, no fault; 0 overlapping, 0 orphaned windows; about 4,100 windows retired, about 3 GB returned.That work is on
DadaCap/leonida:window-orphans(not opened as a PR, to avoid overlapping this one). It also retires windows that other paths orphan (a slot-133 buffer placed over a window) and keeps a retired window's GPU writes going back to the title. @lixonik, would you rather take the cover part into this PR, or have me open mine on top of yours withDepends on: #1920? I'll go with whichever you prefer. This PR currently shows a conflict withmain.Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T08:37:02Z.
@DadaCap Thanks for measuring the overlaps and catching the short mapping. I rebased #1920 onto
d1dff7949and added a length check to both the pool reuse and allocation paths ind78b0e90a. A request that cannot be backed for its full length now fails through the existing unbacked-view path and leaves both live aliases intact.Please open
window-orphansas a follow-up withDepends on: #1920. Your seam-covering path needs the old windows to stay alive through their in-flight submissions and pending GPU write-back. Keeping the covering, retirement and write-back changes together in your PR also keeps your end-to-end regression with the code it exercises.On Windows 11 / MSVC with an RTX 5070 (610.88), all eight focused CTests passed, including the new synthetic seam cases and window write-back. The two portable tests also passed with GCC/UBSan. Vulkan validation layers were unavailable on this machine.
AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-27T08:53:12Z.
@lixonik thanks, will do. I'm porting the covering, retirement and write-back changes onto
d78b0e90anow (your bounding and length checks kept; the cover replaces the unbacked fallback only for a request that runs into existing windows, which it takes whole and retires after their in-flight submissions and write-back). It will open as a follow-up withDepends on: #1920after the full ctest and a retail run on top of your branch. AI-assisted (Claude Code).Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-27T13:04:08Z.
@lixonik the follow-up is open: #2465 (
Depends on: #1920, built on yourd78b0e90aunchanged). Your bounding and both length checks stay; the cover replaces the unbacked fallback only where a request runs into windows, which it takes whole and retires after their in-flight submissions and write-back. All your tests pass unchanged. AI-assisted (Claude Code).Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-27T17:42:02Z.
Short A/B of this PR against main on one machine: same recipe, same pipeline cache folder, only the runtime executable changes (my recipe-diff tool reports exactly one difference). n=1 per side. One run per side, so this is not conclusive.
Reading (marked):
Limits: one machine, one run per side, short recipe.
AI-assisted (Claude Code, Claude Opus 5.5)
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-27T18:30:34Z.
Follow-up to my RUN above, with more runs on the same machine (RTX 4060 8 GB, NVIDIA 610.88, Windows 11, main
ec91d695c, same short recipe and same warm cache folder):LEONIDA_SERIAL_BIG_COMPILESunset)(*) read from that run's log at 19:05 and also recorded by my stop guard; the log was later removed by a disk cleanup on my side.
Two later runs without #1920 also entered the world at 165 s. So the 30 s earlier world entry I reported for #1920 is within what this machine shows across runs, and I do not attribute it to the PR. The display stop is the same with and without #1920. n=1 per row; I have not repeated #1920 itself.
AI-assisted (Claude Code, Claude Opus 5.5)