Perf/indexed copyback ranges #1867
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1869"
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?
Imported from Marvisak/VIctory. Originally posted by VlREX on 2026-11-24T23:53:48Z.
Replace linear precise UAV range scans with a sorted prefix-maximum interval index and binary search. Synthetic lookup comparisons reduced from 6,292,480 to 45,058, excluding index construction. Independently verified with 102,464 JavaScript model queries and 131,072 native C queries, zero mismatches. Four Rust tests included. Native Rust and GPU benchmarks pending. Complementary to #1865. AI-assisted (ChatGPT).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T00:32:41Z.
Review: COMMENTED
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Indexed copyback ranges (docs+gpu): perf work on the copyback path, pairs with #1816's delivered-bytes accounting.
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T00:10:54Z.
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
b118e79:cargo test -p victory-gpu --lockedgives 80 passed, 2 failed, 1 ignored. The two failures are the NVIDIA heap-cap onesmainalso has (descriptor::host::tests::dynamic_slots_are_held_until_releasedandmemory::tests::lists_share_a_table_and_copies_keep_their_views, #1744), so there is nothing new on this hardware. Not run: a title.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T07:26:35Z.
Automated triage for the maintainers.
Needs rebase. This PR no longer merges cleanly into
main(conflict incrates/victory-gpu/src/memory.rs). It will be reviewed again once it is rebased.From the earlier needs-work note, still open: a number from a real frame showing the linear scan costs something (range counts or before/after copy-back ms), a descriptive PR title, and rustfmt on
precise_ranges.rs.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T19:59:41Z.
Reviewed and verified
163c39ffon Windows 11 againstmain(13f91ca).Code review
AdaptiveRangescleanly addresses the upfront allocation/sorting overhead on small or early-exit sets: it scans linearly with zero allocation untiln >= 8andcomparisons >= n.saturating_mul(32), only building the sorted prefix-max index when the range set actually gets hot. Droppingpreciseanddeclaredright after the scan also avoids holding thebyte_for_bytelock longer than needed.PreciseRanges::overlapsagainst the prior linear predicatea < to && from < a + len:saturating_addavoids end overflow,from >= toreturnsfalse, andpartition_point(|&(start, _)| start < to)+ prefixmax_end > frommatches on nested ranges, duplicate starts, zero-length ranges strictly inside a page vs. on boundaries, and saturating ends.Verification (Windows 11, RTX 5090 + WARP)
VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics -- --test-threads=1: 205 passed, 0 failed, 1 ignored (all 7precise_ranges::testspass).precise_ranges::tests7/7,shadow::tests --test-threads=18/8,memory::tests --test-threads=14/5 (only the known13f91caRTX 5090 1M view-heap failurelists_share_a_table_and_copies_keep_their_views).cargo clippy -p victory-gpu --all-targets --locked -- -D warnings(default and--features diagnostics): 0 warnings;cargo xtask policy: 185 files ok.git merge-treeagainst13f91caas well as#2172,#2434,#2096, and#562.Imported from Marvisak/VIctory. Originally posted by crashbashash on 2026-11-26T10:10:03Z.
In-game numbers for the linear search this PR replaces, since the description says native benchmarks are pending.
RX 6800 XT, Linux (Proton, vkd3d-proton),
diagbuild with frame pointers ofmain219878aplus our Linuxcommits, a save in the prison, perf (
cycles:u, call graphs) over 30 s in the world.The search shows up as
memory::bind::closure$2(the after-run closure that copies back marked pages): 13.6 % and12.9 % of the submitting thread's samples in two runs. By source line, 95-97 % of that closure's own samples are the
precise.iter().any(...)line; scanning the bitmap itself is negligible. The list is long becausedraw.rspushes aroot UAV's range for every draw or dispatch that binds it, so a list holds many copies of the same few ranges, and
every marked page is compared with all of them.
I tested the same idea in a smaller form on our branch: sort the ranges and merge overlapping or touching ones in
place (the bytes they cover stay the same, so a list that runs again searches the merged list), then a binary search
per page (
partition_point; with disjoint sorted ranges only the last one starting before the page's end can overlapit), with a test against the linear search over random, duplicated, touching and empty ranges. With it the closure
falls to 0.2 % of the thread. Frame times did not move measurably (it is one thread among several; 2 runs
each), so the gain is CPU time on the submitting thread rather than frame rate here.
Either version removes it; no need to change yours for this. Happy to share ours if a smaller diff helps.
AI-assisted (Claude Code). No game data attached.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.