perf: cut the layer's CPU and card-side overhead (14 changes, switch-gated) #1449
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!1449
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1449"
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?
@gaxolotl on GitHub · 2026-11-28 20:11 UTC · original
gaxolotl:perf/optimizations→main· +5831 −475 · 22 files · 39 commits · closed without mergingWhat this is
A performance pass over the layer, driven by measurements on one machine
(i5-14600KF, 32 GB, RTX 4070 Ti 12 GB, Windows 11 26300, driver 621.24, Series X
profile, 2560x1440, DLSS Quality). Every change is behind its own
VICTORY_*switch and defaults to the new path, with
=0restoring the old one.The target was 30 fps rendered with
VICTORY_FRAMEGEN=0. It is not reachedand cannot be reached by this layer's bookkeeping — the last section has the
measurement that settles it. Everything below is still a real reduction in work
the layer was doing; it just is not the work that limits the frame.
Changes
Card command stream
0.2.0-pre.5(7c53527).10,541 fills/frame became 3,499 copies.
VICTORY_CARD_STEPS_JOIN.3,499 → 823 copies/frame.
VICTORY_CARD_STEPS_ALIGN.ReadProcessMemorya place instead of one perpage (240 ns for 1 byte vs 276 ns per place), the fill lookup under the one
list lock taken per plan, and hash runs built in order instead of sorted
(64k–85k spans a frame).
VICTORY_CARD_PLAN_FAST,VICTORY_CARD_HASH_ORDER.Descriptor heaps
never be mirrored. 22 MB → 9.7 MB read per frame.
VICTORY_SYNC_CAP.VICTORY_SYNC_WORDS.CopyDescriptors— ~16,800 calls →~368 runs/frame.
VICTORY_SYNC_NULL_RUNS.one view into many slots; each was a
Create*View.VICTORY_SYNC_MAKE_CACHE.guarded block is read-only and clean.
VICTORY_SYNC_ASK_CLEAN.Write watch / refreshes
BTreeMap(136 ns → 4 ns a page look at 100k pages), one read lock per flush,ordered ahead-range lookup. Refreshes 11.3 → 8.7 ms/frame.
VICTORY_JOURNAL_TREE,VICTORY_REFRESH_BULK.VICTORY_SEND_CHANGED(off by default).card_sides()per copyinstead of three.
VICTORY_SEND_BATCH.Textures
no room; tell the queue 256 at a time.
VICTORY_TEXSPK_SKIP_WHEN_FULL.40k slots — and bound a take to twice what the pass last served (154 takes
walked 594,000 entries to serve 48,414).
VICTORY_DUE_ORDERED,VICTORY_TEXSPK_DUE_TAKE.VICTORY_TEXSPK_ONE_RECORD.Card compare/hash passes
descriptor table (
SRV t0[64]/UAV u0[64]): 549 → 56 commands in replay,picture byte-identical.
VICTORY_CARD_PASS_BATCH.bit-identical to the CPU mirror in
torn.rs, proved by a WARP test.VICTORY_CARD_HASH_WIDE.Build
victory replaybuilds in about a minute.Verification
cargo test --release -p victory-gpu --lib: 488 passed, 0 failed.wide hash against the CPU mirror, byte for byte.
victory replayof a recorded frame: picture blake3 unchanged by every batchingchange; commands 549 → 56.
Why 30 fps is not reached — and cannot be, from here
Three controlled experiments say the frame is not bound by anything this layer
does.
1706x960) plus the ambient/reflection estimate off — two large quality
cuts — gives 19.6 fps, 51.1 ms, card 83% busy. Halving the pixels changed
nothing.
barrier is promoted to a global UAV barrier. Running the frame with them
removed is slower (44.1 ms vs 42.3 ms baseline); merging them is slower
still (53.8 ms).
victory replay --timing detailedon arecorded frame: indirect mesh draws 25.0 ms in 7,817 commands, dispatches
15.4 ms in 1,735, indirect dispatches 7.9 ms, draws 6.3 ms — against our
hash/compare passes at ~7 ms (all 549), texture copies 3.4 ms, buffer copies
2.8 ms, clamps 1.7 ms.
So the card spends ~42 ms of a ~50 ms frame launching and running ~7,800 mesh
draws at ~5 µs each, and it draws only ~125 W doing it — high occupancy, low
power, i.e. per-draw front-end work, not shading. Removing all of the layer's
GPU work would leave a ~42 ms frame (24 fps), and it would still be the title's
geometry.
The remaining lever is the translated geometry itself — how a mesh draw is
translated and launched — which is a project, not a patch series.
Measurement notes
Unattended runs drift into different content (draws 1.2k–12.9k), so raw fps is
not comparable between runs; the figures above come from the layer's own
per-frame counters or from controlled
victory replay --compareA/Bs in oneprocess.
The host-copy refresh is 13.5 ms a frame, and 85% of its ranges (7,000-8,000 of 8,800) are told "nothing new" (work/stats.txt). Each of those asks: - walked the journal's BTreeMap of every page ever written -- some 100,000 by the end of an hour (the title writes 7,000 pages a frame and nothing prunes it) -- four to six cache misses a look: 136 ns measured per look at that size, against 4 ns in the pieces it holds now (new ignored test); - took the journal's global read lock for itself (~8,000 read locks a frame from the submitting thread's flush filter alone); - walked every range the submission asked about (ask_once keeps one per isolated range): a linear scan; - read two 256 KiB block-bit arrays (published) even where the submission's asking already covered the range and its bits could not matter; - took three of a copy's locks (pending, copied, ranged). None of these change what the journal says, only what an answer costs -- a missed write is visual corruption, so the answers are bit-for-bit as before: - watch.rs Written (watch.rs:138): a page's last-write asking in pieces of 512 pages (32 MiB of title memory, a 4 KiB array), made when first needed; one array read a page, and a range looks a piece up once. VICTORY_JOURNAL_TREE=1 keeps the old BTreeMap path for an A/B run. - watch.rs covers (watch.rs:763): ahead is kept in page order and looked up by binary search instead of the walk. A list out of order can make it say "ask", never "nothing new" (tested against the walk). - watch.rs Snapshot (watch.rs:905): one look at the journal for a whole flush's ranges, with a turn counter that moves on every note; a snapshot a write has outrun answers nothing (VICTORY_REFRESH_BULK=0: one lock a range, as before). - watch.rs nothing_new_in (watch.rs:891): the submission's asking is checked first; the block bits are read only where it does not cover the range. - shadow.rs Shadow::nothing_new_with (shadow.rs:4194): the same asking, from a snapshot; it answers "stale" -- never "nothing new" -- if the look was outrun. - host.rs Batch::flush_all (host.rs:9105): the flush's filter takes one look at the journal for all of its ranges; FLUSHES[4]/[5] and the frame line now say how much of refresh_ms is that asking (the split report-lists.md 4-C asked for). - watch.rs parts_written (watch.rs:88): no pages, no lock. Tests: cargo test --release -p victory-gpu --lib -> 462 passed, 0 failed (460 before, plus the_pieces_hold_what_the_tree_held and the_asked_ahead_ranges_are_looked_up_in_order); the same 462 pass with VICTORY_JOURNAL_TREE=1. cargo build --release -p victory: OK.The pass over the textures picked by index takes up to 4,096 due slots a run and, on a full card, refuses almost all of them at draw.rs:3372-3399. Every one of those was looked at first: what the queue knew of it (a take of the queue's lock when its marks say it was written again), a 48 KiB fingerprint of its memory, the walk of what of it is mapped, and the view the slot holds - four questions whose answer cannot change the refusal. Measured (work/run-baseline.out.err, 16:14:47, 15 fps, the card at its line): 190 ms of pass in 5 s; 23,547 slots taken, 20,776 of them held back for want of room (88%); of its 113 ms "rest", 67 ms telling the queue what came of each slot, 14 ms reading the slots' records, 21 ms asking what of a texture's memory is mapped, 1 ms fingerprints (a slot never uploaded has none to compare). So most of what a full card's pass did was the tell, one take of the queue's lock per refused slot. Now, with no room on the card, a slot that holds no host texture of its own (`texture_slot_made`, host.rs:2643) is held back at once: 102 of those 190 ms go, and the tells go 256 slots at a take (`HELD_A_TELL`, `texture_slots_held`, host.rs:2469) instead of one each. Why no texture that should appear is lost: - `made == 0` means `texture_slot_made_from` is false for the slot, so the old path could not re-upload it either (VICTORY_REUPLOAD_WHEN_FULL excepted nothing here): its outcome was the same `Told::Held`; - the remembering of slots whose memory went is untouched: every slot `texture_slot_gone` can unmake has `made != 0` (it returns false otherwise, host.rs:2764), and those are looked at still - and that is the only reclaim for a copy a slot shows (slot_evict and let_go_idle both refuse copies a slot holds), so the card's room comes back as it did; - the hold is the same entry `Told::Held(frame + most)` writes today, and `texture_slots_room(frame)` makes every held slot due at once when the card has room (host.rs:1405-1415, called at draw.rs:3100) - the path the slots refused further down already rely on; - memory the runtime maps again makes its slots due by name (`texture_slots_remapped`, host.rs:2485), room or no room. Expected: 2-3 ms a frame in the run the report measured (526 ms of pass per 5 s at 16.8 fps, 6.3 ms a frame, 71% of the samples "no room"), i.e. that pass to about 4 ms a frame; 1.3 ms a frame in the sample above. It does nothing when the card has room, which is the other regime (a 5 s stretch at 11 fps spent 571 ms with 27,646 looks again at uploaded textures and 0 held; those 48 KiB fingerprints are that regime's cost, not this one's). `VICTORY_TEXSPK_SKIP_WHEN_FULL=0` restores the old order (the look, then the refusal), and `VICTORY_FULL_CARD_PASS=0` still stops the pass at 256 refusals without telling the queue. Tests: 468 of victory-gpu's lib pass (466 + 2: `refused_at_once`'s four cases, and `slots_held_together_end_as_held_one_at_a_time`, which holds two heaps' slots in one take and one at a time and checks the due lists agree at every frame and that room brings the held ones back early). The suite has pre-existing flaky GPU tests: without this change, 3 of 10 runs failed (`views_off_their_elements_get_a_copy_of_their_bytes` and two `texture::ahead` tests), and with it 1 of 6, the same test.Pull request closed