Repository navigation
d3d12: slot-133 shadows guard aliased title pages at every address instead of copying them each submission (RT-SHADOW-ALIAS-GUARD) - #1867
Conversation
Independent verification — Turing and Blackwell
Environment
NVIDIA 621.14, Vulkan SDK 1.4.363.0, Three repetitions per GPU, revision and validation mode. Results
192 executions: 192 passed, 0 failed, 0 skipped. Findings
No regressions observed. The new alias-guard mechanism Retail workloads and comparative performance Synthetic tests only. No game files used. |
|
@azsekazvamdimitar thank you. I have the same numbers from a local version of the same idea: 1.1 GB aliased before every submission down to 15 MB, shadow phase 173 ms to 6 to 40 ms, 17,939 of 18,226 tiles settled (RTX 5080, Windows 11, 4 GiB window cap). Yours is claimed, so I will not open mine. Some points from building and reviewing it that may help #1867, from reading your diff (not run):
I can't say which of these matter on your machine. If a retail run of #1867 on this card would help, say so. AI-assisted (Claude Code). |
Independent test run: Windows 11, RTX 4060Head Setup
Results
The failures on head are
So: no regression in the 30 other tests, MutationThe The new test does fail without the change. The mutation was against the merge base, not current main, whose copy of the test file has moved on. In game (measured by OreoFR in game, not by me)RTX 4070 Laptop 8 GB, driver 621.40, main + #1849 + a local texture pass. At 140 s:
The wall at about 222 s is still there. I did not run the game and have not reproduced these numbers. AI-assisted: yes (Claude Code built and ran the tests) |
|
Measured on Windows 11 with an NVIDIA RTX 5090 (driver 32.0.16.2124), retail boot, runtime at the #1723 integration point with and without this PR, same settings and the same scripted input for both runs, read from the
No device loss or new fault in either run. AI-assisted: yes. |
|
I tested the alias guard patch on an Intel Xeon E5-2670 v3 with Fedora Linux 45, Wine 11.21 Staging and Lavapipe. The control was In the four late startup samples (63–78 seconds), the runtime reported:
Both runs reached PresentX and ended at the test time limit. The figures cover startup, with hardware rendering disabled. Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, Wine 11.21 Staging, Lavapipe. Retest on the current main branchI repeated the comparison on 61732ac with the same Wine and Lavapipe setup, a fresh overlay for each build and a 95-second limit. The tested rebase keeps the upstream stray read-only page diagnostics; the overlap was in the comment preceding that helper.
These are startup samples from the final 26 seconds. Both runs reached PresentX and ended at the time limit. Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, Wine 11.21 Staging, Mesa Lavapipe 26.2.7. |
|
Native Windows result with the game (the earlier numbers here were Wine). RTX 5060 Ti 16 GB, NVIDIA 621.01, Windows 10 19045, 32 GB RAM, own 1.0.2.1. Base: #2098 at 9f98dcc + #1592 merged with From the slot-133 refresh line, averaged over the submissions after the 4,000th (the world start):
I turned the D3D12 trace off in the same step, so the time column is not a clean A/B; the copied bytes are. n44 reached the opening cutscene's prompts and ran 585 s with no device loss. Two things I can't attribute and am not claiming are from this PR:
If you want a log line or a switch checked on this machine, say which. AI-assisted (Claude Code). |
3124ca8 to
ae0a95d
Compare
…stead of copying them each submission (RT-SHADOW-ALIAS-GUARD) A page xmem maps at two addresses was copied whole at every refresh, since a guard on one view doesn't fault a write through the other: about 1 GB a submission after the story load on a retail boot. ShadowPages now arms the geometry watch's cells of each aliased 64 KiB block at every address it is mapped and copies a block only when a cell's version moved. xmem tells the cells of a mapping change after updating the peers, and of list value writes made through the section. AI-assisted; tested under WineHQ 11.22 and GE-Proton11-14 on an RTX 3090 (NVIDIA 590.48.01).
ae0a95d to
49a0b69
Compare
One conflict, runtime/README.md: this branch rewrote the LEONIDA_SHADOW_ALIAS_MS row, main (ProjectLeonida#2163) added the LEONIDA_SHADOW_KEEP row after it. Both rows kept; the keep row's "aliased" now reads "aliased while they can't be guarded at every address", since aliased pages are no longer copied without a sign of a write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oo (RT-SHADOW-ALIAS-GUARD) check_aliased_guard covers the addresses known when the cells are first armed. This covers the later case: the page is guarded at A and B, then reported at C as well, with the cells' mapping moved at every address as xmem's note_mapping does once the peers are updated. The next submission must ask for the other addresses again and guard C, so a write through C faults and is copied at the submission after it. Without the re-ask in ShadowPages::update_aliased, C stays writable and the write through it is never copied. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merging.
Thanks @azsekazvamdimitar, and @Timon360SB, @MoonEyes, @x2Tweek, @gmankab, @Snooozs and @DadaCap for the runs and reviews. AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2) |
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
runtime/README.md: the console-heap rows come from the refill branch, the shadow rows from #1867. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…reads and writes those pages through the frame table (RT-MEMORY-MODEL) Step 2 of the memory model. After step 1 the console queue's CopyPageMappingsBatchX gave a paired GPU-only page its physical page by table, but still host-mapped the paired CPU page (the "twin") for the D3D12 layer and DirectStorage, which read and write GPU-only memory there: one unmap plus MapViewOfFile3 per page through Wine's server. In the newest local world run that was 47% of slot 31's pages and most of its 1.7-2.5 s of mapping per 10 s. By the log every host remap was such a twin (pages by table minus pages by host equals the twins the title mapped itself, which are kept); destinations with no CPU pair were none. Now the twin is a table page too (map_table_page), and the host reaches table pages through their frames: - src/title_frames.h: xmem's lookup (page -> its section's scratch view, held alive), its peers, monotonic bounds so other memory costs two loads, and for_each_part / run_end to split a range into table and host parts. - xmem: g_table_frames under its own SRW lock (readers never wait behind g_phys_mutex), g_page_tables per physical page. A table page is aliased, its alias peers being its physical page's host views (note_mapping keeps them in step), so #1867's alias cells guard it where the title's CPU can write it. The title's unmap of a table page now tells its readers. transfer_physical pins and notifies table pages too. - Readers: copy_guarded, texture_memory_readable, readable_page / readable_run_end (stream-pool extents), to_host_view, the ShadowPages walk and fill (a table page is read like a read-only page that is not the tracker's, clean while its cells are; a block with no host view anywhere is armed on its own cell), the geometry provider, the title buffers for vertex and index views, raw sampled surfaces, console value reads. - Writers: kernel_writes::write and store write the frame and pin its peers; read_file reads into a bounce buffer first. DirectStorage goes through these. - The slot-31 line keeps "pages N by table, M by host remap" and adds the paths behind them. Not through the table: imports (a table page has no host pages; such buffers are shadows), GPU write-back into a table page (left out like every aliased page; per-frame write-back is step 6), the LEONIDA_MAP_READBACK diagnostic, the fsdraw and compute-input probes (host pages only), the batch hook's LEONIDA_SLOT31_CPU_TWIN mirror (not installed in retail runs), and the title's own ReadFileEx/ReadFileScatter (the title has no CPU mapping there on the console). Tests: title_frames_test (portable); xmem_test copy_page_mappings_cpu_view (no host view at either page, no host map, reads and host writes through the frame, a write through the title's own mapping seen, remaps, kept twins, views replaced once); d3d12_xmem_placed queue_remap_default_route (slot-133 buffers over the GPU-only pages and the twin read them, a guarded title write through the pool's own mapping and a remap reach the GPU, no host remap). Linux ctest (llvmpipe) 119/119; Wine suite on the iGPU against main e5a7c89: no pass-to-fail (432 pass, the same 23 failures). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claimed in the coordination issue as: RT-SHADOW-ALIAS-GUARD (#1608 (comment))
What and why
The slot-133 shadows and title windows (
ShadowPages,runtime/shims/d3d12_vulkan_device.cpp) never guarded a page xmem maps at more than one address (title_page_aliases): a guard on one view doesn't fault a write through the other, so every refresh copied those pages whole. After the story load the stream pools make that the bulk of each submission. On my retail boot (main 0d80bc5, RTX 3090, GE-Proton,LEONIDA_TITLE_WATCHDOG=0) the by-cause line read about 987 MB aliased, 7 MB guarded and 2.4 MB pinned a submission, about 300 ms of each one, and the title presented about 0.3 frames a second.LEONIDA_SHADOW_ALIAS_MScan only make those copies older.This guards the aliased blocks at every address instead, with the geometry watch's cells (
runtime/src/title_geometry_watch.h), which the geometry views already use for the same problem:ShadowPages::update_aliased, at the start ofrefresh()and outside the tracker's lock, acquires a cell for each aliased 64 KiB block the copies read, at its own address and at each other addressgeometry_aliasesnames, and arms them (read-only at every address). A block whose cells kept their versions since they were armed is skipped by the walk; any other is armed again before the walk copies it, so a write after the arming is copied at the next refresh. A write through any address faults intoshadow_write_fault, which already notifies the geometry watch first; a remap, commit or protection change moves a cell's version too.armrefuses it), and in the refreshesLEONIDA_SHADOW_ALIAS_MSthrottles.note_mappingnow tells the cells of a mapping change after it updated the peers, so a watcher that sees the new mapping gets the new addresses;write_title_bytes(list value writes, through the section rather than the title's views) notifies the geometry watch, since no fault tells a guard of those writes.The same retail boot, after the story load:
LEONIDA_SHADOW_ALIAS_MS=3600000(aliased pages copied once: stale, an upper bound)All three runs end in the same world-start device loss, about 180-220 s after the story load starts (queue waits on memory nothing wrote, indirect draws not emitted, then
VK_ERROR_DEVICE_LOST). This pull request doesn't change that; it makes the loading screen run at a usable rate up to that point. No frames were captured that show a visible difference.Tested
d3d12_existing_heap_testgainscheck_aliased_guard: one page mapped at A and B (the test answersgeometry_writes::aliases) is read-only at both addresses between submissions, a write through an unreported third view stays stale (nothing was copied), a write through B faults and arrives with it, and both addresses are writable again after the shadow is released. The existingcheck_aliased_write, which has no other address to arm, still copies every time and passes.d3d12_existing_heap,d3d12_existing_heap_no_write_watch,d3d12_existing_heap_write_watch,d3d12_xmem_placed,d3d12_title_va,d3d12_title_va_shadowandxs_proxy_mockpass under both.xmemfails one check, "writing to 512 of them charges about those 512 pages", under Wine; it fails the same way on main without this change.GPUs tested: NVIDIA GeForce RTX 3090, driver 590.48.01, Debian 13 (Linux 6.12), Wine/Proton as above.
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.