perf(gpu): skip redundant held-slot touch and batch record stats #509
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!509
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-509"
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?
@Not4Eric on GitHub · 2026-12-04 20:24 UTC · original
Not4Eric:perf/records-skip-touch-batch-stats→main· +29 −12 · 2 files · 1 commits · merged 2026-12-05 17:29 UTCWhat this does
Two hot-path reductions in view-record bookkeeping:
c.touch(slot)when a slot is already held/ready inrecords::told_at(same slot ascell.load) and defersc.touch(slot)indraw::State::scanpast theself.readycache hit path (avoiding redundantc.touch(slot)calls — each a relaxed atomic load plus conditional store — on the vast majority of descriptors).STATS[MOVED]andSTATS[STOOD]increments pereach_viewchunk inrecords::roundinstead of calling globalAtomicU64::fetch_addon every cell that changed.Checks
told/told_at/roundincrates/victory-gpu/src/records.rsand movingc.touch(slot)incrates/victory-gpu/src/draw.rs.records::invictory-gpu(0matched); behavioural invariance verified by combined gameplay testing.perf/draw-split-uav-scan-cache.cargo xtask policypassed (360 files ok); no fork-only files, configs, or build outputs.Verified
cargo xtask policy—360 files okPKG=victory-gpu ./build.sh test --lib -- records:: --test-threads=1— compiled cleanly with 0 warnings (0tests matched underrecords::)records::roundprocesses ~260k–310k title slots/frame; not benchmarked in isolation.Cost
None (reduces atomic contention in
records::roundanddraw::State::scan; 0 new warnings).AI-assisted: yes
@Kal0s-design on GitHub · 2026-12-04 22:15 UTC · original
Checked
94e4148on native Windows (one NVIDIA desktop card, didn't run the game).victory-gpu lib tests: 352 passed, 5 failed on the PR and 353 passed, 4 failed on main. The four are the ones that already fail natively here (two indirect host_list tests, two pipeline::host library loads), the fifth is the flaky watch test, which passed 2 of 3 reruns on the PR. Clippy with and without diagnostics shows nothing new in records.rs or draw.rs, only the two old draw.rs warnings main has too. It merges cleanly with current main and with #510 (both touch State::scan), and after merging both, the one c.touch in scan still sits after the ready cache-hit continue.
On "identical slot lifetime" I traced who reads what touch writes. Canon::touch (records.rs:506) only stores STEP into Canon.named[slot], and the only reader of that is the aged check in reclaim (records.rs:600). reclaim skips any slot with refs != 0 before it looks at age (records.rs:608).
The told_at skip (records.rs:816-818) is safe. When resolve gives the same slot the cell already names, that cell took a hold on it before the swap (records.rs:820-825), so refs is at least 1 and reclaim never ages it. When the cell later lets go, release (records.rs:588-593) stamps named again, so ageing starts from the release on both sides.
The scan move (draw.rs:2822 to 2844) isn't strictly identical, but I don't think it changes anything in practice. A repeated SRV hit on the same record in the same list epoch no longer restamps the slot, only the first miss does. Main already does the same thing one level up: the scanned hit (draw.rs:2766-2770) returns for the whole table before any touch. And ready is cleared with scanned in tables_done (draw.rs:609-610). For a slot to age out it would need refs == 0 for at least rest = 2*sweep+2 required rounds (records.rs:889). Descriptor writes into title heaps tell the cell straight away (descriptor.rs:162-164) or, for port heaps, on the next round, and the audit covers every heap in about sweep rounds. So any slot a draw can reach gets held long before it could rest. If one did get rested anyway, quick_key goes to 0, so the next scan sees fresh, misses the cache and re-mirrors (draw.rs:2823-2830). I'd soften the wording to "same reclaim decisions" rather than identical.
The stats batching looks right. MOVED is still counted once per swap and STOOD under the same condition. told() flushes inline (records.rs:795-803) and each each_view chunk flushes at the end of its closure with no early exit (records.rs:868-885). The only reader is line(), which swaps the counters to zero once per report (records.rs:957-960), so at worst a few counts land in the next report. One nit on the description: main never did a fetch_add per slot in round, only for cells that actually changed (the early returns skip it), so the contention saved is per moved cell, which should be far fewer than the cells told each frame. Same for touch, which is a relaxed load plus a store only when the step changed, not an atomic RMW.
Small thing: cargo fmt wants the new stood expression at records.rs:832-834 split over several lines, it's 101 columns with max_width 100. I didn't try a throwaway test for the ageing part since Canon::new needs a live host heap and records() set up, so the lifetime argument above is from reading the code only.
AI-assisted: yes
94e41481d4to8e3a119fbe@Not4Eric on GitHub · 2026-12-05 00:00 UTC · original
Thank you so much for helping, I'm not the best at this and I'm heavily relying on AI to even do this
Pushed updates addressing your review:
let stood = u64::from(...)inrecords.rsto stay within 100 columns.roundbatchesSTATSper moved cell.@Kal0s-design on GitHub · 2026-12-05 00:59 UTC · original
Re-checked
8e3a119on native Windows (didn't run the game).The stood expression at records.rs:832-838 is fmt-clean now, and the description says "same reclaim decisions". The full lib run shows only the four failures main already has natively, clippy has nothing new (only the two old draw.rs warnings), and it still merges cleanly onto current main.
A tiny wording leftover, not blocking. Point 2 still says main did a fetch_add "unconditionally on every slot", but main only did it for cells that changed, and point 1 calls the touches atomic when touch is a relaxed load plus a store only when the step changed.
AI-assisted: yes
github-bot referenced this pull request2026-12-05 11:18:26 +00:00