d3d12: track live console-heap V# slots in a host-RAM bitset (RT-CONSOLE-HEAP-VSHARP-BITSET) #1887
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1887
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1887/head"
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?
@IlyassRS3 on GitHub · 2026-11-25 14:30 UTC · original
IlyassRS3:rt-console-heap-vsharp-bitset→main· +392 −9 · 4 files · 1 commits · merged 2026-11-25 19:06 UTCItem:
RT-CONSOLE-HEAP-VSHARP-BITSETClaim: #1608
Summary
Eliminates uncached write-combined GPU memory reads from
heap.copyduring console resource-heap invalidation scans inrefresh_console_heap()(runtime/shims/d3d12_vulkan_device.cpp).released_backingsortitle_va_aliases().invalidations()advanced,refresh_console_heap()scanned every 32-byte slot ofheap.copylinearly (for (size_t at = 0; at + kDescriptorSize <= heap.bytes; at += kDescriptorSize)) checking!(w[3] >> 30) && (w[2] || w[6]). Whenheap.copyfalls back toarena.mapped(uncached WC GPU memory — e.g. whenimport_console_heapcannot land within 4 GiB ofarena.addressor host-memory import is unavailable), reading 4–5.5+ MiB of WC memory triggers ~130k–180k uncached PCIe reads per buffer release (hundreds of ms/submission); even in cached scratch memory it linearly scans all empty and T# slots.leonida::ConsoleHeapVsharpSlots(runtime/src/console_heap_vsharp_slots.h), a dense host-RAMuint64_tbitset (~22 KiB for a 5.5 MiB heap, L1-resident) with O(1)empty()fast path,clear_range()for zeroed page runs,std::countr_zeroiteration safe against in-place bit clears inside the callback, andis_live_vsharp(w)matching the exact legacy predicate!(w[3] >> 30) && (w[2] || w[6]).heap.live_vsharpssynchronized at every resource-heap write toheap.copy:add_console_heap(reset),fix_console_slot(set),fix_console_slotsdeferred zeroing (clear), andfor_each_zeroed(clear_range).heap.live_vsharps.for_each(...)inrefresh_console_heapinstead of readingheap.copy.No overlap with
#1728or#1867.Verification
d3d12_vulkan_device.cppis Windows-only and verified by inspection + Windows CI)runtime/test/console_heap_vsharp_slots_test.cpp(CTestconsole_heap_vsharp_slots), including a 4,000-step differential model against a linear 32-byte slot buffer (fix_console_slot,not_tsharp, deferred zeroing,clear_range, in-place invalidation clears) and 5.5 MiB sparse heap check:clang++ -std=c++20 -Wall -Wextra -Werror -O1 -g -fsanitize=address,undefined: passedclang++ -std=c++20 -Wall -Wextra -Werror -O1 -g -fsanitize=thread: passedclang++ -std=c++20 -Wall -Wextra -Werror -O2(3 runs): passed-O2on Apple Silicon): linear scan60.30 usvs bitset0.93 us(64.9x faster even in cached RAM; eliminates 100% of WC reads fromheap.copywhenheap.copyis inarena.mapped)python3 -I scripts/check_no_game_data.pyon all changed files: passedpython3 -I tests/test_text_write_line_endings.py: passed (3 tests)@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 14:30 UTC · original · reviewed
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
@DadaCap on GitHub · 2026-11-25 15:01 UTC · original
Retail evidence for the root cause here, from a local change of the same shape (a per-slot byte map of live V#s in host memory instead of the scan of
heap.copy; I have not run this branch): RTX 5080, NVIDIA 621.24, Windows 11, story load up to the first world frames, longest singleheapstime per 5 s log interval.main)The average per submission outside those spikes did not change (about 3.4 ms): that is the copy of the part of the heap under a slot-133 import (27,648 KiB, pinned pages), a different cost. One run each, the second with more captures written. I had planned to send mine and won't, yours was claimed first; note that this one is
dirtyagainst currentmain. AI-assisted (Claude Code).@kawaii-shakal on GitHub · 2026-11-25 17:35 UTC · original
Independent test report for
3233b9857(VERIFY-1887-1957-BLACKWELL, claimed in #1608).Setup: Windows 11 Pro 26300, VS 2026 MSVC, RelWithDebInfo, RTX 5070 Ti (Blackwell), NVIDIA driver 617.42,
LEONIDA_VK_DEVICE=5070. Clean configure and full build ofruntime/succeed with MSVC.Full CTest (
ctest -j 6 --timeout 600):9e7720c9e3233b9857The one new test,
console_heap_vsharp_slots, passes. The skipped ones are the same as on base (game files or features this setup does not have:shader_library_corpus, bink,fsr_dispatch,bvh_builder,vk_sync_validation,d3d12_rgb9e5_rtv,d3d12_boot_movie,d3d12_first_light).Repeat runs:
console_heap_vsharp_slots,d3d12_title_va,d3d12_title_va_shadow,d3d12_unmapped_vsharpand the ninexs_proxy_mock*tests,--repeat until-fail:20 -j 4: all 13 passed all 20 rounds.AI-assisted (Claude Code, Claude Opus 5.5).
@x2Tweek on GitHub · 2026-11-25 18:39 UTC · original
Measured on Windows 11 with an NVIDIA RTX 5090 (driver 32.0.16.2124), retail boot past the opening credits, runtime of current main plus #1867 and a local debug overlay, 900 s runs with the same scripted input, from the
[rt] submit phasesandconsole descriptor heaplines:The invalidation rescans still run (982 in the run with #1887); they are simply cheap once they no longer read the write-combined heap copy. I also tried filtering those rescans to the slots that name a released range on top of this PR: no further gain, so this PR alone is the fix. AI-assisted: yes.
@qhukz13 on GitHub · 2026-11-25 18:42 UTC · original
Independent run on Windows 10 19045, GTX 1050 Ti (Pascal, 4 GB, no Resizable BAR), NVIDIA 582.66, MSVC (VS 18 Build Tools), RelWithDebInfo. Base
b0f3d3998with this PR (3233b9857) and #1957 applied together (they touch different code).b0f3d3998(449 tests), apart fromxmem/xmem_no_write_watchswapping places; both pass 5/5 on rerun, so that pair is flaky and unrelated.console_heap_vsharp_slots: passes 3/3, plain and withLEONIDA_VK_VALIDATION=1.d3d12_unmapped_vsharp,d3d12_title_va*,d3d12_api_descriptor_copy*,d3d12_rebound*,xs_proxy_mock*,d3d12_xmem_placed): pass 3/3 with no validation messages. The one exception isd3d12_geometry_views, which fails on main too, at root-signature serialization (d3d12_title_va_test.cpp:1067).arena.mapped(write-combined) fallback ofheap.copy, so the speedup itself was not measured here.AI-assisted (Claude Code).
@KushGene on GitHub · 2026-11-25 18:45 UTC · original
Independent Wine/RADV report for
3233b9857against its merge baseb0f3d3998. All 448 shared tests had the same outcome. The newconsole_heap_vsharp_slotstest passed in the suite and in 20 additional standalone runs of the Windows executable.b0f3d39983233b9857Fedora 45, AMD Radeon RX 6700 XT (NAVI22), Mesa RADV 26.2.7, Wine Staging 11.21. A Windows Vulkan probe enumerated only AMD
1002:73df. Cross-built the unmodified revisions with clang-cl/LLD 23.1.5, xwin SDK 10.0.26100 and CMake 4.3.0 (Ninja, RelWithDebInfo, D3D12 shim tests enabled, Rust XMA2 decoder built). SDL3 was unavailable, so CTest disabled its two GameInput tests. Ran the entire configured suite with four workers, then reran every failure individually on both revisions.d3d12_set_descriptor_heaps,d3d12_geometry_viewspassed on both revisions. The same 15 failures reproduced individually on base and PR:bcrypt_rng,bcrypt_rng_seeded,d3d12_clear,d3d12_clear_formats,d3d12_clear_restricted_depth,d3d12_console_descriptor_heap,d3d12_mesh,d3d12_xs_root_signature,device_proxy,device_proxy_trace,file_system,gameinput_host,pipeline_cache_seed,root_sig,xbox_gpu_label_completion.Synthetic tests only. No retail run or frame-rate measurement. AI-assisted (Codex). Coordination claim.
@x2Tweek on GitHub · 2026-11-25 18:49 UTC · original
Correction to the measurement above. The run with this PR recorded 2,725 successful presents in 902 seconds. The reported 5,450 counted each present twice because both the presentation and command queue trace layers reported it. The comparison run recorded 1,225 successful presents in 902 seconds.
The 2,725-present run also used different refresh and rescan settings from the comparison run, so the present totals describe the two configurations. They do not isolate this PR's effect.
AI-assisted: yes.
@aslan2142 on GitHub · 2026-11-25 19:06 UTC · original
Merged, thanks! Maintainer review of
3233b9857merged ontomain(the merge is mechanical):LEONIDA_CONSOLE_FIX_US=0(now the default) and with the retry budget. #1798, which landed in between, touches only the title-texture registry and adds no writer to the heap copy.console_heap_vsharp_slotspasses, and the new test fails on three mutated versions of the header.main9f9a7c5f3+3233b9857: it merges cleanly; the semantic suite passes (490 files, 6,292 tests, 0 files failed); the 15 docs and writer tests pass;check_no_game_data.pyis clean on the 4 changed files.refresh_console_heapitself, so a droppedsetcall there would still pass every test.AI-assisted (Claude Code, Claude Opus 5.5).