Walking stalls of 0.5-0.7 s are CopyPageMappings remaps on leonida-alias (RX 7900 XT): could they be tile mappings on the card? #2848

Open
opened 2026-12-01 08:27:09 +00:00 by Yassan01 · 1 comment
Yassan01 commented 2026-12-01 08:27:09 +00:00 (Migrated from github.com)
Contributor

Imported from ubiquitarianism/leonida. Originally posted by Yassan01 on 2026-12-01T08:27:09Z.


Summary

Walking in the open world on an RX 7900 XT, most frames are 40-50 ms, but every few seconds a frame takes 0.2-1.5 s. With LEONIDA_TIMELINE + LEONIDA_TIMELINE_STALL_MS=300, the two stalls caught (518 ms and 677 ms) were almost entirely the leonida-alias thread in "page mappings behind the title's call", with the line of submissions waiting behind it. None of the existing mapping switches changed this measurably. This is a question more than a bug: could the title's page-mapping copies be done as tile mappings on the card instead of host view remaps?

Setup

  • AMD Radeon RX 7900 XT 20 GB (RDNA 3), driver 32.0.32029.2010, Resizable BAR on
  • Ryzen 7 5800X3D, 32 GB DDR4-3600, Windows 11 (build 26200), page file on an NVMe drive
  • d3d12 diag build (--features diagnostics,mimalloc) at 407f71a2, Series X profile, 2560x1440 output
  • Settings: the play-nvidia.ps1 Series X set (incl. LEONIDA_MAP_THREADS=1), plus LEONIDA_TWIN_BIAS=0, LEONIDA_DSTORAGE_IO=overlapped, LEONIDA_TEXTURE_BUDGET_MB=7168, LEONIDA_HELD_GREY=1, LEONIDA_NO_WATCHDOG=1, LEONIDA_SHADER_LOOP_LIMIT=4096
  • Every known pipeline warmed beforehand (leonida warm): 0.0 s of pipeline waits in these runs
  • Scene: from the save into the world, then a scripted walk (W / turn / W / jump / back) for about 4 minutes, with LEONIDA_AB phases of 2 s

What the stall traces show

Stall 1 (518 ms between two presents):

trigger interval of 517.92 ms: the chain it came out of, by cause
   477.70 ms  page mappings behind the title's call
    11.71 ms  ahead of a frame: the heap's buffer views
     7.58 ms  a landing's job
trigger chain by thread
   477.72 ms  "leonida-alias"
spans: 514.12 ms in 4, longest 458.81  page mappings behind the title's call
       420.45 ms in 2, longest 414.98  the line: waiting for page mappings

Stall 2 (677 ms):

   529.35 ms  page mappings behind the title's call
   114.25 ms  outside our spans on "leonida-alias"
trigger chain by thread
   643.66 ms  "leonida-alias"
spans: 532.59 ms in 8, longest 202.85  page mappings behind the title's call

The title remapped about 2,500-2,700 pages a second over a run (LEONIDA_ALIAS_SAME: 787,441 pages by 312 s, same=0, so none were already showing the page asked for).

What was tried (walking A/B, frames over 50 ms per 2 s phase)

  • LEONIDA_MAP_THREADS 8 against 1: 5.49 against 5.46, no difference
  • LEONIDA_ALIAS_CHUNK=0 against the default 16: 4.33 against 5.04 over two runs (282 phases); phases with a frame over 200 ms 7 against 6, so the long stalls stay
  • LEONIDA_WRITE_SITES (34 sites learned, 13 patched): no measurable change
  • LEONIDA_PAGE_ASK: 4.96 against 5.04, no difference; the title's write faults asked Windows about regions at most 14 times a frame (0.16 ms)

The idea

The comment on alias_behind in queue.rs says the title's CPU does not read the addresses these copies map (the GPU's side of its tiled heap), and the comment on side_by_side in xmem.rs says each host map or unmap waits for the address-space lock that the guards' protection changes also take (100,000 a second in the world). On the console the same call is a change of the GPU's page tables.

Could CopyPageMappingsBatchX destinations be backed by a reserved resource on the card, with the call turned into UpdateTileMappings on the queue in the title's order? The pool pages would then need to be in a heap of the card's (a CPU-visible one where Resizable BAR is on, so the title's and DirectStorage's writes into the pool land there). The open parts I can see: the texture refreshes that read title memory today, and what else reads the pool on the host. tiles.rs already gives reserved textures tiles on the queue, so some of the pieces may be there.

The trace .txt summaries and the logs are available if useful.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:6715919933 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/issues/2848). Originally posted by [Yassan01](https://github.com/Yassan01) on 2026-12-01T08:27:09Z. --- **Summary** Walking in the open world on an RX 7900 XT, most frames are 40-50 ms, but every few seconds a frame takes 0.2-1.5 s. With `LEONIDA_TIMELINE` + `LEONIDA_TIMELINE_STALL_MS=300`, the two stalls caught (518 ms and 677 ms) were almost entirely the `leonida-alias` thread in "page mappings behind the title's call", with the line of submissions waiting behind it. None of the existing mapping switches changed this measurably. This is a question more than a bug: could the title's page-mapping copies be done as tile mappings on the card instead of host view remaps? **Setup** - AMD Radeon RX 7900 XT 20 GB (RDNA 3), driver 32.0.32029.2010, Resizable BAR on - Ryzen 7 5800X3D, 32 GB DDR4-3600, Windows 11 (build 26200), page file on an NVMe drive - d3d12 `diag` build (`--features diagnostics,mimalloc`) at 407f71a2, Series X profile, 2560x1440 output - Settings: the play-nvidia.ps1 Series X set (incl. `LEONIDA_MAP_THREADS=1`), plus `LEONIDA_TWIN_BIAS=0`, `LEONIDA_DSTORAGE_IO=overlapped`, `LEONIDA_TEXTURE_BUDGET_MB=7168`, `LEONIDA_HELD_GREY=1`, `LEONIDA_NO_WATCHDOG=1`, `LEONIDA_SHADER_LOOP_LIMIT=4096` - Every known pipeline warmed beforehand (`leonida warm`): 0.0 s of pipeline waits in these runs - Scene: from the save into the world, then a scripted walk (W / turn / W / jump / back) for about 4 minutes, with `LEONIDA_AB` phases of 2 s **What the stall traces show** Stall 1 (518 ms between two presents): ``` trigger interval of 517.92 ms: the chain it came out of, by cause 477.70 ms page mappings behind the title's call 11.71 ms ahead of a frame: the heap's buffer views 7.58 ms a landing's job trigger chain by thread 477.72 ms "leonida-alias" spans: 514.12 ms in 4, longest 458.81 page mappings behind the title's call 420.45 ms in 2, longest 414.98 the line: waiting for page mappings ``` Stall 2 (677 ms): ``` 529.35 ms page mappings behind the title's call 114.25 ms outside our spans on "leonida-alias" trigger chain by thread 643.66 ms "leonida-alias" spans: 532.59 ms in 8, longest 202.85 page mappings behind the title's call ``` The title remapped about 2,500-2,700 pages a second over a run (`LEONIDA_ALIAS_SAME`: 787,441 pages by 312 s, `same=0`, so none were already showing the page asked for). **What was tried (walking A/B, frames over 50 ms per 2 s phase)** - `LEONIDA_MAP_THREADS` 8 against 1: 5.49 against 5.46, no difference - `LEONIDA_ALIAS_CHUNK=0` against the default 16: 4.33 against 5.04 over two runs (282 phases); phases with a frame over 200 ms 7 against 6, so the long stalls stay - `LEONIDA_WRITE_SITES` (34 sites learned, 13 patched): no measurable change - `LEONIDA_PAGE_ASK`: 4.96 against 5.04, no difference; the title's write faults asked Windows about regions at most 14 times a frame (0.16 ms) **The idea** The comment on `alias_behind` in `queue.rs` says the title's CPU does not read the addresses these copies map (the GPU's side of its tiled heap), and the comment on `side_by_side` in `xmem.rs` says each host map or unmap waits for the address-space lock that the guards' protection changes also take (100,000 a second in the world). On the console the same call is a change of the GPU's page tables. Could `CopyPageMappingsBatchX` destinations be backed by a reserved resource on the card, with the call turned into `UpdateTileMappings` on the queue in the title's order? The pool pages would then need to be in a heap of the card's (a CPU-visible one where Resizable BAR is on, so the title's and DirectStorage's writes into the pool land there). The open parts I can see: the texture refreshes that read title memory today, and what else reads the pool on the host. `tiles.rs` already gives reserved textures tiles on the queue, so some of the pieces may be there. The trace `.txt` summaries and the logs are available if useful.
lixonik commented 2026-12-01 21:48:02 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-01T21:48:02Z.


Independent walking-stall comparison point on NVIDIA + Windows 10 (MEASURED):

Setup

  • Hardware / OS: NVIDIA GeForce RTX 5070 12 GB (driver 621.40), Ryzen 9 5950X (16C/32T), 64 GiB RAM, Windows 10 Pro 22H2 (build 19045).
  • Build & settings: diag profile (diagnostics,dlss,mimalloc) at main 1e3e316c5, Series X profile, -NoFrameGen, default play-nvidia.ps1 flags (including LEONIDA_MAP_THREADS=1, LEONIDA_ALIAS_DIRECT=1), plus LEONIDA_TIMELINE_STALL_MS=200, LEONIDA_TIMELINE_AT=195, LEONIDA_ALIAS_SAME=1, and scripted walking (LEONIDA_KEYS alternating W / turn / W over ~160 s in the world; 32 world frame samples, median 20.9 fps / 47.8 ms, 3,456 median / 7,819 max draws, gpu_wait 0.0 ms, 0 errors / 0 device lost).

Measurements

  1. LEONIDA_ALIAS_SAME confirms the exact same same=0 pattern:
    • By the end of the ~160 s walk: calls=2,048, pages=342,760, same=0 (matching the 0% already-mapped rate observed on RX 7900 XT).
  2. leonida-alias per-frame cost was much smaller here than the 477--529 ms stalls seen on Win11 / RX 7900 XT:
    • Across 170 one-second queue::behind (LEONIDA_ALIAS_LATER) samples (142 non-zero): peak was 8.7 batches/frame and 33.2 ms/frame (top 5 samples: 33.2, 25.5, 22.9, 18.1, 12.7 ms/frame; the runtime's changes of mapping per frame peaked around 25.2 with 2.12 ms holding title memory still, longest 1.61 ms).
  3. Captured walking stall (LEONIDA_TIMELINE_STALL_MS=200):
    • Trigger interval: 208.49 ms (retained ring coverage 1,910.92 ms; 65,536 events retained; partial completeness).
    • Top causes in the trigger chain:
      • 113.04 ms -- ahead of a frame: textures picked by index ("leonida-ahead-textures", 115.84 ms on thread)
      • 34.71 ms -- streaming: reading the source (dstorage threads)
      • 11.34 ms -- submit: the lists' steps ("leonida-submit", 23.58 ms on thread)
      • 10.17 ms -- a copy's refresh + 8.51 ms -- a texture's refresh ("leonida-wide-*")
      • 2.68 ms -- kernel: VirtualFree, 2.19 ms -- kernel: GetWriteWatch, 0.43 ms -- kernel: VirtualProtect
    • In the same retained window, page mappings behind the title's call was only 8.35 ms across 2 spans (longest 5.91 ms), the title's CopyPageMappings was 0.12 ms across 2 spans, and the title's XMemMapPhysicalPages was 16.71 ms across 1,444 spans (longest 0.78 ms).
    • Note: one later 1,283.5 ms sample (0.8 fps, 7,819 draws) occurred after the one-shot stall capture had already fired; in that window leonida-alias was 3.4 batches / 1.9 ms/frame, while recording reported 122.0 ms waiting for pipelines (pipelines were not pre-warmed with leonida warm before this run).

Takeaway for #2848

  • The same=0 remap volume (~2,100+ pages/s during scripted walking) reproduces identically across vendors/OS, so reducing host remap work (or moving destinations to GPU UpdateTileMappings) still targets a real, universal workload.
  • However, the extreme 0.5--0.7 s single-call spikes on leonida-alias did not appear in this Windows 10 22H2 + LEONIDA_ALIAS_DIRECT=1 run (peaking at 33.2 ms/frame instead of 477--529 ms), suggesting OS memory-manager / address-space lock behavior (Windows 11 build 26200 vs Windows 10 build 19045) or LEONIDA_ALIAS_DIRECT may amplify those long tail spikes.

AI-assisted: Antigravity

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7326799714 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/issues/2848#issuecomment-7326799714). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-01T21:48:02Z. --- Independent walking-stall comparison point on NVIDIA + Windows 10 (`MEASURED`): ### Setup - **Hardware / OS:** NVIDIA GeForce RTX 5070 12 GB (driver `621.40`), Ryzen 9 5950X (16C/32T), 64 GiB RAM, Windows 10 Pro 22H2 (build 19045). - **Build & settings:** `diag` profile (`diagnostics,dlss,mimalloc`) at `main` `1e3e316c5`, Series X profile, `-NoFrameGen`, default `play-nvidia.ps1` flags (including `LEONIDA_MAP_THREADS=1`, `LEONIDA_ALIAS_DIRECT=1`), plus `LEONIDA_TIMELINE_STALL_MS=200`, `LEONIDA_TIMELINE_AT=195`, `LEONIDA_ALIAS_SAME=1`, and scripted walking (`LEONIDA_KEYS` alternating W / turn / W over ~160 s in the world; 32 world frame samples, median 20.9 fps / 47.8 ms, 3,456 median / 7,819 max draws, `gpu_wait 0.0 ms`, 0 errors / 0 device lost). ### Measurements 1. **`LEONIDA_ALIAS_SAME` confirms the exact same `same=0` pattern:** - By the end of the ~160 s walk: `calls=2,048`, `pages=342,760`, **`same=0`** (matching the 0% already-mapped rate observed on RX 7900 XT). 2. **`leonida-alias` per-frame cost was much smaller here than the 477--529 ms stalls seen on Win11 / RX 7900 XT:** - Across 170 one-second `queue::behind` (`LEONIDA_ALIAS_LATER`) samples (142 non-zero): peak was **`8.7` batches/frame** and **`33.2` ms/frame** (top 5 samples: `33.2`, `25.5`, `22.9`, `18.1`, `12.7` ms/frame; `the runtime's changes of mapping per frame` peaked around `25.2` with `2.12 ms` holding title memory still, longest `1.61 ms`). 3. **Captured walking stall (`LEONIDA_TIMELINE_STALL_MS=200`):** - Trigger interval: **208.49 ms** (retained ring coverage 1,910.92 ms; 65,536 events retained; partial completeness). - Top causes in the trigger chain: - `113.04 ms` -- `ahead of a frame: textures picked by index` (`"leonida-ahead-textures"`, `115.84 ms` on thread) - `34.71 ms` -- `streaming: reading the source` (`dstorage` threads) - `11.34 ms` -- `submit: the lists' steps` (`"leonida-submit"`, `23.58 ms` on thread) - `10.17 ms` -- `a copy's refresh` + `8.51 ms` -- `a texture's refresh` (`"leonida-wide-*"`) - `2.68 ms` -- `kernel: VirtualFree`, `2.19 ms` -- `kernel: GetWriteWatch`, `0.43 ms` -- `kernel: VirtualProtect` - In the same retained window, `page mappings behind the title's call` was only **`8.35 ms` across 2 spans (longest `5.91 ms`)**, `the title's CopyPageMappings` was `0.12 ms` across 2 spans, and `the title's XMemMapPhysicalPages` was `16.71 ms` across 1,444 spans (longest `0.78 ms`). - Note: one later 1,283.5 ms sample (`0.8 fps`, `7,819` draws) occurred after the one-shot stall capture had already fired; in that window `leonida-alias` was `3.4 batches / 1.9 ms/frame`, while recording reported `122.0 ms waiting for pipelines` (pipelines were not pre-warmed with `leonida warm` before this run). ### Takeaway for #2848 - The `same=0` remap volume (~2,100+ pages/s during scripted walking) reproduces identically across vendors/OS, so reducing host remap work (or moving destinations to GPU `UpdateTileMappings`) still targets a real, universal workload. - However, the extreme 0.5--0.7 s single-call spikes on `leonida-alias` did **not** appear in this Windows 10 22H2 + `LEONIDA_ALIAS_DIRECT=1` run (peaking at `33.2 ms/frame` instead of `477--529 ms`), suggesting OS memory-manager / address-space lock behavior (Windows 11 build 26200 vs Windows 10 build 19045) or `LEONIDA_ALIAS_DIRECT` may amplify those long tail spikes. AI-assisted: Antigravity
Sign in to join this conversation.
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#2848
No description provided.