Repository navigation
Conversation
…ORY_LOOKUP_CACHE=0: every ask goes to the tables) Every bind of a draw asks for the host copy of each buffer it reads: under the tables' one lock, among the 64 buffers that start below the address, then for memory outside buffers under the windows' lock. In the prologue cell that is about 245,000 asks a frame from the title's six recording threads, 54 ms of their time together (VICTORY_PROFILE). A thread now keeps what each ask (address, length, kind) found, weakly, for as long as the tables have not changed: 91 % of the asks are answered there. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… PR #1237; here VICTORY_LOOKUP_CACHE=1|alt, off by default) Every bind of a draw asks for the host copy of each buffer it reads, under the buffer table's one lock (and the windows' lock for memory outside buffers): about 245,000 asks a frame from the title's recording threads by the pull request's profile, 54 ms of their time together. A thread keeps what each ask found, weakly, for as long as the tables have not changed (a counter bumped where a buffer is registered or released, a copy taken out of a table, a window made or let go). Its author measured 117.2 -> 104.2 ms a frame on an RTX 3090 Ti on this tree (a183ea2, Series X profile, one run each). Read whole here: every place the tables of lookup change bumps the counter. Applied as it is but for the switch (on by default there; off here until a run of ours has carried it, with an alternating form) and the log line placed by hand. Not run in a game here. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
I found two stale-cache cases while testing this branch. A recording thread could cache the old buffer under the new generation while registration was waiting for the lock. A loose window could also still be handed out after the idle sweep had removed it. Both regressions fail on cdf74b5 and pass with the fixes on my RX 7900 XT. Fix and focused tests against your branch |
|
AI-assisted local A/B on RTX 5070 Ti, Windows, Series X profile. Same warm-cache build from upstream
In sampled on-mode timing lines, around 205k–233k buffer lookups per frame came from the thread-local cache. Frame time was similar in this boat view with the cache off or on. This measures one stationary scene on this PC. |
… PR fxceless#1237; here VICTORY_LOOKUP_CACHE=1|alt, off by default) Every bind of a draw asks for the host copy of each buffer it reads, under the buffer table's one lock (and the windows' lock for memory outside buffers): about 245,000 asks a frame from the title's recording threads by the pull request's profile, 54 ms of their time together. A thread keeps what each ask found, weakly, for as long as the tables have not changed (a counter bumped where a buffer is registered or released, a copy taken out of a table, a window made or let go). Its author measured 117.2 -> 104.2 ms a frame on an RTX 3090 Ti on this tree (a183ea2, Series X profile, one run each). Read whole here: every place the tables of lookup change bumps the counter. Applied as it is but for the switch (on by default there; off here until a run of ours has carried it, with an alternating form) and the log line placed by hand. Not run in a game here. (cherry picked from commit 32be36d)
3.1 Driver-call dedups from VIctory-NVIDIA (each on unless =0):
- ca1d519, VICTORY_BIND_CACHE: set_targets does not set the same
render targets and depth again. The views are compared (title
resource, host texture, record words), not the handles. Merged with
the target formats of Phase 2: formats are taken for every call,
views are made only when the targets change. replay() forgets the
targets for the new host list after a cut, State::reset() does on a
title reset. The other OMSetRenderTargets calls here are on lists of
their own (indirect, over) or at a list's close (the depth plane
pass), after the title's last draw.
- b32fb99, VICTORY_DECLARE_ONCE: a range shaders write is declared
once until the list next writes title memory (Copy or Run steps,
Deferred::title_written). The key holds this tree's `marked` flag
too. Exact: Shadow::writing already takes each byte once per
submission and later refreshes copy into the snapshot, so the
skipped steps only repeated a flush and a lock.
- ab86ef7: a pipeline a list binds again is not kept and named
again (HostList::bind_pipeline). With the card's clock per pipeline
(cardmeter) every bind still ends the span before it.
- c96525d: a root constant buffer not 256-byte aligned is filled
into scratch once per host list until the list next writes title
memory (HostList::fill_scratch). Each part after a cut is a host
list of its own, with its own scratch.
3.2 fxceless 32be36d (PR fxceless#1237) with PR fxceless#1245, VICTORY_LOOKUP_CACHE=1|alt
(off by default): a thread remembers what its asks for a buffer's
host copy found while the tables are unchanged. fxceless#1245: the
generation is bumped after registering under the table lock, and a
cached window is checked against the window table under its lock
before it is handed out (both fxceless#1245 tests). Here as well: a buffer's
copy in place is never cached, since in_place_let_go takes those out
when their memory is about to be remapped. Every table change in this
tree bumps the counter (register, unregister, in_place_let_go, the
idle sweep, window creation).
3.3 fxceless PR fxceless#1240, the exact parts only:
- VICTORY_RAM_TRIM_MB (off unless set): below that much available
memory, the lesser of physical RAM and remaining commit (as fxceless#822's
committed_cache_idle_ms already weighs them), the sweep runs every
500 ms and also drains the reuse pools: CPU snapshot buffers, spare
texture staging buffers, idle host lists past 16.
- A descriptor page of zeros whose slots were never looked at is not
fingerprinted (mirror_copied_page).
- Not taken: VICTORY_TEXTURE_MAX_DIM (drops detail), skipping the
zero fill of staging slices above the tail mip (would upload stale
bytes where tiles are mapped), the batched mirror (a rewrite of
mirror(), whose per-slot logic differs here), and the PR's own
VICTORY_BIND_CACHE (3.1 has one).
3.4 fxceless PRs fxceless#1230, fxceless#1232, fxceless#1233:
- fxceless#1230: contiguous readback pieces of one source join into one
CopyBufferRegion (VICTORY_READBACK_COALESCE=1; off), with its tests.
- fxceless#1232: join_ranges compacts in place (same result; test against
the allocating form).
- fxceless#1233: AVX2 changed-run detection (VICTORY_CHANGED_RUNS_AVX2=1 and a
runtime avx2 check; off). This tree has no SSE2 form of
changed_runs, so the AVX2 kernel and its mask walker were taken
alone and checked against this tree's walk
(avx2_changed_runs_match_the_walk).
3.5 WIDE scalar buffer loads (fxceless c36971b, shader part as in
VIctory-NVIDIA 200a9cc) on bit 128: bit 64 stays MERGE. Not in ALL;
VICTORY_SHADER_OPT=255 (or any value with 128) asks for it, since
parse_shader_opt now masks with KNOWN = ALL | WIDE. The cache key
already holds the whole mask. raw_dwords reads one console load four
dwords a call on both raw smem paths; test
scalar_buffer_loads_read_the_same_dwords_one_call_or_four (Windows,
software adapter).
Gate: Windows check, diagnostics check, clippy -D warnings (default and
all features), tests 342 passed / 0 failed / 8 ignored, policy 230 files
ok, viz. victory-gpu tests and the Windows-only shader tests are built
and linted, not run (pc-home offline).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ORY_LOOKUP_CACHE=1|alt, off by default) From fxceless/victory-fork 32be36d and bc6ee68 (fork PRs fxceless#1237 KyleS98, fxceless#1245 UwUCammie), re-implemented on our tables. Every bind of a draw asks `shadow::find`/`find_any` for the host copy of each buffer it reads: about 245,000 asks a frame by the pull request's profile. With the switch a thread keeps what each ask (address, length, kind) found, weakly, for as long as the tables have not changed (TABLES_CHANGED). fxceless measured about 14 ms less CPU per frame (their diagnostics run 293); ours already reads the buffers' table under a readers' lock, so the gain here is to be measured (`alt`: twenty seconds with, twenty without). What counts a change, on the right side of it and with the table's lock held (fxceless#1245: a copy that leaves is counted before it leaves, an entry that comes after it is in; a remembered answer is used only if the count is the same again after its handle was taken): - register (after the insert; also before it when the same key was there), unregister (before the removal); - a window made in `loose` (all three ways: in place, GPU upload heap, PC/card memory; `window_in`); - in_place_let_go, windows and buffers' copies (`take_out_windows`, `take_out_buffer_copies`, counted only when something goes); - the idle sweep (`sweep_out`), which looks at each window's holders again after it counted, so a window a thread took from its memory just before stays; - readonly's put_in_place_of (moves to and from GPU upload heaps, cold put-backs, moves back for shader writes and for the raw-address directory): counted before and after the swap. A copy made for a buffer's entry on its first ask is no change (no ask under the same count can have found another). Taken-out copies stay alive while held (retire), so a handle taken a moment before a change names live memory. Frame line "asks for a buffer's host copy per frame: ... answered from the asking thread's memory ..., ... from the tables; ... changes of the tables" when the switch is set. Tests: every change path counts (thread-local count), registration and release count under the lock (fxceless#1245's test), the sweep's second look comes after the count, and the remembered ask forgets on a change, on a copy let go, and on an answer found across a change. Not run in a game. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@UwUCammie both cases are real, thank you. The first one is plainly my mistake: @SkillIssueXO thanks for the paired run. No gain in a stationary view at 150 ms a frame is consistent with what I measured: the saving is lock time on the title's recording threads, and it shows where they are the limit. In the prologue cell on a 3090 Ti that was 54 ms of thread time a frame over six threads (117 -> 104 ms on Series X, 84.6 -> 72.5 ms on Series S, switch off and on, same binary); the maintainer's run 293 puts it at about 14 ms a frame. Where the frame waits on something else, as in your boat view, it gives nothing. I am not claiming a general frame-rate gain beyond those scenes. Since AI-assisted (Claude Code, Claude Fable 5.2). |
… PR fxceless#1237; here VICTORY_LOOKUP_CACHE=1|alt, off by default) Every bind of a draw asks for the host copy of each buffer it reads, under the buffer table's one lock (and the windows' lock for memory outside buffers): about 245,000 asks a frame from the title's recording threads by the pull request's profile, 54 ms of their time together. A thread keeps what each ask found, weakly, for as long as the tables have not changed (a counter bumped where a buffer is registered or released, a copy taken out of a table, a window made or let go). Its author measured 117.2 -> 104.2 ms a frame on an RTX 3090 Ti on this tree (a183ea2, Series X profile, one run each). Read whole here: every place the tables of lookup change bumps the counter. Applied as it is but for the switch (on by default there; off here until a run of ours has carried it, with an alternating form) and the log line placed by hand. Not run in a game here. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> # Conflicts: # crates/victory-gpu/src/host.rs # crates/victory-gpu/src/shadow.rs
What
Every bind of a draw asks for the host copy of each buffer it reads (
shadow::find/find_any→lookup). Each ask:The built-in profiler (
VICTORY_PROFILE=1, sampled in the world only) shows what that costs in the prologue cell:shadow::lookupat 54 ms of their time together per frame, underdraw::readable, which is the second-largest part ofState::bind(185 ms a frame over the six threads).They ask for the same ranges again and again. With this PR a thread remembers what each ask (address, length, kind) found:
let_go_idlelooks at the strong count, as before);loosedoes when it hands one out: stampsused, widensasked, and counts unsized asks.VICTORY_LOOKUP_CACHE=0sends every ask to the tables, as before. A line on the frame-rate log counts both kinds.Measured
RTX 3090 Ti, warm cache and pipeline library, prologue cell. Each row is the same binary with the switch off and on, using the README's run-253 switch set plus
VICTORY_CARD_BUFFERS_MIN_KB=64 VICTORY_CARD_BUFFERS_MB=1280.a183ea2+ this PR only9c184b3+ #798 + #1081 + #1171 + #1227 + thisEach "off" figure is one run. On the Series S tree the build before this change measured 77.2 ms in the same spot, so read the gain there as somewhere between 5 and 12 ms.
Picture: the cell is the same with and without, compared from grabs.
What is left in
State::bindBy the same profile, the largest part is
HostHeap::mirrorand what it calls (buffer_copy,make), with 22 ms a frame of the recording threads waiting for its lock. I haven't touched that here.AI-assisted (Claude Code, Claude Fable 5.2); runs and grabs on my machine; no game data.