umem: skip sparse GPU binds and lookup records for CPU-only host_range views #186
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/vktory6--VKtory!186
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-186"
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?
@Mhyster on GitHub · 2026-12-02 06:21 UTC · original
Mhyster:opt/umem-skip-host-range-gpu-binds→main· +130 −54 · 3 files · 1 commits · openWhat
Overlap with open PRs:
#168(umem: run on NVIDIA's driver) and#178(umem: driver.rs) touchgreenfield/umem/src/lib.rs(device setup) and 3 lines ofgreenfield/umem/src/mapping.rs; this change touchesMapping,insert_mapping,carve,set_runs_before, andmap_pieces.Addresses
docs/TASKS.md("Small items": "About 9 % of sparse binds go to a CPU-only pool window the GPU never reads",docs/learnings/known-wrong.md"Pages above 2^40"):gpu: booltoumem::MappingandState::mapping_uses_gpu(start, len)(!self.in_host(start, len)).map_piecesenters a pool view inside a declaredMemory::host_range(victory-hle's CPU-only pool write window above 2^41, whichvkback-unix/umem-unixalready register viam.host_rangewhenown = true),insert_mappingmaps it withgpu = false:self.window).self.lookup.insert).vkQueueBindSparsebinds (self.queue_bind) and timeline events.set_runs_beforequadratic run-rewriting walks across 64 KiBpool_windowpages.st.mapsandst.blocks[block].mappingssopool_release,destroy_pool,unview,protect,read_backing,check_sample(stray-write detection against DirectStorage writes), andDropcontinue to track and unmap its CPU pages cleanly.umem::loud::fail+Error::Invalid) if a caller ever requests a GPU-only view (cpu == false) inside a declaredhost_range.carve, skipslookup.remove,timeline::unmapped,st.stale/queue_bind(null), andset_runs_beforeforgpu == falsemappings, and preservesm.gpuon any carved remainders.set_runs_beforeandinsert_mapping'srunmerge, ignoresgpu == falsemappings so GPU runs never merge across non-GPU aliases.The reference
No D3D12 / vkd3d-proton counterpart (this is our own Linux
umempool-window mechanism, documented indocs/learnings/known-wrong.md"Pages above 2^40" andcrates/victory-hle/src/modules/umem.rspool_window/reserve_window).Evidence
Checks run (all passed on Linux x86_64)
greenfield/umem/src/lib.rs(host_range_tests::host_ranges_merge_and_cover_only_what_was_declared): verifiesState::mapping_uses_gpureturnsfalseinside a declaredhost_rangeandtruefor title addresses.host_range_pool_view_skips_gpu_binds_and_lookupingreenfield/umem/tests/gpu.rs(compiled and clippy-checked; not executed on GPU in this session).cargo test -p victory-shader -p victory-formats -p victory-core -p xtask --locked: passed (victory-core13,victory-formats49 passed / 5 ignored,victory-shader240 passed / 2 ignored,xtask6).(cd greenfield && cargo test -p umem -p frame -p vkback --lib --locked && cargo test -p vkback --test policy --locked): passed (frame13,umem22,vkback168 passed / 3 ignored,policy6/6).cargo clippy --all-targets --locked -- -D warnings: passed cleanly across root (-p victory-shader -p victory-formats -p victory-core -p xtask),greenfield,greenfield/wine, andgreenfield/vkback/translate.Checks NOT run (live game / GPU unavailable in this session)
The host GPU was not touched in this session:
cargo test -p umem --test gpu host_range_pool_view_skips_gpu_binds_and_lookup(requires GPU).VKB_LAT+greenfield/tools/frec/frames.py.docs/tools.md, "Vulkan validation run").cargo xwin clippy ..., verified by GitHub Actions CI).Checklist (docs/AGENTS.md)
docs/TASKS.mdnot edited, the fixed item named above (rule 29)unsafeblock has a// SAFETY:comment; no raw pointer around the borrow checker (rule 36)TRANSLATOR_VERSIONbumped if the translator's output changes (rule 27)@firefloc on GitHub · 2026-12-02 07:02 UTC · original
I tested #186 locally on Linux/RADV because a streaming trace showed a large cost in sparse bind submission and in
set_runs_before. I also tried a separate change to the tree traversal so I could distinguish the two effects.Setup: RX 7900 XTX (RADV NAVI31), Ryzen 7 7800X3D, 32 GiB RAM, CachyOS (kernel 7.3.6), KDE/Xwayland at 3440×1440. The fork base used upstream
cc16c64. Each run started from a fresh clone of the same save, with the live guard filter from #141,VICTORY_VIEW_GUARD=1, valid BCPack tables, per-frame MangoHud logging, andVKB_LAT. The PE and tools were identical across builds. The scene was the load into the saved world, so these numbers do not characterize the standard boat route.Exploratory passes, world seconds 1–80
With #186 alone the number of sparse-bind flushes dropped from 142,857 to 129,088. Its p99 and max improved in this pass, while mean cadence and the count of frames over 100 ms went the other way. The game lock was held, but a local config overrode the build lock setting in this series. These were single passes and the sparse-bind totals are summed timings over the reported run segments, across threads. They are useful for attribution, not an FPS verdict.
Independent follow-up for
set_runs_beforeThe extra change uses one descending
BTreeMap::range_mut(..at).rev()traversal in place of a predecessor search and a second mutable lookup per changed entry. The stop conditions, published run lengths and Vulkan calls are unchanged. On top of #186, the measured time in that function went from 2.80 to 0.44 s with 64.23M and 64.53M run updates. In a separate pair with both the GPU and build locks confirmed and without #186 in either build, it went from 2.99 to 0.93 s (−69%) for 66.15M and 66.10M run updates. This is summed time in the function, not a per-frame saving. The standalone traversal change passed the 22 umem unit tests plus the GPU tests for span changes and GPU-only pool views. The host-range CPU/GPU alias coherence test also passed with #186 and the traversal change together.In the locked pair, over world seconds 1–60, MangoHud recorded 7.92 → 4.51 FPS, 487 → 2,106 ms p99, and 206/467 → 167/266 frames over 100 ms. There was active swap in both runs, with spot samples above 100 MiB/s in both directions in the slower run. This pair does not establish a frame pacing benefit or attribute the slowdown to the traversal. Neither run recorded a remap applied ahead of its queue position or a read of pages mapped from the future. I did not run the in-game Vulkan validation or picture gate for #186.
The result worth retesting is the reduction in sparse-bind work from #186 and the separate reduction in tree maintenance. A warm, interleaved boat run without swap pressure would show whether either reduction carries through to frame times.
@firefloc on GitHub · 2026-12-02 17:33 UTC · original
I checked the lookup changes at
c3516dd. Keeping the CPU-only alias out of the GPU sparse window and makinglocatereturn no GPU buffer makes sense. However, theif gpuaroundlookup.insertalso removes the alias frombacking_ofandkinds_in, which still read that same tree. The existingbacking_ofcontract explicitly covers equality between a texture view and the pool alias that DirectStorage writes through.cpu_read_okalso uses the reported memory kinds.Could we keep the backing identity and kind visible to those CPU queries while excluding the alias from GPU lookup and binds? I compiled a regression test with two views of one write-combined pool page. It asserts equal backing identity, write-combined placement and
cpu_read_ok == false, checks that the alias has no GPU location, then checks the partial unview and removal. Vulkan execution of that test remains pending. The physical DirectStorage notification path I checked translates its notifications to title addresses, so this lookup change does not by itself establish an in-game stale-texture regression.@firefloc on GitHub · 2026-12-02 18:50 UTC · original
The targeted alias test now reproduces the lookup change on Navi 31 / RADV. I used the same test setup on
d59b4f8andc3516ddb, with two views of the same write-combined pool page and one declared ashost_range.d59b4f8: 1 pass. Both views report the same backing,kinds_inreportsGttWriteCombined, andcpu_read_okis false. Both sides of a partial unview keep the expected backing and placement.c3516ddb: the same test fails on backing identity. The host alias has no backing,kinds_inis empty, andcpu_read_okbecomes true. Both sides still lack that metadata after partial unview. The alias has no GPU buffer, as intended.The test uses views inside one sparse window, so it checks the lookup contract independently of the real pool's high address. This is native Vulkan test evidence. The DirectStorage path we traced reports title addresses, and a visible game regression remains unverified.
@vktory6 on GitHub · 2026-12-02 20:08 UTC · original
Thanks. We ran it on the reference card (RX 9070 XT) in the boat scene: binds sent fell by 2.6 % and sparse flushes by 8 %, both within the noise of that scene, so there is no measured gain yet. That alone would not block it (rule 24). The correctness point firefloc raised does.
The
if gpuaroundlookup.insertkeeps the alias records of CPU-onlyhost_rangeviews out of the lookup altogether. That hides them from the CPU-side queries too:backing_of,kinds_inandcpu_read_ok. One concrete path is dstorage.rs's zlib decode destination (cpu_read_okbefore it reads back). A write-combined alias page then counts as fine, and its slow read goes uncounted, silently (rule 5).What we'd merge:
locate,locate_span,span_of,gpu_address_of): no window and no sparse bind for them. That keeps the bind saving.cpu_read_okandkinds_instay right for the alias. Please credit firefloc in the commit.The sparse-bind cost on RADV is measured and discussed in https://github.com/vktory6/VKtory/discussions/260, if you want numbers on what a bind costs.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.