perf: cut the layer's CPU and card-side overhead (14 changes, switch-gated) #1449

Closed
github-bot wants to merge 39 commits from github-bot/gh-1449 into main AGit
Owner

@⁠gaxolotl on GitHub · 2026-11-28 20:11 UTC · original
gaxolotl:perf/optimizations → main · +5831 −475 · 22 files · 39 commits · closed without merging

What 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 =0 restoring the old one.

The target was 30 fps rendered with VICTORY_FRAMEGEN=0. It is not reached
and 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

  • Join adjacent card copies — upstream foxhound 0.2.0-pre.5 (7c53527).
    10,541 fills/frame became 3,499 copies. VICTORY_CARD_STEPS_JOIN.
  • Align copy runs on 256 bytes when the title's constant ring is off 256.
    3,499 → 823 copies/frame. VICTORY_CARD_STEPS_ALIGN.
  • Plan the steps faster: one ReadProcessMemory a place instead of one per
    page (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

  • Mirror only the slots the host has — 41% of the 1,245,184-slot heap could
    never be mirrored. 22 MB → 9.7 MB read per frame. VICTORY_SYNC_CAP.
  • Carry the record words out of the compare pass instead of re-reading them.
    VICTORY_SYNC_WORDS.
  • Make runs of null slots with one CopyDescriptors — ~16,800 calls →
    ~368 runs/frame. VICTORY_SYNC_NULL_RUNS.
  • Cache the descriptor made for a record within a round — the title copies
    one view into many slots; each was a Create*View. VICTORY_SYNC_MAKE_CACHE.
  • Answer a round from a clean heap without asking the watch when every
    guarded block is read-only and clean. VICTORY_SYNC_ASK_CLEAN.

Write watch / refreshes

  • Journal page table as fixed-size pieces instead of an unbounded
    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.
  • Send only the dwords that changed, for copies no shader writes.
    VICTORY_SEND_CHANGED (off by default).
  • Gather send ranges across ≤256-byte gaps, one card_sides() per copy
    instead of three. VICTORY_SEND_BATCH.

Textures

  • Refuse a slot with no host texture before its 48 KiB look when the pool has
    no room; tell the queue 256 at a time. VICTORY_TEXSPK_SKIP_WHEN_FULL.
  • Take the due list from an index ordered by due frame — 108 µs → 3.6 µs at
    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.
  • One record read a slot instead of 4–5. VICTORY_TEXSPK_ONE_RECORD.
  • The pass went 1,215 → 541 ms per 5 s (~12 → ~5 ms/frame) with these.

Card compare/hash passes

  • Run-list driven passes and one dispatch per compare list via a
    descriptor table
    (SRV t0[64] / UAV u0[64]): 549 → 56 commands in replay,
    picture byte-identical. VICTORY_CARD_PASS_BATCH.
  • 256-thread piece hash with a tree (16 dependent steps instead of 64),
    bit-identical to the CPU mirror in torn.rs, proved by a WARP test.
    VICTORY_CARD_HASH_WIDE.

Build

  • Fat LTO, one codegen unit for release; the diagnostics profile skips LTO so
    victory replay builds in about a minute.

Verification

  • cargo test --release -p victory-gpu --lib: 488 passed, 0 failed.
  • WARP tests pin the null-run descriptors, the run-list and table hashes, and the
    wide hash against the CPU mirror, byte for byte.
  • victory replay of a recorded frame: picture blake3 unchanged by every batching
    change; 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.

  1. Pixels are not the cost. DLSS Performance (1280x720 internal instead of
    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.
  2. Barriers are not the cost. The replay has 3,017 barriers and every title
    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).
  3. The layer's GPU work is small. victory replay --timing detailed on a
    recorded 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 --compare A/Bs in one
process.

**@⁠gaxolotl** on GitHub · 2026-11-28 20:11 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1449) `gaxolotl:perf/optimizations` → `main` · +5831 −475 · 22 files · 39 commits · closed without merging ## What 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 `=0` restoring the old one. The target was 30 fps rendered with `VICTORY_FRAMEGEN=0`. **It is not reached and 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 - **Join adjacent card copies** — upstream foxhound `0.2.0-pre.5` (`7c53527`). 10,541 fills/frame became 3,499 copies. `VICTORY_CARD_STEPS_JOIN`. - **Align copy runs on 256 bytes when the title's constant ring is off 256.** 3,499 → 823 copies/frame. `VICTORY_CARD_STEPS_ALIGN`. - **Plan the steps faster**: one `ReadProcessMemory` a place instead of one per page (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 - **Mirror only the slots the host has** — 41% of the 1,245,184-slot heap could never be mirrored. 22 MB → 9.7 MB read per frame. `VICTORY_SYNC_CAP`. - **Carry the record words out of the compare pass** instead of re-reading them. `VICTORY_SYNC_WORDS`. - **Make runs of null slots with one `CopyDescriptors`** — ~16,800 calls → ~368 runs/frame. `VICTORY_SYNC_NULL_RUNS`. - **Cache the descriptor made for a record within a round** — the title copies one view into many slots; each was a `Create*View`. `VICTORY_SYNC_MAKE_CACHE`. - **Answer a round from a clean heap without asking the watch** when every guarded block is read-only and clean. `VICTORY_SYNC_ASK_CLEAN`. ### Write watch / refreshes - **Journal page table as fixed-size pieces** instead of an unbounded `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`. - **Send only the dwords that changed**, for copies no shader writes. `VICTORY_SEND_CHANGED` (off by default). - **Gather send ranges across ≤256-byte gaps**, one `card_sides()` per copy instead of three. `VICTORY_SEND_BATCH`. ### Textures - **Refuse a slot with no host texture before its 48 KiB look** when the pool has no room; tell the queue 256 at a time. `VICTORY_TEXSPK_SKIP_WHEN_FULL`. - **Take the due list from an index ordered by due frame** — 108 µs → 3.6 µs at 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`. - **One record read a slot** instead of 4–5. `VICTORY_TEXSPK_ONE_RECORD`. - The pass went **1,215 → 541 ms per 5 s** (~12 → ~5 ms/frame) with these. ### Card compare/hash passes - **Run-list driven passes** and **one dispatch per compare list via a descriptor table** (`SRV t0[64]` / `UAV u0[64]`): 549 → 56 commands in replay, picture byte-identical. `VICTORY_CARD_PASS_BATCH`. - **256-thread piece hash with a tree** (16 dependent steps instead of 64), bit-identical to the CPU mirror in `torn.rs`, proved by a WARP test. `VICTORY_CARD_HASH_WIDE`. ### Build - **Fat LTO, one codegen unit** for release; the diagnostics profile skips LTO so `victory replay` builds in about a minute. ## Verification - `cargo test --release -p victory-gpu --lib`: **488 passed, 0 failed**. - WARP tests pin the null-run descriptors, the run-list and table hashes, and the wide hash against the CPU mirror, byte for byte. - `victory replay` of a recorded frame: picture blake3 unchanged by every batching change; 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. 1. **Pixels are not the cost.** DLSS Performance (1280x720 internal instead of 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. 2. **Barriers are not the cost.** The replay has 3,017 barriers and every title 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). 3. **The layer's GPU work is small.** `victory replay --timing detailed` on a recorded 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 --compare` A/Bs in one process.
A frame's fills of constant buffers read a few hundred bytes each out of the
title's ring; each was a copy of its own on the card. VICTORY_CARD_STEPS_JOIN
(4096 bytes between two places of one host copy when unset; 0 restores one
copy per place) joins them into one copy into the buffer between.

Measured here (RTX 4070 Ti, Series X, 1440p): 10,541 card fills/frame became
3,499 copies/frame. Frame rate unchanged within scene noise, as the submitting
thread, not the card, is the wall on this configuration.
Borrows the DXIL slices instead of copying each stage into a Vec and feeds one
contiguous frame to BLAKE3, so short pipeline descriptions hash in parallel.
Name output is unchanged, so pipeline libraries already on disk still load
(the added test pins a name from the previous writer). Reported upstream:
18% faster hot PSO prebuild (107 -> 86 us over 380k rounds).
Upstream's launcher and the release build's \play\ set both; this fork's
script did not, so a run started from it capped neither the per-frame texture
pass nor kept the helper threads awake. Upstream measured 39.4 -> 47.0 fps and
a worst walking frame of 525 -> 145 ms with them (foxhound 3d52ac8, PR #13).
The pass over the records the title copies into its heap as bytes
(`descriptor::sync_heaps`) took 8.8-9.5 ms a frame of the submitting
thread in the measured run (work/run-fgoff.out.err, 16:38-16:42: 350-530
changed pages, 22 MB read, 10,096-14,000 records mirrored, split 3.4 ms
asking + 1.8 reading and comparing + 3.2 making, 13 rounds a frame).

Three switches, each on unless `=0`, take out work that the counters
showed was for nothing:

- VICTORY_SYNC_CAP: the title's view heap has 1,245,184 slots; the host
  mirrors the first 737,856 (the 1,000,000-view cap less the 2^18 dynamic
  slots it keeps past the title's), so 41% of what was asked about, read
  and compared could never be mirrored -- and the counters said so: 49% of
  the bytes read were past the last slot looked at. `ask_end` ends the
  range the write watch is asked about with the page that holds the last
  mirrored slot (and each part is cut there). Which records are looked at
  and mirrored is unchanged: `changed_slots` already clamped to
  `mirrored_count`, so this removes the I/O only.
- VICTORY_SYNC_WORDS: `HostHeap::mirror_words` makes a slot from the
  `[tag, i, generation]` words the pass has already read and compared,
  instead of `mirror` reading them again from title memory -- 12,000 to
  14,000 scattered records a frame, each a cache line of the 22 MB the
  reading pass has just gone over.
- VICTORY_SYNC_JOIN: the records of earlier rounds (`copied_before`) go
  into the same helper-thread batch as the changed ones instead of a batch
  of their own: one fewer wake of the `victory-records` pool a round.

And `Tracked::seen` (watch.rs) is a word a page instead of a `BTreeMap`:
the range is one heap of ~500 pages, all of them looked up at every round,
which cost 30-50 ns a page.

Expected: asking 3.4 -> ~1.8 ms, reading 1.8 -> ~1.0, making 3.2 -> ~2.9,
so 8.8-9.5 -> ~5.5-6.5 ms a frame (~0.9-1.6 fps at today's 18.9). The
line "descriptor records the title copied..." names any of the three that
is off, and its "N slots looked at" and "N MB read" now fall together.

Tests: cargo test --release -p victory-gpu --lib: 461 passed, 0 failed
(one new: `descriptor::ask_end_tests`, the cut range holds every mirrored
slot and `changed_slots` names the same slots either way).
Build: cargo build --release -p victory: ok.
The card's steps take a fill onto the card by copying its bytes into the
buffer between and pointing the fill's descriptor slot at them. A slot is a
constant buffer view, whose address must be on 256 bytes, so lay_out only
joined places whose title address was on 256 bytes; a place off them got a
copy of its own at an aligned offset.

The title's constant buffers lie in a ring a multiple of 256 bytes apart from
a base of its own, and the console needs only 16-byte alignment, so a ring off
256 bytes cost one copy command per constant buffer: the run of 2026-11-28
16:38 did 2,357 copies of 1.3 KB for 7,609 fills - 3.1 MB, command time and
not bytes.

A place off 256 bytes now joins a run of places whose addresses agree with it
in the low eight bits: its offset from the run's start is a multiple of 256,
so it lands on 256 bytes exactly when the run's first place does, and each
place still lies as far from its run's start as its address does. A run stops
at 256 KiB and joining never takes the layout past the buffer between, so the
gaps copied over stay small. VICTORY_CARD_STEPS_ALIGN=0 puts the old layout
back.

docs/gpu-work-audit.md writes down the frame's command inventory this came
from, and what of the rest of the layer's work on the card is provable or not.
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.
8,414 of the 12,117 records the heap-sync pass mirrored in the measured
run (work/run-fgoff.out.err; 4.21 ms of "making") were records that are
not views of ours: the slot must read nothing, and every one of them gets
the same descriptor -- a null 2D SRV, or a plain point sampler. Each was
made into the worker's staging heap with one `CreateShaderResourceView`
and copied into the host heap slot with one `CopyDescriptorsSimple`: two
calls of the card's for a descriptor that is already there, 4,096 times
over, on six threads contending for the driver's lock.

`VICTORY_SYNC_NULL_RUNS` (on unless `=0`):

- `descriptor::sync_heaps` takes the slots whose record's first word is
  not VIEW_TAG out of `make`, in runs of consecutive indices of four or
  more (`null_runs`). Which slots those are is exactly the set `mirror`
  takes the null path for: it decides on `tag == VIEW_TAG` alone, so a
  record left in `make` (including one whose words this pass did not keep,
  `words: None`) is mirrored exactly as before, and a VIEW_TAG record
  whose view has gone stale is left to `mirror` as well.
- Each run is given to the helper threads in jobs the size of the changed
  records' own (`records_a_job`), and `HostHeap::make_null_run` makes its
  slots read nothing: it takes their locks in batches of 64 (never across
  a multiple of the locks' count, so two runs cannot wait for each other),
  writes all of a batch's descriptors with one `CopyDescriptorsSimple`
  from a prepared run of 4,096 nulls (`NullRun`: one made, then doubled,
  as `fill_heap` fills a heap), and then per slot does the rest of what
  `make_null` and `mirror` do -- `clear_twin`, `keep(None)`,
  `note_buffer(None)` (which writes the slot's stride word). A slot that
  already showed nothing is left alone, as `mirror` leaves it, and a
  slot's lock is held until its descriptor is there, so a title thread
  making that slot meanwhile cannot have its view overwritten.
- `null_view`/`null_sampler` are now thin wrappers of `make_null_view`/
  `make_null_sampler`, which take the device: the per-slot path and the
  run are made by the same code, so a run writes what one slot at a time
  writes. `a_run_of_nulls_is_what_one_slot_at_a_time_writes` proves it on
  WARP: 32 slots filled with null UAVs of two dimensions, a null made into
  slot 0 the per-slot way, a run of ten copied from slot 4, then the bytes
  of every slot compared against slot 0's and against what they held.

The frame line adds "N of the mirrored made to show nothing by copying a
run of nulls, in M runs a frame" and names the switch when it is off.

Expected: of the 4.21 ms of making, the nulls' 16,828 D3D12 calls become
~130, which should take making to **~1.6-2.2 ms** and the whole pass from
9.06 to **~6.5-7.0 ms**; the counters to watch are "making" and the new
two fields (8,400 slots in 100-200 runs a frame).

Tests: cargo test --release -p victory-gpu --lib: 465 passed, 0 failed, 36
ignored (461 before; +3 `descriptor::null_runs_tests`, +1 the WARP test).
Build: cargo build --release -p victory: ok; cargo check -p victory-gpu
--features diagnostics: ok.
Copies in the card's memory, hash passes (R4). With
VICTORY_CARD_REHASH_RUNS=1 the pieces hashed again after ranges go up are
one pass per stretch of pieces that touch: 223 passes over 443 pieces a
frame in gameplay (2.0 pieces a pass), because a submission's changed
pieces come in small groups scattered over a copy. joined_piece_runs now
joins runs whose nearest pieces lie at most VICTORY_CARD_REHASH_GAP pieces
apart (16 by default; 0 = only those that touch) into one pass, hashing the
pieces between them as well. A pass costs the time of one piece however few
it has (64 threads, each 64 dependent steps: CARD_COMPARE), a piece hashed
beside others costs only its 64 KiB, so a gap of a few pieces is cheaper
than the pass it saves; the whole copy's span is not (a 174 MB copy changed
at both ends would hash 174 MB to save one pass), hence the gap and not the
hull. Hashing a piece that need not be hashed costs bytes and no write: its
stored hash is unchanged, as rehash_runs says. VICTORY_CARD_REHASH_JOIN=0
restores the old join; the frame line prints the join's state and gap.

What it cannot buy: in run-baseline the stage "copies in the card's memory"
does not co-vary with the pass count (164 vs 242 passes: 10.96 vs 9.32 ms)
and does with the refresh volume (14 vs 32 ms: 7.59 vs 13.71 ms) - the
sends are the cost, and that is R3's ground.

Fills (R5). VICTORY_FILL_BACK=1 (off): the scratch chunks a fill writes are
made by Host::shared_buffer (custom, write-back, L0) instead of an upload
heap, so rep movsb from title memory writes cache lines instead of going
through write combining. Scratch is only read by the card, and a write-back
L0 buffer is readable by shaders just the same (the CPU sides of the card
copies, inplace's title memory, and the buffer a card fill is read from at
CARD_STEPS=2 are made of it); on a card of its own both heaps are system
memory, so no VRAM moves. Off because at CARD_STEPS=2 the card already does
the constant-buffer fills (10-12k a frame), and what is left is an
unmeasured slice of the 2.9 ms copies-and-fills bucket.

R7 (a lower card-buffer tier): not touched. VICTORY_CARD_BUFFERS_MIN_KB=64
already cards every title buffer (a copy's size rounds up to 64 KiB) and
both launchers set it; no copy was refused for room in the measured run, so
the ~20 MB/frame copied without a card side is the title's own copies,
fills and windows, not a tier.
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.
Two changes on top of the journal-in-pieces work (refresh 13.5 -> 8.7 ms a
frame).

1. VICTORY_SEND_CHANGED, the safe subset (default OFF, as before, so a run can
   A/B it). A refresh of a copy in the card's memory takes, and sends up, only
   the dwords title memory changed -- but only for a copy no shader was ever
   declared to write (Shadow::written false; Shadow::changes_only as before).
   Such a copy's card side is only ever written by us, so the CPU's side is
   what it holds: a page the write watch counted as written, whose bytes are
   mostly unchanged, no longer copies and uploads whole. The others -- any copy
   a shader writes -- take whole ranges exactly as before (sends_changed,
   shadow.rs:2505; take, shadow.rs:4644; take_page, shadow.rs:2572). This is
   the subset report-copies R9 argued for; the old all-copies behaviour is what
   run tile1-0 broke.

   The comparison is word_runs (AVX2), and its runs are exactly what goes to
   card_changed_runs: unchanged bytes cost no copy and no send. SEND's four
   diagnostics atomics are now behind the diagnostics feature, since a page of
   every such copy pays them and several threads take pages at once.

2. A flush of more than 256 ranges -- the measured flushes are -- asked about
   each range one at a time inside the workers: some 6,900 takes of the
   journal's global read lock a frame, where the small flushes take one look
   for all of theirs. Each worker now answers a chunk of about 128 ranges from
   one look (Batch::refresh_chunk, host.rs:9209; VICTORY_REFRESH_BULK=0 keeps
   the old per-range asking). The look is dropped before any range is brought
   up to date, so an update's own asking never waits on it. FLUSHES[4]/[5] now
   count and time these asks too, and the frame line says so.

Tests (+3; 469 total, all green -- also with VICTORY_SEND_CHANGED=1 on, and
with VICTORY_REFRESH_BULK=0):

- a_copy_takes_and_sends_only_the_dwords_that_changed (shadow.rs:3162): end to
  end through Shadow::take on a copy in the card's memory. A page never taken
  goes up whole and queues the whole page; a page that did not change takes
  and queues nothing; one changed dword queues exactly that dword; two queue
  two runs; no other byte of the CPU's side moves.
- a_range_takes_the_dwords_that_changed_and_no_others (shadow.rs:3208): three
  pages, two dwords changed in the middle one -- the runs are exactly those,
  and asking again with nothing changed runs nothing at all.
- the_changed_only_path_is_for_copies_no_shader_wrote (shadow.rs:3239): a copy
  a shader writes takes whole pages whatever the switch says, and a copy whose
  shaders store what they do not declare keeps the changed-dword path it had.

cargo test --release -p victory-gpu --lib: 469 passed, 0 failed, 37 ignored.
cargo build --release -p victory: OK, no warnings.
The layer's cost is CPU and spread over ten crates; the submitting thread calls
into victory-gpu, which calls into victory-shader and victory-formats on the same
frame, and with the default 16 codegen units and no LTO those calls cannot inline
across crate boundaries. Build time 3m14s (from ~40s); run time is the point.
The stage "copies in the card's memory" is 9.0 ms a frame in the 2026-11-28
run. Its own line says 3.18 ms of it is `send::take`: 40 MB a frame taken
out of the copies' CPU sides, 959 copy commands (runs of more than 256
bytes) and 174,470 word pairs (shorter runs), each pass of the rest per
copy. The 36,378 ranges are therefore not 36,378 CopyBufferRegion calls,
and the per-range cost is the taking's layout, the pair loop, the hash runs
and the statistics - some five passes of ~10 ns - not one API call.

`VICTORY_SEND_BATCH` (on; `=0` gathers nothing, as before) joins ranges
whose nearest bytes are at most `VICTORY_SEND_BATCH_GAP` apart (256, at
most 4096): a range entry costs more than the gap bytes it adds (256 bytes
are ~0.03 us of the copy and the bus against ~0.1 us of the passes one
range goes through). The bytes a gap adds are unchanged on both sides and
go up with the range; every byte of every range is in the result, in order,
and only the gaps are added (test a_gathered_range_holds_every_byte_of_...).

A gap is never filled where a flight in the air may be writing: the copy's
side there is older than the card's, and sending it would lose a shader
write. `Shadow::pending` is that set; it is read per copy, let go of before
`dirty`'s lock (the order `Shadow::update` takes them), and walked beside
the ranges in one pass, so the guard costs a comparison per merge.

Also: one `card_sides()` per dirty copy instead of two (the "before" twins
are kept from the sends for the passes: a mutex and a COM reference saved
each), `card_has_before()` in the three places that only asked whether a
twin exists, and the ranges merged in place instead of through a second
allocation. The frame line prints the ranges "of N without
VICTORY_SEND_BATCH", so one run settles what the gathering is worth.
The pass over the textures picked by index takes the slots due four or five
times a frame - 264 takes in the 5 s of 2026-11-28 16:14 - and every take
walked every slot in the queue, 9,000 to 40,000 of them, to find the 122 to
253 due: "held 196 ms taking the slots due" of a pass that took 571 ms, while
the title's recording threads note every descriptor copy under that lock.

The order the pass needs was already made outside the lock: `texture_slots_due_known`
lets go of the queue before `Due::ordered` runs (the guard is a temporary of
the `let` that calls `due_and_census`), and it sorts only the slots due, a few
hundred. What the lock was held for was the walk itself, and the census taken
with it.

Now the queue keeps its slots by (due frame, slot) in a `BTreeSet` (`due_at`)
and the classes of the census (`Class`: uploaded in part, uploaded whole
waiting for a look again, looked at with nothing to upload) as counters, both
kept in step by the three places that change an entry: `put` (a write, memory
made due), `take_out` (done, a table read, a stale view) and `amend` (a look,
an upload in part, a look again, a hold, room again). A take looks at the
slots due and at nothing else, and the census counts are O(1).
`VICTORY_DUE_ORDERED=0` walks as before, on the same queue state: an A/B of
the take alone.

A slot due is still taken exactly once and in the same order. The set is the
same - `due_at` holds exactly `slots` filtered by `due <= frame` - and the
list handed to `Due::ordered` is the same; that order is total (write numbers
are unique), so the served list is identical whatever order the candidates
come in. `the_due_order_matches_a_walk_of_every_slot` holds the two together
after every kind of mutation, at every frame of a scripted run (writes of
slots held already too, looks, uploads in part, looks again, holds, room
again, memory made due, slots taken out), for `max` 1 and 4,096, and compares
the census too.

Measured on this box (`due_take_costs`, ignored, hot queue): 264 takes of
9,000 slots with 200 due - 3.7 us a take from the order against 15.0 us
walked; of 40,000 - 3.6 us against 108.4 us. The take no longer grows with the
queue. The game's line says 0.74 ms a take on a queue colder and contended than
this one, and what it spent was the entries walked; those 196 ms become the
~200 due ones' lookups, so about 5-15 ms per 5 s, ~180-190 ms off that 571 ms
pass (3 ms a frame at 11.3 fps; part of it comes back as uploads the pass now
reaches within its budget).

Not done, and why: the recheck skip the lead asked for next
(`VICTORY_TEXSPK_SKIP_SAME`) cannot be made to skip anything but all rechecks.
A slot is in the recheck chain only while its record is the one its upload
noted - any write puts a fresh `Waiting` with `checked` cleared (`written`),
and any note of its memory (`changed`) does the same - so "record and upload
epoch unchanged since the last look" is what being in the chain means. The
rule would therefore be `VICTORY_HEAP_RECHECK=0` in disguise, which the comment
at draw.rs:3338-3345 names: a texture the title fills after it wrote the view
keeps what its first look found for the rest of the run (run 179: the main
character's face had colour only when the world was entered under the card's
line). And the looks are not duplicates that a cache could remove: the run's
counters add up exactly - 27,646 looked at again + 4,361 the same + 1,282
uploaded ahead + 175 uploaded in the list + 2,280 read through tables + 2,595
memory not there + 11 no more of it + 66 nothing = 38,416 slots taken, one
outcome each. So the 151 ms per 5 s those looks cost in that regime stands
unless the sample itself is weakened, which is a picture decision, not a
bookkeeping one.

Tests: 474 of victory-gpu's lib pass (473 + 1, and the ignored
`due_take_costs`), 38 ignored. The suite's pre-existing flaky GPU tests still
flake (1 of 3 runs once, then 20 green; without this change 3 of 10 runs
failed earlier in this session); the new test is deterministic.
A refresh asks the journal again and may flush a list of its own; holding the
thread-local borrow across Self::update panicked the submitting thread with
'RefCell already borrowed'. The room is taken out before the loop and put back
after it.
card_pass dispatched one pass a run of 64 KiB pieces, and a pass costs the
time of one piece however few it has: the replayed capture's frame has 549
of them, 397 compares and 152 hash passes after sends.

CARD_COMPARE now takes a run list (compare == 3): a record a run, and a
group a piece of it, found by binary search over the records' ordinals, so
a copy's runs go in one dispatch (up to 65,535 pieces each). The pieces
hashed and the dwords of differs written are the same ones. The run lists
are a mapped upload buffer, bump-taken by plans and given back with the
results area when none is out.

The replay gets --batch-card-passes, the same edit, to measure it without
the game.

Measured (victory replay --compare, 3 loops, one process): 549 -> 498
passes, hash 152 -> 104, compare 397 -> 394; the picture is byte-identical
(blake3 48c623e0405273d4, unchanged and batched). A no-op --compare
control moves the frame by -2.18 ms, so the frame delta (-3.07 ms) is ~1 ms
at best: a frame's compares are ~4 copies a submission, one run each, so
one dispatch a copy cannot cut them. A list's copies in one dispatch (a
descriptor table over them) is the next lever.

VICTORY_CARD_PASS_BATCH=0 restores a dispatch per run.
One dispatch a copy was not the lever: a frame's 549 passes (397 compares,
152 hash passes after sends) are ~7 copies a submission with one run each,
so 549 became 498. This binds the copies of a list as descriptor tables
instead: SRV t0[] a copy's buffer, UAV u0[] its before hashes, and a
64-byte run record names its copy's entries, so a whole list is one
dispatch. The per-copy pass stays for VICTORY_CARD_PASS_BATCH=1 and the
per-run one for =0. A plan's tables come from a ring of a shader-visible
heap with the same lifetime as the run lists, and a list falls back to a
copy at a time if they do not fit.

Replayed (--compare --batch-card-passes, 3 loops, one process): 549 passes
-> 56 (compare 397 -> 32, hash 152 -> 24), picture byte-identical (blake3
48c623e0405273d4) - but the frame is not faster: 59.52 vs 60.02 ms (44.33
vs 44.05 in another run), the passes 7.68 vs 7.56 ms. In the same session
--skip-hash-passes takes the 549 passes away and the frame falls 58.33 ->
50.59 ms: 7.7 ms for the same 549 pieces. The cost is the 35 MB of ~550
copies read a piece at a time, cold, not the dispatches: passes of one
piece cost 1.1 us with their buffers warm (card_compare_costs: 55 GB/s of a
pass of one, 1,790 GB/s at 64 a pass), and the small passes were already
overlapping. The next cut is the per-piece cold read (wider groups, a
shorter dependent chain), not the count.

The replay mirrors it in --batch-card-passes with its own heap and the
spare descriptors the static tables need; a WARP test checks the table
shader against a pass per copy.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 20:17:09 +00:00
`card_compare_costs` now runs each shape twice: with `differs` in the card's
memory and in the PC's (the live one is the PC's), to see what the compare's
4-byte result writes over PCIe cost. They cost nothing: 80 rounds of 5
passes of one piece is 0.44 ms with the results in the card's memory and
0.47 ms with them in the PC's.

A new ignored `card_compare_costs_cold` gives each pass a copy of its own,
as a frame's do: 512 copies of 64 KiB, one done in each, are 1.93 ms, 3.8 us
a pass — against 1.1 us with one buffer warm. So the cold read is part of
what a frame's passes cost (~14 us a pass over 56 lists), but not all of it:
the rest is their context, 112 short lists among the title's work, which
fewer dispatches do not change (the previous commit measured 549 -> 56
passes with the frame unchanged).
--inline-card-passes moves a submission's compare list's commands to the
end of its last title list (the place they ran in order anyway) and takes
the list out: the way a layer that recorded them there would. The hash
lists are not moved: they are submissions of their own, and moving one into
a later submission changes the resources' states against the replay's
copies of what the CPU wrote - it lost the card twice - while the host
cannot record into the title's closed lists either (its sends are known
only when the submission is).

Measured (--compare --batch-card-passes --inline-card-passes, 3 loops):
49.12 -> 48.72 ms, the same 56 passes, 32 lists fewer, picture
byte-identical; the no-op control in the same session moved the frame by
+0.10 ms. A submission's list boundary is worth ~0.4 ms, not the ~7 ms the
passes cost: the count of lists is not where that is, and a host-side
inline (which would need a placeholder tail on every title list) is not
worth it.
Two switches, each on unless `=0`, for the two biggest parts of the pass
(12.38 ms a frame in the heavy run: 3.22 asking, 2.71 reading, 5.10
making).

VICTORY_SYNC_MAKE_CACHE -- 10,738 records were mirrored a frame, and each
was a `Create*View` into the worker's staging descriptor plus a
`CopyDescriptorsSimple` into the host slot, the same two calls of the
card's for a record the title had already had made: it copies one view
into many slots of a table. `HostHeap::make_slot` now keeps the
descriptor made for each record key in a heap of ours the card does not
see (`MadeCache`, 2^14 slots, cleared at the start of every round by
`make_round_next`), and a slot whose key was made earlier this round is
one `CopyDescriptorsSimple` from it: no create, and no `make_twinned`
either (the buffer/texture lookups it does). A miss still costs the same
one create and one copy it did, the descriptor being made into the
cache's slot instead of the thread's; a slot the host cannot make, a
sampler heap, a heap with raw twins, and a round that wants more than
2^14 descriptors all take the old path unchanged. Draw-made slots
(`for_draw`) go through it too: what is copied is the same descriptor for
the same record key, and the kept resource travels with it.

VICTORY_SYNC_ASK_CLEAN -- the write watch asks about the whole heap at
every round (13 rounds a frame), and a round of the title's writes is
some 26 of the heap's 361 blocks. A block of this heap is read-only by our
hand: a write to it is a fault, and the fault tells of it. So a round that
finds every block of the range read-only, clean, not opened and not told
(`watch::untouched`) has nothing new to mirror and asks nothing at all --
no `materialize`, no journal, no `Asking` hold (which a submission's own
asking, held whole with `hold_all`, can make a round wait for), no guard
walk. A page a take could not read (`SyncPart::short`) stands the
shortcut down for that heap from then on (`Tracked::short_read`), and a
range that is not guarded view memory never takes it.

Expected (not measured: no game run): making 5.10 -> ~3.4-4.2 ms if a
third to a half of the mirrored records are repeats of a key already made
that round (the log's own evidence for repeats is the 49,515 draw-table
records and 16,850 waited ones, most of which are repeated views); asking
3.22 -> ~2.0-3.0 ms, the rounds that find nothing becoming ~2 us, the ones
that find writes unchanged (a block written since the last round must be
re-armed, and that is the guard's cost, not the asking's). The line says
how many descriptors the cache made and how many slots it served, and
names each switch that is off.

Tests: cargo test --release -p victory-gpu --lib: 466 passed, 0 failed, 36
ignored (465 before; +1 `made_cache_tests::a_round_keeps_only_its_own`,
that a round keeps nothing of the round before and its slots run out).
Build: cargo build --release -p victory: ok; cargo check -p victory-gpu
--features diagnostics: ok.
The stage "copies in the card's memory" is 11.7-14.3 ms of a 51-54 ms
preparing in the 2026-11-28 runs (60 submissions a frame), and "planning
steps done on the card" 7.4-8.8 ms of it; neither had a breakdown.

Planning (`VICTORY_CARD_PLAN_FAST`, on):

- The line "planning the card's steps, per frame" now splits it into
  choosing the steps, finding what each reads and whether its pages are
  there, laying out the buffer between, bringing what they read up to
  date, recording their list and pointing the slots, with the kernel reads
  and the steps counted.
- `mapped` asked each page of a place for a byte through the kernel. A
  read of the whole place costs what one page's byte costs (276 ns against
  240 for 500 bytes: `examples/probe_cost.rs`), so it reads the place once
  (up to 64 KiB) and its pages are known from then on: the same answer,
  since a read of `[from, to)` succeeds only if every page of it is there,
  and a failed read still falls back to the page-by-page search that names
  the page. 11,500 fills a frame at ~1.3 pages a place: some 4 ms of page
  probes become ~2.5.
- A fill's destination (`FillTo`) was looked for per step, a lock of its
  list taken for each (11,500 a frame); it is taken in `does_of`, which
  walks the same steps under one lock each.

The copies' stage (`VICTORY_CARD_HASH_ORDER`, on): its line "copies in the
card's memory, its parts per frame" gives gathering what changed, the
declared writes and the views picked, the sends and hashes, and the
compare. The hash runs are built from ranges gathered in order, so their
first pieces only grow, and `joined_piece_runs` no longer sorts the
64,000-85,000 of them a frame; a test pins that the unsorted and the sorted
joins agree.

No write path changes: a place that is not all mapped is still refused as
before, and a run with either switch off prints the old parts for the
comparison.
The texture pass is 1,215 ms per 5 s in the run of 2026-11-28 20:08 (14.7
fps, a full card, 152 passes, 48,414 slots taken, 154 takes of the due list).
What the line's parts are, and what the "rest" is, from that run's own lines:

  428 ms "the rest": 82 telling the queue what came of each slot, 41 reading
  the slots' records, 53 fingerprints after uploads (the recheck chain's
  seeds, 8,174 uploads at 6.5 us), 43 handing first uploads to the copy queue
  ahead, 94 slots shown after their upload / flipped / made at once (a second
  kind of view making, inside the rest), 10 asking whether a staged texture's
  memory is all there, 41 other checks, 64 not told apart. (Not in the
  1,215 ms: 300 ms before the loops, of which 216 taking the slots due, 62
  making slots due, 19 views made again and slots flipped.)

Two cuts, both about the two biggest single items after the views:

1. The take (216 ms). It was bounded by 4,096, but a pass stops at its time
   after ~318 of the 3,857 slots that were due: 154 takes walked, looked up
   and sorted 594,000 entries to serve 48,414. Now a take brings twice what
   the pass last served, between 256 and 4,096 (`TAKE_CAP`, `note_taken`):
   ~636 in that run, so the take's walk, lookups and sort fall by about six
   times, to ~35-50 ms per 5 s. The order is the same, so the slots served are
   the same; the ones the bound leaves out are those after the ones a pass
   reaches, and they move up as those before them are told of. `on_time`, the
   count that decides the catch-up budget, is now the census's true count
   rather than the length of the (bounded) take.

2. One record a slot (the pass's title-memory reads). The pass asked the
   title's memory for the slot's record four or five times a slot: for the
   view it holds (`descriptor::view`), for "shows another view of it"
   (`texture_slot_shows_other`), for "made from it" (twice), for the mirror,
   and for the show-after after an upload. Now the record's words are read
   once (`descriptor::record_at`), and the view (`descriptor::view_of`), the
   key (`descriptor::key_of`), `texture_slot_made_from_key`,
   `texture_slot_shows_other_key` and `mirror_words` all take those words: one
   read of title memory and one registry look a slot instead of four or five,
   which the layer already avoids elsewhere (`mirror_words` exists for the
   heap-sync path for the same reason). Expected 25-100 ms per 5 s (48,414
   slots x 4 reads saved), and it makes the record a slot acts on one snapshot.

The two answers the lead asked for, from the code and this run:

- The slots' views (201 ms, plus the 94 ms of "shown" and 19 ms of "views
  made again" inside the rest): a view is NOT made per slot per frame. A slot
  made from the record it still has is answered from its quick key, without
  the lock, and makes nothing. A record rewritten to another view of the same
  placed texture (a title streaming more levels in: 70,692 of these in that
  5 s) keeps the old view and makes nothing (`KEPT_VIEWS`, `MIRROR[1]`). A
  descriptor is made once per (slot, record): `MIRROR[2]` now counts them and
  `MIRROR[3]` their nanoseconds. So the 201 ms is the slow-path bookkeeping
  per record change (the slot's lock, the views' registry, the spans' stale
  sweep) and the descriptors for genuinely new records, plus what
  `placed_texture` costs - which is now timed apart as its own part
  (`HEAP_TEXTURE_NANOS[7]`), so the next run says which of the two it is.

- The host copies (198 ms): `hosted` makes one host texture per title texture
  - the device's resource, its state, sometimes a twin - and a copy already
  made costs a mutex and an Arc clone. Nothing is made per frame for a texture
  that has one. `HOSTED[0]`/`HOSTED[1]`/`HOSTED[2]` now count the asks that
  found one, the ones that made one and the nanoseconds making them took, so
  the next line says whether the 198 ms is creation for streaming or churn
  (made, let go by `let_go_idle`/`slot_evict`, made again). What this run
  shows is that replacement of a copy by one with more levels is 3,991 of
  123,069 uploads since the start (3%), not the bulk; 3,682 copies were alive.

The rest is now explicit in the log: the "its rest" line splits the commit
reserve and the slot's texture (what fills it, whether it is staged, whether
the device is gone, letting its staging go) from the other checks, and "in
all" splits the placed texture's resource from the slots' views. A new line
counts the slots' views and the host copies as above (the draws, the heap's
records and the pass together, since they share those paths).

Tests: 484 of victory-gpu's lib pass (482 + `a_take_brings_what_a_pass_served`
and `a_record_key_names_its_view_or_nothing`), and the same 484 with
`VICTORY_TEXSPK_ONE_RECORD=0` and with `VICTORY_TEXSPK_DUE_TAKE=0`. The
release build of `victory` is clean.
The 64-thread chain is 64 dependent 16-byte loads a thread and then the
serial fold of the 64 hashes: 128 steps one after another. With the gate on
(the default; =0 keeps the old chain) a piece is hashed by 256 threads, 16
steps each, and their hashes are combined pairwise, eight levels, to the
same 16 bytes; the same 31 bits are folded over them for the flag.

The hash's value changes, so the CPU mirror changes with it: torn's
hash_with/parts_with take the scheme and hash() follows
card_hash_wide(); the AVX2 path stays the narrow chain's. The shader is one
source with #if WIDE, compiled with that define, and a WARP test holds the
two sides together: pieces of 16 bytes to 64 KiB, both schemes, 16 bytes
for 16 bytes against the CPU mirror, and the folded 31 bits in a compare.

Measured (--compare --batch-card-passes, 3 loops, one process): passes
7.01 -> 6.93 ms wide and 7.00 -> 7.08 narrow; frames 46.08 -> 43.99 and
45.89 -> 42.55; the no-op control in the same period moved 45.90 -> 45.05,
its identical passes 7.42 -> 6.98. The chain is not what the frame's passes
cost: warm passes of one piece are 0.37 ms (wide) against 0.42 (narrow) per
400, cold copies 0.07 against 0.08 ms per 512, while the frame charges
~7 ms for the same 549 pieces either way. The wide hash is kept (a little
faster warm, bit-identical) behind the switch.
github-bot closed this pull request 2026-11-29 10:44:41 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!1449
No description provided.