perf(gpu): check clean guard ranges one bitmap word at a time #381
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/lobomfz--VIctory-xmem!381
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-381"
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?
@tommiehansen on GitHub · 2026-12-03 21:45 UTC · original
tommiehansen:codex/watch-clean-bitmap→main· +46 −2 · 1 files · 5 commits · openFollow-up — clean-range benchmark coverage restored
Standard comparison at
b581f7evsf66910f(four ABBA blocks, Linux CPU-only):The adapter now recognizes the production
covers_or_emptypredicate. The comparison completed successfully, but the separate coverage assertion failed because it used the unqualified workload name; this is a harness-check failure, not a production correctness failure. Follow-up audit corrects the identifier and additionally verifies implementation identity and correctness digests. These are synthetic bitmap predicate timings, not frame-time savings.Standard benchmark — 2026-12-05
CPU-only Standard audit ·
b581f7evsf66910f.The job passed, but the relevant optimized clean/mixed range workloads were not measured on the candidate. No new performance claim; harness coverage must be fixed.
What this does
check clean guard ranges one bitmap word at a time.
Checks
cargo xtask policyon the final revision; no new game assets or build output intended.Verified
Existing measurements and commands are retained below at their original revisions. No fresh compile, policy or hardware test is claimed by this metadata review.
Cost
Synthetic predicate −94.89% to −95.94%, with drift; no live guard/FPS timing.
Detailed implementation and historical validation
Problem
The write-watch guard checks whether a view range is already clean before taking the more expensive path. The current predicate walks every set bit to count it. Upstream documents workloads with about 150,000 view blocks queried in a frame, nearly all clean.
Change and correctness
Reuse the existing masked bitmap-word scan, with the same sequentially consistent word loads as the set-bit iterator. A covered word needs one comparison, and a missing bit can send the request to the existing slow path immediately. The scan preserves partial-word masks, missing-piece behavior and the empty-range result. The shared guard lock and subsequent
BESIDEcheck remain in their original order. No shader, mapping, reset, protection or queue behavior is changed. The implementation is derived from the existing in-tree bitmap and guard code.Validation
Apple M5, macOS ARM64, Bench Suite Standard, four paired A/B/B/A blocks. Each timed sample checks 64 ranges of 2,784 blocks. The fixture extracts the corresponding production bitmap and the predicate called by
guardfrom each revision.45591b019f71f9Both result digests matched. The exhaustive local boundary oracle passed for both revisions, including empty ranges, missing bits and word and bitmap-piece boundaries. The production snapshots compiled the relevant portable code. Asset policy and Git whitespace checks passed. Candidate microseconds had high relative variance, and clean baseline drift was +5.5%.
The two workloads are provided by Benchmark Suite PR #322. They time the clean-range predicate and exclude the rest of
guard, lock contention and Windows write-watch calls. Hardware benchmarking was unavailable. Please test matched RT-enabled native routes on RX 9060 XT 16 GB at 1080p and RX 9070 XT at 1440p, with frame generation off, and compare guard CPU time, copy correctness and P99. No gameplay FPS change is inferred.The benchmark workload is committed at
7d2ad97in PR #322. Upstream1152b9cstill has the benchmarked baselinewatch.rs, and GitHub reports a clean merge against that revision.Follow-up review fixes (2026-12-04)
Head:
4634589b6be95cc5f67336663f64109042a13170.Name the empty-range semantics explicitly (
covers_or_empty). Addedclean_range_word_scan_matches_set_bit_count, comparing against the original set-bit count across word and piece boundaries, absent pieces, holes and empty ranges.Pinned CI audit started for this revision. Final-head compilation, tests and policy results are pending; historical measurements have not been relabelled.
Queue refresh — 2026-12-05
Merged upstream main
b581f7e0a8086158953a64068ba29305d5450d68into the existing branch without rewriting history. New head:f66910f888999fc362a73b11fa7df368783eb535. Live before/after watch tally still needed.Fresh pinned CI audit is the verification record for this revision; previous tests apply to the previously stated heads. #528 remains a separate policy prerequisite, not a runtime dependency. No new gameplay or GPU timing claim.
@Kal0s-design on GitHub · 2026-12-03 22:19 UTC · original
Tested on native Windows 11 (MSVC), with the PR applied on top of
0b652f8and also on its own branch.Equivalence. I added a local-only test (not part of this PR) that compares
g.clean.range(first..last).count() == last - firstfrom main againstcovers(first, last)on the sameBlocks, over every[first, last)pair (empty ranges included) in each window:253,188,480 cases, 0 mismatches (94.8M of them clean). To check the harness itself, I made the end mask drop the last bit when a range ends on a word boundary, and it caught that right away (f=0 l=64 and others), so it does look at the edges.
Tests, PR on
0b652f8,cargo test -p victory-gpu --lib -- --test-threads=4 --skip descriptor::tests::views_die_with_their_resource: 338 passed / 5 failed / 23 ignored, twice. That's the same as main. The 4 indirect/pipeline failures also fail on main here.watch::tests::the_rest_of_the_one_asking_has_a_number_of_its_ownis flaky in the full watch run on both (main failed 2 of 4 runs, PR 3 of 5) and passes every time when run alone on both. The other watch:: tests pass in debug and release.Clippy with
--all-targets: no new warnings compared to main. A small nit: rustfmt with the repo config wants to wrap theall_orderedsignature and thecoversbody.Rough timing in release (not the bench suite), 64 ranges of 2,784 blocks over a 150k-block clean set: old 66.0 us, new 2.75 us (about 24x). With a hole in some ranges: 66.7 us vs 2.06 us. That's the same order as your numbers.
Looks right to me.
AI-assisted: yes
@tommiehansen on GitHub · 2026-12-04 00:05 UTC · original
Thanks @Kal0s-design for verifying
watch.rsacross the 253M-case differential check and catching the formatting nits. Fixedrustfmtformatting onall_orderedandcovers(formatting-only change;rustfmt --edition 2024 --checkand Windowsx86_64-pc-windows-msvcvictory-gpu --all-targetscheck pass).@Luxuride on GitHub · 2026-12-04 12:03 UTC · original
Safe as written and a real micro-win — the swap is semantically identical (
watch.rs:1487-1489skips the missing piece andcount()cannot reachlast - first, and theBESIDEcheck is untouched) — but three small things:watch.rs:2102-2106says a frame asks about "some 10 GB of view memory, 150,000 blocks, nearly all clean", and the tally atwatch.rs:2127counts exactly the "no question to Windows" cases. One before/after line of that counter sells the change by itself.all()usesAcquire(watch.rs:1474) whilecoversasks forSeqCst(watch.rs:1866) to matchBits::range(watch.rs:1390). Keep theSeqCst— it is the same word order the range iterator had — but comment why, or the next reader will "fix" it back.coversreturnstruefor an empty range (watch.rs:1862) while theall()it wraps returnsfalse(watch.rs:1497). Correct at this call site, but name it (covers_or_empty) or assertfirst < last, because it will bite the next caller.Fold the rustfmt commit into the first one before merging.
watch: check clean guard ranges one bitmap word at a timeto perf(gpu): check clean guard ranges one bitmap word at a time@tommiehansen on GitHub · 2026-12-05 10:19 UTC · original
Thanks for the bitmap review. f66910f uses covers_or_empty and documents the SeqCst ordering. The restored clean/mixed benchmark coverage now passes CI with matching digests and verified production predicates. The preceding Standard comparison measured 93.29%/94.80% lower predicate time; not per-frame savings.
github-bot referenced this pull request2026-12-05 11:23:55 +00:00
github-bot referenced this pull request2026-12-05 11:23:58 +00:00
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.