[PR #2117] d3d12: a console heap's V# words are fixed once a pass, not once a slot (RT-CONSOLE-VSHARP-MEMO) #2121

Open
opened 2026-11-26 21:20:07 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2117
Author: @azsekazvamdimitar
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: console-vsharp-memo


📝 Commits (1)

  • ecc72ee d3d12: a console heap's V# words are fixed once a pass, not once a slot (RT-CONSOLE-VSHARP-MEMO)

📊 Changes

2 files changed (+55 additions, -7 deletions)

View changed files

📝 runtime/shims/d3d12_vulkan_device.cpp (+45 -6)
📝 runtime/test/d3d12_unmapped_vsharp_test.cpp (+10 -1)

📄 Description

Claimed in the coordination issue as: RT-CONSOLE-VSHARP-MEMO (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7174972924)

What and why

After the story load, most of refresh_console_heap's time ("fixing copied slots" in its log line) goes to fix_vsharp on words the title repeats across thousands of slots of its console descriptor heap. Many are data that reads as a buffer V# into title memory with no copy: on my retail boot 3,000-27,000 of them a submission ("with no copy given no records"), most with identical words. Each one goes through vsharp_address into resolve_title_memory / resolve_pool_memory, which call VirtualQuery, and a failure adds no alias, so the next slot with the same words pays again. Under Wine VirtualQuery is slow: with LEONIDA_SAMPLE_MS=10 a third of the submitting thread's samples were VirtualQuery under fix_console_slot.

fix_heap_vsharp asks fix_vsharp once for each distinct V# (all four words) in a pass over a heap's slots and gives later slots with the same words the same answer. The answers last one pass: they are dropped after the pass over the copied slots, again after the invalidation pass (which runs because a buffer was released or an alias went), and are not used by the retries or the empty-slot probe. The log line gains "answered by an earlier slot of the pass".

The same retail boot, 900 s each, RTX 3090, GE-Proton, main db1a22d29 with #1851, #1957 and #1867, LEONIDA_ASYNC_PIPELINES=1, LEONIDA_TITLE_WATCHDOG=0, LEONIDA_TITLE_WINDOWS_MB/LEONIDA_ARENA_MB 4096, thread sampler on in both:

after the story load without with this pull request
heap refresh a submission (heaps in the submit-phase lines) 107.8 ms (max 5,332) 18.8 ms (max 1,109)
share of the submit wall time 31% 7%
submissions (from 120 s to 900 s) 1,977 2,527
presents in the run 4,929 5,614
device lost no no

One run each. The slot-133 shadow refresh (about 200-230 ms a submission) is now the larger cost; this doesn't touch it.

Tested

  • d3d12_unmapped_vsharp: its console heap already holds 128 identical unmapped V#s, which now take one answer between them. It gains a check that a slot written later with the words the first refresh had no copy for is fixed again once their alias exists: it fails when the answers are kept across refreshes, and passes with this change.
  • On this branch (rebased on main a73a57e13), cross-built with clang-cl: d3d12_unmapped_vsharp, d3d12_console_descriptor_heap and console_heap_vsharp_slots pass under WineHQ 11.22 (winewayland) and GE-Proton11-14 (winex11); console_heap_vsharp_slots passes natively on Linux.
  • The boot numbers are from the same change on db1a22d29. Not run on Windows.

GPUs tested: NVIDIA GeForce RTX 3090, driver 590.48.01, Debian 13 (Linux 6.12), Wine/Proton as above.

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2117 **Author:** [@azsekazvamdimitar](https://github.com/azsekazvamdimitar) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `console-vsharp-memo` --- ### 📝 Commits (1) - [`ecc72ee`](https://github.com/ubiquitarianism/leonida/commit/ecc72eef7198ba1bc01081ed1dede7a4771f1f0b) d3d12: a console heap's V# words are fixed once a pass, not once a slot (RT-CONSOLE-VSHARP-MEMO) ### 📊 Changes **2 files changed** (+55 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+45 -6) 📝 `runtime/test/d3d12_unmapped_vsharp_test.cpp` (+10 -1) </details> ### 📄 Description Claimed in the coordination issue as: RT-CONSOLE-VSHARP-MEMO (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7174972924) ### What and why After the story load, most of `refresh_console_heap`'s time ("fixing copied slots" in its log line) goes to `fix_vsharp` on words the title repeats across thousands of slots of its console descriptor heap. Many are data that reads as a buffer V# into title memory with no copy: on my retail boot 3,000-27,000 of them a submission ("with no copy given no records"), most with identical words. Each one goes through `vsharp_address` into `resolve_title_memory` / `resolve_pool_memory`, which call VirtualQuery, and a failure adds no alias, so the next slot with the same words pays again. Under Wine VirtualQuery is slow: with `LEONIDA_SAMPLE_MS=10` a third of the submitting thread's samples were VirtualQuery under `fix_console_slot`. `fix_heap_vsharp` asks `fix_vsharp` once for each distinct V# (all four words) in a pass over a heap's slots and gives later slots with the same words the same answer. The answers last one pass: they are dropped after the pass over the copied slots, again after the invalidation pass (which runs because a buffer was released or an alias went), and are not used by the retries or the empty-slot probe. The log line gains "answered by an earlier slot of the pass". The same retail boot, 900 s each, RTX 3090, GE-Proton, main db1a22d29 with #1851, #1957 and #1867, `LEONIDA_ASYNC_PIPELINES=1`, `LEONIDA_TITLE_WATCHDOG=0`, `LEONIDA_TITLE_WINDOWS_MB`/`LEONIDA_ARENA_MB` 4096, thread sampler on in both: | after the story load | without | with this pull request | |---|---|---| | heap refresh a submission (`heaps` in the submit-phase lines) | 107.8 ms (max 5,332) | 18.8 ms (max 1,109) | | share of the submit wall time | 31% | 7% | | submissions (from 120 s to 900 s) | 1,977 | 2,527 | | presents in the run | 4,929 | 5,614 | | device lost | no | no | One run each. The slot-133 shadow refresh (about 200-230 ms a submission) is now the larger cost; this doesn't touch it. ### Tested - `d3d12_unmapped_vsharp`: its console heap already holds 128 identical unmapped V#s, which now take one answer between them. It gains a check that a slot written later with the words the first refresh had no copy for is fixed again once their alias exists: it fails when the answers are kept across refreshes, and passes with this change. - On this branch (rebased on main a73a57e13), cross-built with clang-cl: `d3d12_unmapped_vsharp`, `d3d12_console_descriptor_heap` and `console_heap_vsharp_slots` pass under WineHQ 11.22 (winewayland) and GE-Proton11-14 (winex11); `console_heap_vsharp_slots` passes natively on Linux. - The boot numbers are from the same change on db1a22d29. Not run on Windows. GPUs tested: NVIDIA GeForce RTX 3090, driver 590.48.01, Debian 13 (Linux 6.12), Wine/Proton as above. AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#2121
No description provided.