gpu: replace O(N) bindless_plan scans with O(dirty) incremental tracking #199
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/Belobug--VIctory-Belobug-AMD!199
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-199"
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?
@Vladimir-Human on GitHub · 2026-11-25 21:26 UTC · original
Vladimir-Human:perf/incremental-bindless-plan→main· +2698 −290 · 4 files · 4 commits · openSummary
AI-assisted performance PR eliminating the four full-table
O(85,000)scans inBindless::plan()(crates/victory-gpu/src/descriptor/host.rs) by introducing incremental per-slot change tracking (DirtyTracker/plan_dirty()), while preserving all recentorigin/main(4f62c2a) behavior verbatim.What changed
O(dirty)Bindless::plan(): Tracks dirty bindless slots acrossShadowchanges,Placedview bumps/evictions,Resourcereleases/destroys, and slot writes so unchanged frames and partial updates only inspect affected slots rather than walking all ~85k entries on the submit thread.4f62c2apreservation & integration:VICTORY_LOD_CLAMPinlargest_mip,placed_censusinresource.rs, and the production write-only plan skip outside tests (cfg!(test) && self.writes_dirty).write_slotsin strict lockstep and preserves bit-exact output parity against full-table planning.VICTORY_PLAN_REUSE=0reverts to full-scan planning for A/B validation and troubleshooting.bindless_plan_differential_parity,bindless_plan_ring_overflow_fallbacks, pinning pre-evictionID3D12ResourceCOM references across eviction).Verification (RTX 4070 SUPER / i5-13400F,
3469dd5cf8)cargo clippy -p victory-gpu --no-deps --all-targets --all-features --locked: 0 warnings in added/modified code.VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --locked --all-features -- --test-threads=1: 118 passed, 0 D3D12 debug errors/warnings (2 pre-existing unrelated failures on NVIDIAPORTABLE_VIEWScap /watch::testsparallel run;watch::testspasses 1/1 standalone).VICTORY_D3D12_DEBUG=1stress onbindless_plan_ring_overflow_fallbacks+bindless_plan_differential_parity: 10/10 passed.VICTORY_D3D12_DEBUG=1 VICTORY_PLAN_REUSE=0descriptor::host::tests::bindless: 6/6 passed, 0 D3D12 errors.bench_bindless_plan_85k(85,000 slots, median of 12 iters, bit-exact parity verified):0.1 us -> 0.0 us2,731.4 us -> 79.9 us(34.2x)12,402.2 us -> 47.1 us(263.3x)12,656.0 us -> 33.0 us(383.5x)14,533.2 us -> 28.5 us(509.9x)Co-Authored-By: AI Assistant
4f62c2a) into perf/incremental-bindless-plan d8365a5224@Vladimir-Human on GitHub · 2026-11-25 23:43 UTC · original
Follow-up uncontested
--releasebenchmark on idlei5-13400F/RTX 4070 SUPER(3469dd5cf, median of 12 iters):4 changed slots:2,479.9 us -> 54.4 us(45.6x)1 dead shadow (4 slots):9,500.5 us -> 42.2 us(225.1x)1 bumped view (4 slots):11,369.5 us -> 30.1 us(377.7x)1 evicted placed (4 slots):10,626.6 us -> 19.1 us(556.4x)@adrianmjim on GitHub · 2026-11-26 19:47 UTC · original
Tested on native Windows 11 with an RX 7900 XT (hardware adapter, driver 32.0.32029.2010). Head
3469dd5, base4f62c2a. Other jobs were running on the machine (CPU at 100%), so the timings are noisy.Lib tests (
cargo test -p victory-gpu --lib, debug, 15 interleaved runs each of base and PR):frame::tests::waits_end_on_ticks_and_count_framesfails on both (base 15/15, PR 13/15). Thewatch::testsflakes you mentioned happen on base too, in 4 of 15 runs on each side.bindless_plan_differential_paritywas among the tests that had not finished, along with the shadow/texture/watch tests. I did not root-cause either one.descriptor::hostpasses 16/16 withVICTORY_PLAN_REUSE=0.--test-threads=1): base and PR both fail onlywatch::tests::written_pages_are_reported_to_every_asker.Same-path comparison against base:
bench_bindless_plan_85kcompares two code paths inside the PR. So I ported its scenario to a single heap through the defaultbindless_plan(), which builds on both base and PR. On base it also needs the PR's test-onlytest_register_directand thedirect()test lookup. Release, 5 interleaved runs, median of the per-run medians:Base and PR produce the same plans in all 10 runs: same read ranges, write ranges and bounces for all 108 plans. I left the retained-resource count out of that check because it varies from run to run on either build.
The evicted-placed number in the PR's own bench looks like an ordering effect:
Also note that both benches are test builds, and there base takes
cfg!(test)branches. It always walks the direct slots (host.rs:1791 on base) and always remakes the plan (:1989). So the base cost in a release game build may be lower than these numbers.Not tested: the D3D12 debug layer (no diagnostics build), clippy, WARP, and any in-game timing.
@Vladimir-Human on GitHub · 2026-11-27 07:04 UTC · original
Thanks @adrianmjim for testing on RX 7900 XT (108/108 identical plans against base, single-heap comparison, and catching the ordering bug in
bench_bindless_plan_85k's evicted-placed sub-case).bench_bindless_plan_85kevicted-placed ordering (f470ac0): Case 5 now runspass_frame()+title_memory_remapped()fresh before each side, alternates full-first vs incremental-first onk % 2, and asserts pairwise-distinct live COM resource pointers (host_before,host_full,host_inc) so neither path can reuse the other's re-created texture in the global placed-texture map.--releasebench_bindless_plan_85knumbers (f470ac0,i5-13400F/RTX 4070 SUPER, 3 clean runs, 85,000 slots, median of 12 iters per run):4 changed slots:2,897–3,250 us -> 79–104 us(31–41x)1 dead shadow (4 slots):11,747–15,346 us -> 49–64 us(239–265x)1 bumped view (4 slots):12,572–17,289 us -> 31–47 us(371–419x)1 evicted placed (4 slots):12,684–18,126 us -> 702–1,400 us(13.0x–18.1x, median 15.6x — replacing the earlier ordering-affected556x/19.1 usfigure now that both sides independently pay cold D3D12 placed-texture re-creation).cfg!(test)caveat: Agreed with your note — bothbench_bindless_plan_85kand the single-heap port run undercfg!(test), where the full-scan baseline always remakes the plan and takes test-only branches, so the real release game build baseline cost on unchanged/partially-changed frames can be lower than these test-build numbers.f470ac0:cargo clippy -p victory-gpu --all-targets(0 new warnings in touched code),bench_bindless_plan_85k --release(3/3 clean runs passing), anddescriptor::hosttests in both default incremental andVICTORY_PLAN_REUSE=0modes (all PR + bindless/eviction tests pass; only untouched upstreamdynamic_slots_are_held_until_releasedhits NVIDIA's 1M shader-visible descriptor cap on RTX 4070 SUPER).@adrianmjim on GitHub · 2026-11-27 07:06 UTC · original
Thanks @Vladimir-Human. Re-creating before each side, alternating the order, and asserting distinct resource pointers is what that sub-case needed. The 13–18x figure is now a like-for-like cold re-creation on both sides, rather than one side reusing the other's texture. Nothing further from me.
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.