Skip to content

VIctory-reloaded picks: submit-thread and write-watch work, memory fixes (all switches off) - #20

Open
oceansde012 wants to merge 32 commits into
mainfrom
claude/project-thread-8a9gdp
Open

oceansde012 wants to merge 32 commits into
mainfrom
claude/project-thread-8a9gdp

Conversation

@oceansde012

Copy link
Copy Markdown
Owner

Requested by Vlad · project thread

What

30 clean cherry-picks (-x) from Biskwit/VIctory-reloaded (GPL-3.0, Vice-Tay base, 28.8–29.6 fps Series S on i9-12900K + RTX 4090) onto f4b48ad, plus:

  • a DeepSeek commit that turns every new switch off by default (on with =1): VICTORY_PLACE_APART, VICTORY_PLACE_LANE, VICTORY_FAULT_FAST, VICTORY_REFRESH_STAMPS, VICTORY_WIDE_WAKE, VICTORY_XMEM_WATCHED, VICTORY_AMBIENT_DEPTH, VICTORY_CLEAR_UAV; and renames reloaded's shader-hash VICTORY_LAND_NOT to VICTORY_LAND_NOT_SHADERS (PR adanaport picks: VICTORY_LAND_NOT + VICTORY_LIST_LOW (off by default) #13 already uses VICTORY_LAND_NOT for lengths);
  • a revert of test(gpu): depth-bounds test without library loads (needs Vice-Tay's library::loads()).

Also off by default already: VICTORY_CARD_NEAR, VICTORY_ONE_WALK, VICTORY_STALE_WALKED, VICTORY_PLAN_ONCE, VICTORY_AHEAD_INDEX, VICTORY_ASK_OWN, VICTORY_UNDER_WHO.

Always on (no switch): the write-watch journal in 4 MiB pieces instead of a B-tree (same answers, test against the tree), and fixes d59b637 (upload no longer stops an alias copy), 0d7de37 (bake texture pass per heap), 3b82381 (first piece in parallel compares), 69e724e/46902d2 (only matter with FAULT_FAST), replay/diag fixes.

Not taken

  • SUBMIT_SPLIT, OFF_LINE, PRELUDE_OFF_LINE, PRESENT_OFF_LINE, UNDER_MASKS (about −7 ms together on their PC): conflict with our host.rs, Codex job later.
  • Fixes 38b93f2, 7455510, d3c43c1, f491203, b5d0365: conflicts.
  • Shader translator fixes (f5e21d4, ab28295, 652e07e, …): they change the picture, need their own A/B.
  • 445679a: touches the XCL-derived console_insn.rs.

Checks

Report: reports/reloaded-2026-11-28.md in project files.


Generated by Claude Code

Cause: `victory replay` of a Series S cell capture (frame 2203, 80,241
resources) could not run on the RTX 4090.
- 3,665 buffers placed in heaps opened from existing memory were refused
  ("parameter incorrect"): the heaps lose cross-adapter sharing (DROP)
  but their buffers kept ALLOW_CROSS_ADAPTER. The same fix as Vice-Tay
  9ba5661 (replay of renderer port 1), found independently here.
- With those made, loading the contents lost the device (TDR, nvlddmkm
  153): DRED put the page fault in a committed default-heap buffer made
  with CREATE_NOT_RESIDENT (heap flag 0x800). The host makes such memory
  resident itself; the replay never did, so its first copy faulted.

Change: resources drop ALLOW_CROSS_ADAPTER, and heaps and committed
resources drop CREATE_NOT_RESIDENT, like the other flags a replay has no
use for.

Measured: the capture now replays, 34.7 ms on the card (median of five
loops, list timing), the picture at 60-61 dB against the presented one.

Checks: clippy (workspace, all targets, with and without all features),
cargo xtask policy, tests/replay.rs passes. victory-gpu's lib tests: two
failures that are not this change's: depth_bounds_pipeline_loads_and_
filters_draws (no library loads on NVIDIA since d8388ae) and a timing
test of the timeline that passes when run alone.

(cherry picked from commit 04d5dc78cb9ec97bc80a2c87cb0ea4b7408a9366)
Cause: a replay that lost the device said only "the GPU will not respond
to any other command (0x887A0006)", with no step and no command: the hang
fixed in the commit before took three TDRs to place.

Change: with --breadcrumbs, the replay names its lists ("list <n>
(submission <i>)", as --listing numbers them) and its resources
("resource <id> <place>"). When the device is lost while loading the
contents, making the copies to restore from, putting back what a run
changed or running the frame, the error says which lists stopped at which
breadcrumb, the page fault's address, and the resources alive and freed
there. docs/replay.md says so.

Measured: it named "resource 1185 Committed { kind 1, flags 2048 }" for
the page fault the commit before fixes. Without --breadcrumbs nothing is
named and nothing changes.

Checks: clippy (workspace, all targets, with and without all features),
cargo xtask policy, tests/replay.rs passes.

(cherry picked from commit 5e5be056c0678aceeb1e6e8f225b7d5829d024ce)
Cause: XMemAllocDefault served every block from the host heap, whose
memory is not write-watched. A host copy of such memory is copied whole
at every refresh ("copied whole (memory not watched)" on the frame
lines). In the Series S cell one 21 MB block (0x1412200 bytes, written by
shaders, read by the title) was copied whole twice a frame: 42 MB and
4.4 ms of copies a frame, both on the frame's critical path in a timeline
(ssfps-m1-tl: "a copy's refresh" of 2.1-2.6 ms, once on the submitting
thread, once on a helper it waited for), and sent up whole to its copy in
the card's memory each time (21 MB a frame up, 21 MB fetched, "321 of
them both ways") though the landing had just put the card's bytes there.
The title's own VirtualAlloc was looked at first: it allocates none of
these.

Change: XMemAllocDefault blocks of 1 MiB and more (with their header),
aligned to 64 KiB or less, are a reservation of their own with
MEM_WRITE_WATCH; XMemFreeDefault releases them (the header's size has its
top bit set), telling the GPU side first, as the 32-bit blocks do.
VICTORY_XMEM_WATCHED=0 keeps them in the heap. Watched, the block's
refreshes take only the pages the title wrote, and the pages the landing
wrote are left as the card has them (VICTORY_LAND_ECHO).

Measured (Series S, prologue cell, warm, i9-12900K + RTX 4090; medians
of the frame lines in the settled world, ms a frame):

| tree, launches | frame | card busy | copy-back | submit thread | its refreshes | copied whole |
|---|---|---|---|---|---|---|
| ss-fps (2)                        | 57.6 / 57.3 | 42.4 / 45.1 | 24.2 / 24.0 | 55.7 / 55.0 | 15.5 | 4.4 |
| ss-fps + this (2)                 | 55.8 / 57.0 | 49.0 / 48.5 | 28.5 / 30.0 | 53.7 / 54.8 | 12.7 | 0.1 |
| the merged tree fcfb681 (3)       | 58.0 / 60.4 / 59.5 | 44.2-46.4 | 24.8-25.2 | 55.0-56.5 | 16.7 | 4.4 |
| fcfb681 + this (2)                | 53.8 / 54.0 | 45.9 / 43.7 | 26.0 / 25.4 | 51.6 / 51.2 | 13.0-13.6 | 0.1 |

Alone on ss-fps the frame gains ~1 ms: the card is then the limit (busy
49 of 56 ms, idle 7). With the card's load taken down by 53c4db9 and the
threads of 8cc56ce, the three together: 50.7 ms (bcombo-1; card busy
34.1, submitting thread 48.8). Copy-back grows 4-6 ms (the landing writes the
block's pages now that it is watched), and stays under the frame.

Picture: unchanged over frames 1500-3600 (wall colours in the usual
range). The stepped silhouette on the left wall (scratchpad silhouette.py)
showed in one of these 9 launches, ww3-1 on the merged tree, as in 3 of 19
merged launches with or without this; none on ss-fps. A launch with VICTORY_REFRESH_CHECK=1 found no watched
block stale after a refresh (its 65 warnings are all of one view of
console memory at 0xac6160000, which this leaves alone).

Checks: clippy (workspace, all targets, with and without all features),
cargo xtask policy, victory-hle tests (a new one: big blocks are
write-watched and aligned, and freed; a block aligned to 2 MiB stays in
the heap).

(cherry picked from commit f5ef19e39ef2c914834a5a1eea6b6a87163cb8b4)
depth_bounds_pipeline_loads_and_filters_draws asserted that the second
make of its pipeline came from the pipeline library. Since d8388ae the
library is not loaded on NVIDIA (VICTORY_LIBRARY_LOAD=1 loads it), so
the test failed on the RTX 4090 at that assertion. The assertion now
holds only where the library is loaded, as the mesh pipeline test
already skips; the depth-bounds draw checks still run everywhere.

Checks: the test passes on the RTX 4090 with and without
VICTORY_LIBRARY_LOAD=1.

(cherry picked from commit 5ae2e3e7ff84665aa42835e7e1c052a889c58889)
Cause: the relay fetches some 64 MB a frame from copies in the card's
memory and merges it into title memory (Series S cell, main 7cae3c5:
~1,100 pieces, merging 14-15 ms on 3 threads, 38-41 ms of their time; the
relay 25 ms landing in all). Mapped to the shaders that write them
(replay --flow of capture card-cell, the containers' names): 21 MB of it
is one 0x1412200-byte XMemAllocDefault block that only FSR4's passes
write (fsr4_model_v07_fp8_no_scale_*, 20 pipelines), whole, every frame:
its scratch tensors, which the title's CPU never reads. (Also refreshed
whole once a frame: the landing's writes look like the title's to the
write watch, 1.3 ms.)

Change: VICTORY_LAND_NOT=<shader hashes>: a copy in the card's memory
that only those pipelines were ever declared to write, of 1 MiB or more,
whose memory is watched (by the kernel or the guards), is not fetched nor
landed: the card keeps its bytes, title memory keeps what it had. The
writes are still declared (the compares run, the flights' ranges wait
and are done with as before). A copy any other pipeline writes is landed
from then on. play.ps1 sets FSR4's 20 hashes. A/B-able with VICTORY_AB.

Paths that could send title bytes up over what the card holds there,
checked (none does unless the title writes the pages):
- whole-copy refreshes: only of memory that cannot be asked (not
  watched), which such a copy is not; pages never taken are taken once,
  at the copy's first refresh, before any shader write; the block is a
  reservation of its own (f5ef19e), never remapped;
- card-copy refreshes (take, take_landed, copy): pages written since they
  were taken, by the write watch or the guards; with VICTORY_SEND_CHANGED
  off a written page goes up whole, so a write of the title's anywhere in
  it would send the page: the probe below finds none;
- under-write compares and merges (merge_under_writes): the title's
  writes under flights' ranges only;
- rehash compares: hashes on the card, no title bytes;
- texture read-backs: into the title memory of the textures read back;
  FSR4's textures are their own resources, and the probe saw no access of
  ours either;
- landings of other copies over the same title memory: none (probe).

Diagnostics: VICTORY_LAND_NOT_PROBE=1 makes the title memory of each
piece left on the card no-access at each landing; the first access gives
the protection back and is logged with its address, read or write, the
instruction's module+offset and the thread.

Measured (Series S, prologue cell, i9-12900K + RTX 4090, play.ps1's
4090 settings with VICTORY_WINDOWS_BAR_MB=6144; in-run A/B card-ab-fsr-1,
VICTORY_AB=40,VICTORY_LAND_NOT: 7 phases off and 8 on, 47 and 52 frame
lines of the settled world; medians, ms a frame):

| | frame | card busy | submit thread | relay landing | its fetch waits | merging (wall) | title at presents | left on the card |
|---|---|---|---|---|---|---|---|---|
| off | 52.8 | 22.7 | 49.6 | 25.2 | 5.4 | 14.3 | 20.9 | - |
| on | 49.7 | 20.5 | 46.7 | 18.2 | 4.1 | 9.2 | 21.4 | 20.1 MB |

The A/B phase lines' own frame medians, phases in the world: off
50.7-55.6 ms (7), on 47.7-50.2 (7); every phase on is under the phases off
beside it. The submitting thread is 2.9 ms shorter too (not looked into:
likely the three landing threads taking fewer of its cores' time).

Access check (card-probe-fsr-1, a whole cell launch to frame 3400,
VICTORY_LAND_NOT_PROBE=1): 322 pieces of 64 KiB armed (the block), 20.1 MB
a frame left on the card, 0 accesses by anything.

Picture: the same (wall 24-45 colours/1000 px over frames 1600-6000 of
the A/B launch, 26-41 in the probe launch; head intact; no stepped
silhouette).

Checks: cargo clippy --workspace --all-targets (with and without
--all-features) -D warnings, cargo xtask policy, cargo test --workspace
(984 passed, among them land::tests::shaders_named_and_only_those_are_not_landed);
with diagnostics, land::probe::tests (an access to an armed piece is noted,
the protection given back, the access goes on).

(cherry picked from commit 26ed29c30abcda884739af0ab4f2534455c18af7)
Cause: the title's job threads spent 41 ms a frame in write faults on
guarded view memory, and the guards' lock was waited for 287 times a
frame, 47 ms of all threads' time (timeline split-tl-1, main 7cae3c5).
Who holds the lock, for how long, and why faulting stores that could go
in beside the guard (VICTORY_STORE_BESIDE) open their block instead,
was not told.

Change (diagnostics builds): the line of waits for the write trackers'
locks names the lines of watch.rs that held the guards' lock longest in
all, with how often and the longest hold. The line of the title's writes
beside the guards counts the stores that opened their block because
their place fills blocks, or because there was no other way to the page.

First findings (Series S cell, i9-12900K + RTX 4090, run guards-h1,
settled; per frame):

| place | holds | held | longest |
|---|---|---|---|
| a write fault (on_write) | 350 | 3.0 ms | 3.2-3.6 ms |
| a refresh guarding blocks again (guard) | 106 | 2.6 ms | 2.5-3.7 ms |
| the same, taken again between runs | 96 | 1.9 ms | 3.1-3.7 ms |

About 8 ms held against 48-60 ms waited: holds are short on average
(9-25 us) with tails of milliseconds, even a fault's one VirtualProtect.
With VICTORY_STORE_BESIDE=1, 235-270 stores a frame open their block at
places that fill blocks, 8-13 for want of another way to the page.

Checks: cargo clippy -p victory-gpu -p victory-hle --all-targets, with
and without --all-features, -D warnings; cargo test -p victory-gpu
watch:: titlewrite:: cores::.

(cherry picked from commit 634a93a99fc2e8f2be40b6ea12e3f02107118572)
Cause: the write-watch journal kept every page ever found written (64 KiB
pages, some 80,000-150,000 in the cell) in one B-tree, and every look at a
range walked it twice down to the range's ends: each refresh's look whether
anything is new (Shadow::nothing_new, some 10,000 a frame on the submitting
thread and the wide threads, under the journal's read lock), and each
asking's answer (writes, asked). In a sampled timeline of the submitting
thread (parts-prof2-tl) those looks were about a twentieth of its samples
(nothing_new 3.2 %, the tree's descent 1.1 %, collecting its answers
0.7 %). A test of the two structures alone, 80,000 pages: 111 ns a look at
a range of a few pages in the tree, 20 ns in pieces; 1.1 against 1.0 us
for a whole 174 MB heap.

Change: the journal's `written` is a table of pieces of 64 pages (4 MiB of
title memory) by number, each made when a page of it is first written; a
look at a range is a lookup for each piece it lies in. What it answers is
as before (pages in order, each with its last asking), a test compares it
with a tree over random notes and ranges.

Measured (Series S, prologue cell, i9-12900K + RTX 4090, play.ps1's 4090
settings; in-run A/B with the tree kept beside it, VICTORY_JOURNAL_PIECES
switched every 30 s, medians of the settled world's frame-line blocks, ms
a frame):

| launch (switches in A/B) | blocks off/on | submitting thread worked | its refreshes | its lists' steps | its write watch | frame |
|---|---|---|---|---|---|---|
| parts-g-ab1 (with VICTORY_ASK_OWN) | 28 / 30 | 54.3 -> 53.4 | 14.6 -> 14.0 | 21.9 -> 21.6 | 5.4 -> 5.2 | 56.0 -> 56.5 |

(The launch ran while the run queue's waiters took some three cores: its
absolute times are high, its phases alike. The A/B build noted every page
in both structures; this one keeps only the pieces, so its notes cost less
than either phase's.)

The gate (this commit on 74d2497, the 4090 settings with
VICTORY_WINDOWS_BAR_MB=6144 and VICTORY_LAND_NOT as vt-go.ps1 now sets
them; a cold launch on a fresh shader cache, three warm ones, a 17-minute
session): 22.3 fps median (p10 20.7, 44.9 ms) over the four launches, the
session 22.2 (45.0 ms), 43-46 ms a minute throughout it and the process's
private memory flat at 24.0-25.0 GB; no device loss, the head and the
glass as the reference, wall colours 25-47 per 1000 px, no stepped
silhouette in any of the five. A launch with VICTORY_REFRESH_CHECK=1 found
no copy stale after its refresh.

Checks: a test (the pieces against a tree, random notes and ranges); cargo
clippy --workspace --all-targets (with and without --all-features), cargo
test --workspace, cargo xtask policy.

(cherry picked from commit 27b7a9002dc55e760b73b56db5f44ae25a928526)
Cause: every write fault of the title's on guarded view memory took the
guards' lock to open its block, behind refreshes that hold it to make
blocks read-only again. The holds are short on average and milliseconds
long at their tails, even a fault's one VirtualProtect (the kernel's
address-space lock): with STORE_BESIDE and COPY_BESIDE on, 167-174
waits a frame, 28-40 ms of all threads' time, most of them the title's
job threads (fault books of guards-h1: wait median 0.1 us, p99 2.3-3.9
ms, max 15 ms; five job threads 3.5-4.8 ms a frame each).

Change: a write fault on a guarded block whose page is shown at no other
address opens it without the guards' lock (VICTORY_FAULT_FAST=0: with
it, as before; VICTORY_AB can name it). A gate per block, a bit, is
held by whoever changes the block's protection: the fault, or the
holder of the guards' lock around guarding, opening, covering other
views and publishing. The fault clears the block's published bit, opens
it, and notes it opened in a short list that the next holder of the
lock takes into the guards before it looks at any block (and that a
holder takes again after each gate). Pages shown at several addresses
(their blocks are mirrored in a bit set) keep the way with the lock,
which opens or taints every view.

Measured (Series S cell, i9-12900K + RTX 4090; in-run A/B of 20 s
phases, STORE_BESIDE and COPY_BESIDE on; medians a frame, 9-13 blocks
per arm; the machine was contended in guards-x1, so frame times are
compared within a launch only):

| launch | arm | frame ms | title@present | submit thread ms | faults opening a block (without the lock) | guard-lock waits |
|---|---|---|---|---|---|---|
| guards-x1 | with the lock | 56.5 | 24.0 | 55.4 | 198 | 174, 39.9 ms |
| guards-x1 | without | 57.8 | 24.9 | 54.7 | 196 (142) | 107, 17.8 ms |
| guards-x2 | with the lock | 48.5 | 19.4 | 47.0 | 188 | 168, 27.8 ms |
| guards-x2 | without | 49.0 | 20.7 | 47.8 | 187 (136) | 110, 12.2 ms |

The lock's waits fall by 55 %; the title waits 0.9-1.3 ms more at its
presents (it is quicker while the submitting thread sets the frame);
the frame and the submitting thread are as they were within noise.

Picture and checks: VICTORY_REFRESH_CHECK=1 with it on (guards-rcf, to
frame 3400): no host copy stale after its refresh, 147 faults a frame
opened without the lock; banding 25-55 colours per 1000 px. The test of
writes and askers on eight threads runs with it on too (one view, one
view resting, three views), and a test of its own; cargo clippy
-p victory-gpu --all-targets, with and without --all-features.

(cherry picked from commit d4e8d3a45b8305ddc7dbda0c7491f667517076bb)
d4e8d3a4 opened write-faulted blocks without the guards' lock by
default. Agent guards found a likely lost-write race in it on pages
shown at several addresses: open() clears an aliased block's mark
before it marks the page's other views unclean, without holding that
block's gate, so a fault on the same block can open it alone and an
asker at another view can still answer "nothing new". The stress test
watch::many_askers_tests::no_write_is_lost_between_askers_when_faults_open_alone
failed once ("is not after") after the rebase; the gates and
VICTORY_REFRESH_CHECK=1 launches saw nothing.

The fast path gave no frame gain yet (the submitting thread is the
wall), so it is now off unless VICTORY_FAULT_FAST=1, until the fix is
measured. Doc comment and README say so.

Checks: clippy (workspace, all targets, with and without all
features), victory-gpu watch tests (42 passed).

(cherry picked from commit 7dfa5eb9f813ed841bd58140870c86c2faccc3d5)
From Vice-Tay fa11650 ("copies: a guard page fails the copy and stays
a guard page") and c277533 ("copies: count a guard page that cannot be
re-armed; destination guard tests"), both by zocram4cc.

Cause: title memory has guard pages (stack guards, and guards the title
sets itself). A copy of ours over title memory (safecopy's copy, put and
merge, under the write handler in watch.rs) that touches one raises
STATUS_GUARD_PAGE_VIOLATION, and Windows clears the page's guard flag as
it raises it. The handler sent every fault inside a copy to the copy's
failing exit, whatever its code, and nothing set the flag again: the
page stayed an ordinary page, and the title's next touch of it did not
raise the guard fault it was set up for (its stack cannot grow there).
Upstream traced silent exits 1-3 minutes into the world to this (two
0x80000001 among three million access violations, under Proton).

Change: a guard fault inside a copy sets the guard flag again on its
page, with the protection the page has, if the page is still committed,
and fails the copy as before. One that cannot be re-armed, or a fault
that gave no address, is counted, and the first is said ("guard not
re-armed"). A guard fault outside a copy goes on to the next handler as
before. The same as upstream; the handler's other paths (the faults
that open blocks) are untouched.

Tests (upstream's): a guard page in a copy's source, and in the
destination of a copy, a put and a merge, fails it and stays a guard
page; a page that cannot be guarded again is counted.

Checks: cargo clippy -p victory-gpu -p victory-loader --all-targets,
with and without --all-features; cargo test -p victory-gpu safecopy::
watch::.

(cherry picked from commit 69e724ee6a3bdc4bd95733e2adfbe87b86908477)
Cause: the test of writes and askers on eight threads with faults
opening blocks alone (no_write_is_lost_between_askers_when_faults_open_alone)
failed 1 of 30 runs on 4dca7bf9, in its one-view part: "1 views, page
3 ... 3230 is not after 3248", a write missing at the writer's next
asking. Two races, both of d4e8d3a4:

- Any page: fast_open made the block writable, then noted it opened
  (OPENED). In between, another thread's store lands in it with no
  fault, and that thread's asking drains nothing and finds the block
  clean: "nothing written". This is the failure seen.
- A page shown at several addresses: open() took an aliased block out
  of the aliased before the page's other views were told (their
  PUBLISHED bits cleared, or the views opened), without the block's
  gate. A fault on it could open it alone meanwhile, and an asking at
  another view be answered "nothing new" by its bit.

Change: fast_open sets the block's BESIDE bit before it makes it
writable; an asking already tells a block with that bit as written
though the guards hold it clean, and takes the bit. open() holds the
gates of the blocks it takes out of the aliased (with all views opened,
those of the other views too) until they are open; a fault on one waits
and then finds it open. VICTORY_FAULT_FAST is on by default again
(7dfa5eb9 undone, doc comment and README with it).

Tests: one for each race, deterministic: a test-only wait of the
opening thread (WAIT_IN_TEST, beside FAST_IN_TEST and REST_IN_TEST)
holds it at the point where the other thread comes between.

| test | without the fixes | with |
|---|---|---|
| a_write_while_a_fault_opens_its_block_alone_is_told | 20 of 20 fail | 0 of 20 |
| a_fault_on_a_block_leaving_the_aliased_waits_for_the_other_views | 20 of 20 fail | 0 of 20 |
| no_write_is_lost_between_askers_when_faults_open_alone | 1 of 30 fail (4dca7bf9) | 0 of 30 |

("Without the fixes": these tests and the wait, the BESIDE bit and the
gates in open() left out.)

Checks: cargo clippy -p victory-gpu --all-targets, with and without
--all-features; cargo test -p victory-gpu watch:: safecopy:: (56
passed).

(cherry picked from commit 46902d225ff03e9e1277edfcad890416edd001d9)
Cause: Shadow::differing cuts a range of 32 MiB or more into pieces for up
to eight threads at 64 KiB lines of title memory. The first thread's cut,
`at - (start + at) % PIECE` with `at` the range's start, goes below zero
when the copy does not begin on a 64 KiB line: in release builds it wraps,
`.max(from)` keeps the huge value, and the first thread compares nothing.
About a threads-th of such a range was never compared, so what shaders
wrote there never went back into title memory.

Change: Vice-Tay 21ec811 (after fxceless/victory-fork#1407, finding by
stellarr-studio/kelvaroq): a saturating subtraction, and its test
(parallel_compare_includes_the_first_partial_piece, a 48 MiB copy at an
address 32 KiB into a piece).

Reach here: differing is the compare of copies in the PC's memory when
VICTORY_WIDE_BACK=0. With play.ps1's settings (VICTORY_WIDE_BACK=1, the
relay) copy-backs go through find_all/find_pieces, which cut on piece ends
without the subtraction, and title buffers from 64 KiB up are compared on
the card; so no copy of the Series S cell took this path.

Checks: cargo test -p victory-gpu --lib parallel_compare passes; clippy
--workspace --all-targets, with and without --all-features, -D warnings:
clean. Gate: card-gateA (items 1, 2 and 4 on 7dfa5eb9, card-gateA.exe):
cold and three warm launches of the Series S cell at 42.5-44.4 ms a
frame, the card busy 19.7-25.6 ms; a 17-minute session flat at 40.6-42.2
ms a minute, 23.6 GB private; no device lost, no draw dropped but the
ray-tracing builder's; one warm launch had the left wall's intermittent
silhouette, as split-gate-warm1 has on the base without this batch.

(cherry picked from commit 3b8238162c9e8e56d5c5daa6889d05c0ab0f28fd)
Vice-Tay d60fc84 (readmet3xt-lab), with a switch added.

Cause: wide() woke every kept thread (notify_all) for any batch, however
few jobs it had. The calling thread drains the queue too, so a batch of n
jobs has work for n - 1 helpers at most, and the rest woke to find nothing.

Change: one notify_one for each job the caller can share. When there are
at least as many jobs as kept threads, it still wakes all of them, as
before. That is the common case: wide_each makes 7 jobs for 6 threads. So
this changes only small batches. VICTORY_WIDE_WAKE=0 restores the old
behaviour; VICTORY_AB can also switch it while the title runs.

Measured (Series S, prologue cell, i9-12900K + RTX 4090; in-run 2x2 A/B
with VICTORY_METER_THREAD, VICTORY_AB=12, launch split-now-hv-1; settled
phases' median frame time, ms):

| arm | frame |
|---|---|
| neither | 42.1 (42.0, 42.2) |
| this | 42.2 (41.7, 42.7) |
| the meter's thread | 41.6 (1 phase) |
| both | 41.4 (1 phase) |

Within noise: identical in-run arms differ by ~1 ms. It goes in as no
regression.

Checks (on 43744777): clippy --workspace --all-targets --locked, with and
without --all-features, -D warnings: clean; cargo test --workspace --locked:
all pass; cargo xtask policy: ok.

Gate: split-gate2, with the three levers together (split-g3.exe, built on
7dfa5eb9 before the rebase onto 43744777): cold and three warm launches of
the Series S cell at 39.6, 41.2, 43.8 and 39.7 ms a frame (windows' ranges
38.5-71.6); an 11-minute session at 38.3-41.9 ms a minute, 24.5-25.7 GB
private, flat; no device lost, no panic, 264-272 draws dropped a frame as on
the base (the ray-tracing builder's). Silhouettes: warm2 at frames
1500-1800 (the left wall's intermittent one, as card-gateB-warm1 has), and
warm3 at frame 1500 only (as split-gate-warm3 and card-gateA-warm2 have);
none in the cold, warm1 and long launches.

(cherry picked from commit 4d7ac9d12e0c8f2c9954dbb930db8e0c4635d967)
Cause: the title pins its own threads as on the console, through
SetThreadGroupAffinity. On an i9-12900K its masks are:
- 0xff for its eight busy job workers: logical processors 0-7, i.e. four
  fast cores with both their threads;
- 0x1f00 for its main thread and ten others: LPs 8-12;
- 0x2000 and 0x3f00, plus 0x3fff overall;
- 0xffffff and 0x0, which pin nothing.
Our threads were kept on all sixteen fast LPs (VICTORY_FAST_CORES=2),
beside the title's. The eight E-cores (16-23) and the fast pair 14-15 ran
nothing of the title's.

Change: the title's masks are learned from an HLE SetThreadGroupAffinity,
from agent guards' patch. The api-ms-win-core-processtopology set is now
bound to the kernel module, and VICTORY_TITLE_AFFINITY=0 leaves the
title's threads unpinned. A mask of every processor counts as no pin.
Every thread of ours that asks for cores is registered, and is placed
again whenever the title's masks grow or a switch changes while the title
runs (VICTORY_AB).
- VICTORY_PLACE_APART (on; =0: as before): the eight threads that
  translate lists (THIN) run on the slow cores the title leaves.
- VICTORY_PLACE_LANE (on; =0: as before): the line's thread, the wall,
  runs on the fast cores the title leaves.
- Every other thread of ours is placed as before.
- Until the title has asked for processors, nothing changes. Where its
  masks leave no slow cores (or no fast ones), the thread stays where it
  would have been, and that is logged once per kind ("the title leaves no
  slow cores: the thread stays where it was").
- Diagnostics: at each change of these switches, each kind of ours logs
  its CPU time since the last change.

Rejected first: keeping all of ours off the title's LPs made frames ~5 ms
longer. That put the lane on 14-15, the relay and the sender on 14-23, and
every helper and pool on the E-cores. In split-pl3-apart, 3+3 phases:
- frame 52.2 vs 47.2;
- the heaps' records wait 10.2 vs 3.2;
- the sender worked 16.0 vs 8.8.
The helpers that the lane and the sender wait on (heap-sync, the wide
refresh helpers) are slower on E-cores.

Measured (Series S, prologue cell, i9-12900K + RTX 4090; exe split-a4,
whose two switches were off by default; in-run 2x2 A/B, VICTORY_AB=12 with
both switches, three launches split-now-pl4-1..3). Settled phases only:
over 150 frames, more than 3,000 draws, p90 under 1.25x the median. The
frame is the median of the phases' median frame times; the other columns
are the frame lines' medians per arm (all three launches). Identical
in-run arms differ by ~1 ms.

| arm | phases | frame | the lane worked | title waited at presents | card idle | sender worked |
|---|---|---|---|---|---|---|
| neither | 5 | 42.3 (41.1-43.1) | 39.9 | 14.5 | 20.9 | 7.5 |
| lists apart | 4 | 40.8 (39.4-41.7) | 38.9 | 15.3 | 20.3 | 8.0 |
| lane apart | 4 | 40.9 (40.5-41.9) | 39.2 | 13.8 | 20.8 | 10.0 |
| both | 6 | 40.0 (39.3-41.6) | 38.3 | 14.8 | 18.6 | 9.8 |

Both together beat neither in every launch (40.7, 39.4 vs 41.8, 42.3;
39.3, 40.4 vs 41.1; 41.6, 39.6 vs 43.1, 42.3).

Our threads' CPU, ms a second (GetThreadTimes, pools summed; medians of
the same phases):

| arm | lane | list x8 | wide x6 | land x2 | under x5 | records x5 | views x3 | relay | send | heap-sync |
|---|---|---|---|---|---|---|---|---|---|---|
| neither | 779 | 3538 | 637 | 330 | 243 | 357 | 290 | 302 | 120 | 141 |
| lists apart | 774 | 4097 | 739 | 356 | 236 | 362 | 270 | 306 | 112 | 130 |
| lane apart | 836 | 3570 | 656 | 372 | 278 | 407 | 300 | 332 | 124 | 129 |
| both | 821 | 4210 | 660 | 368 | 268 | 404 | 298 | 315 | 121 | 145 |

The list threads take ~17% more CPU time on the E-cores for the same work,
and nothing waits for them there. The fast cores are left to the title's
workers and to the threads the frame waits for.

Checks (on 43744777): clippy --workspace --all-targets --locked, with and
without --all-features, -D warnings: clean; cargo test --workspace --locked:
all pass; cargo xtask policy: ok.
Tests: cores.rs, what the title leaves is found by kind (fast, slow, all;
none before it asks or where it leaves none).

Gate: split-gate2, with the three levers together (split-g3.exe, built on
7dfa5eb9 before the rebase onto 43744777): cold and three warm launches of
the Series S cell at 39.6, 41.2, 43.8 and 39.7 ms a frame (windows' ranges
38.5-71.6); an 11-minute session at 38.3-41.9 ms a minute, 24.5-25.7 GB
private, flat; no device lost, no panic, 264-272 draws dropped a frame as on
the base (the ray-tracing builder's). Silhouettes: warm2 at frames
1500-1800 (the left wall's intermittent one, as card-gateB-warm1 has), and
warm3 at frame 1500 only (as split-gate-warm3 and card-gateA-warm2 have);
none in the cold, warm1 and long launches.

(cherry picked from commit d92322077d946ccd7cb9a8a8dba7457138b90632)
After Vice-Tay 755dc92 (and the index it refines).

Cause: whether the submission's one asking holds a range was a look
through every range it asked (Journal::ahead, a Vec, `iter().any`), at
every refresh's look (nothing_new), every asking's answer (writes, asked)
and in ask_rest for each range asked alone: some ten thousand looks a
frame on the submitting thread and the wide threads, under the journal's
read lock, through tens of ranges each. And ask_ahead, called at every
submission's refreshes in front, made and sorted its pieces before it
found the submission's asking standing and threw them away.

Change: the ranges are kept sorted by their first page, those another one
holds dropped, so their ends rise too and one binary search says whether
one holds a range (Ahead, as Vice-Tay's); ask_rest adds what it asks to
it. ask_ahead looks at the standing asking first.

Not taken: Vice-Tay e11801e (a raw title copy keeps the submission's
asking standing): in the cell the asking is almost never ended inside a
submission (two sampled timelines of the submitting thread: about one
GetWriteWatch call a frame outside the submission's asking, 82 inside it),
so it would buy nothing measurable here.

VICTORY_AHEAD_INDEX=0 looks through all the ranges, as before (switched by
VICTORY_AB for in-run comparisons).

Measured (Series S, prologue cell, i9-12900K + RTX 4090, the 4090
settings, this branch on 7dfa5eb9; one launch, in-run A/B of this switch
and VICTORY_ASK_OWN, each flipped every 30 s, so each is on in half the
other's phases; medians of the settled world's frame-line blocks, ms a
frame):

| launch | blocks off/on | its refreshes | its lists' steps | its write watch | submitting thread worked | frame |
|---|---|---|---|---|---|---|
| parts-now-fi-ab1 | 26 / 25 | 8.2 -> 7.9 | 14.9 -> 14.7 | 4.2 -> 4.1 | 39.8 -> 39.9 | 42.1 -> 42.0 |

A few tenths of a millisecond in the parts that look; nothing in the whole
thread's time that the launch can tell apart.

Checks: a test (the index against a look through all the ranges, built at
once and a range at a time); cargo clippy --workspace --all-targets (with
and without --all-features), cargo test --workspace, cargo xtask policy.

(cherry picked from commit c70e83ded4db9cc0b0d86d430c59be72069d9aae)
Cause: the submission's one write-watch asking (ask_once: ask_ahead, then
ask_rest) held every page of the address space in ASKING while it asked,
so it waited for whatever other thread was asking about anything: a
texture's refresh, the heap pass beside the recording, the guarded view
memory's askings, which themselves wait for the guards' lock. In a sampled
timeline of the submitting thread (parts-prof2-tl) that was 1.5 ms a
frame in Asking::hold, about one wait a frame of 1.4 ms. The submission
never asks about view memory.

Change: the two parts hold the page runs they ask about (AskingRuns),
taken all at once, so they wait only for another asking of the same pages,
as every other asking does. What ASKING guards is per page (no two askings
of a page interleave, so no answer is lost) and holds as before.
VICTORY_ASK_OWN=0 holds everything, as before.

Measured (Series S, prologue cell, i9-12900K + RTX 4090, play.ps1's 4090
settings; in-run A/B, the switch flipped every 30 s, medians of the
settled world's frame-line blocks, ms a frame):

| launch (switches in A/B) | blocks off/on | its write watch | submitting thread worked | its refreshes | frame |
|---|---|---|---|---|---|
| parts-f-ab1 | 22 / 20 | 5.4 -> 4.8 | 53.0 -> 53.4 | 12.9 -> 13.6 | 53.2 -> 53.7 |
| parts-g-ab1 (with VICTORY_JOURNAL_PIECES) | 28 / 30 | 5.7 -> 5.0 | 54.3 -> 53.2 | 14.2 -> 14.5 | 56.9 -> 55.5 |
| parts-now-fi-ab1 (with VICTORY_AHEAD_INDEX, on 7dfa5eb9) | 26 / 25 | 4.4 -> 3.9 | 40.4 -> 39.4 | 8.2 -> 7.9 | 42.0 -> 42.2 |

The asking itself is 0.5-0.7 ms shorter in all three; what that does to
the whole thread differs (+0.4, -1.1, -1.0 ms): part of the wait can move
on to the refreshes, which meet the same other askings and the guards'
lock later. (The first two launches ran while the run queue's waiters took
some three cores.)

Checks: a test (an asking of other pages does not wait, one of the same
pages does); cargo clippy --workspace --all-targets (with and without
--all-features), cargo test --workspace, cargo xtask policy.

(cherry picked from commit a1df9bd6cdb6adeac72b36da9d39f586ff245d33)
Cause: the title's command lists call ClearUnorderedAccessViewUint (the
list's slot 0x1a8, after ClearDepthStencilView 0x198 and
ClearRenderTargetView 0x1a0). The list had no method there: the call went
to the table's stand-in, which logs "method not implemented" once and does
nothing. Every launch on disk logs it at the world's first frames (76
runs); Vice-Tay's main has no such method either.

A diagnostics build that logged each call (run sil-asap-c2) found two in a
launch, once each when the world begins, both to zero: a raw view of a
whole 21 MB buffer (0x1412200 bytes: FSR4's scratch block) and an 80x45
R32_FLOAT texture with render target and unordered access, a value per
16x16 tile of the 1280x720 picture. Neither was cleared: the buffer kept
what title memory held there, the texture what the host's new render
target held. What the title clears is read: with this change and the
clears' bytes replaced by 0x3f (VICTORY_CLEAR_UAV=poison) the picture is
as without it, with 0xff every frame from the world on is white
(sil-asap-poison-1, -ff). With 0xff in the texture alone the picture is
black up to frame 2000 and white from 2048 on (sil-poison-tex): what it
held when the world began is read at least once (the pass that writes
it whole every frame does not read it, and no pass before it in a frame
binds it), and what that read gives lasts.

Not shown: that this is what gives the dark stepped shape some launches
show on the Series S cell's left wall, or the dark interior. The other
per-tile textures of the cell's lighting (an 80x45 value and class mask,
a 40x23 mask) are written whole, or zeroed by a shader, every frame.
Today's launches, counted on the cell's frames: without this change 8 of
123 had the shape and none the dark interior; with it 0 of 11 had the
shape and 1 the dark interior (wall 19 against 45, sil-gate-warm2).
Neither count decides it: the per-launch state is still open.

Change: ClearUnorderedAccessViewUint and ...Float (0x1b0) are list
methods, written down with VICTORY_THIN like the other calls (the view's
record, the values and the rectangles copied at the call). A clear is a
copy from zeros kept on the card, or from upload memory holding the
clear's texels (the values' low bits per channel for the Uint form, as
D3D12 puts them; zeros only for the Float form): into the view's texture
(its level and layers or slices, or its rectangles), or into the buffer's
host copy at the clear's place in the list, as a shader's write
(`HostList::place_fill`). That write lands like any other but adds no
writer of its own (`Shadow::cleared`): FSR4's block, which only shaders
VICTORY_LAND_NOT names write, stays on the card after it (20.1 MB a frame
left there after the clear, as before). VICTORY_CLEAR_UAV=0 leaves clears
out as before; =poison[:<byte>[:buffer|:texture]] fills what they name
with that byte instead (diagnostics). Not handled, and logged once if a
title does it: depth textures' colour twins, non-zero float values.

Not this: the purple stepped blocks on the cell's papers with the ambient
stand-in off are there with the clears too (VICTORY_AMBIENT unset: share
of purple pixels 0.47 and 0.50 without, 0.47 with); the stand-in stays.

Measured (Series S, prologue cell, i9-12900K + RTX 4090, play.ps1's 4090
settings): ssfps-gate on 7dfa5eb9: cold, warm1, warm3 and the 12-minute
run as before (wall 45-46, banding 29-47 colours a 1000 pixels), warm2
the dark interior above (banding 7); frame 41.8-43.4 ms against
43.3-44.7 in the day's other gates; no device loss.

Checks, rebased on 4dd0614b: cargo clippy (default and all features) and
cargo xtask policy clean; cargo test --workspace passes, with a test of
the texel packing.

(cherry picked from commit 8e9a8c28bb5fb63bb3b60edbd1a2cf62f0ff59a6)
From Vice-Tay 7993c1b ("Copy GPU-written texture views after a CPU
upload", by fxceless; adapted there from edsuuu/VI-BR-PORT 5c17c8c8,
after kesku in fxceless/victory-fork #1241).

Cause: a placed texture shown at the address of another that the card
writes (a probe atlas, say) is brought up to date by an alias copy from
that one (texture::alias). The copy was left out when the list had
already asked about the texture (first_use) and the source's state had
not changed since. A CPU upload of the same texture from title memory
in the list asks first_use too, so the alias copy after it was left
out, and the texture kept the CPU's bytes instead of the card's newer
ones.

Change: the list keeps, for each texture it copies into by alias, the
source of its last copy (HostList::alias_source_changed); a copy is left
out only when that is the same source and its state did not change. The
texture is still marked used for the list, as before.

Port: the same as upstream; in host.rs the new method goes beside ours
(the conflict was upstream's defer_raw_copy next to it, which we do not
have).

Test (upstream's): alias_after_title_upload_copies_the_gpu_atlas (an
upload, then an alias copy from a card-written texture: the sampled
texel is the card's). On WARP with diagnostics: passes with the change;
fails without it ("kept the CPU upload instead of the GPU atlas", left
0, right 0x8c020100).

Checks: cargo clippy -p victory-gpu --all-targets, with and without
--all-features; cargo test -p victory-gpu --features diagnostics --lib
resource::tests:: texture:: on WARP (22 passed).

(cherry picked from commit d59b637cbbeebc0b90f645d0b5125931b7d48347)
From Vice-Tay 7eef143 ("Track decoration bake coverage per descriptor
heap", by Taynan Piza; its body is empty, the cause below is ours).

Cause: before a draw of the title's decoration bake, the textures picked
by index are brought up to date by a pass over the heap's due slots; a
later bake of the frame skips that pass while nothing is new. "Nothing
new" was one static for all heaps, BAKE_SERVED: the write count of the
heap whose pass last served everything, plus one. A bake on another
heap compared its own count with it, and an equal count by chance made
it skip a pass it needed: the bake drew with textures not brought up to
date. And a pass that ran while another was at work could mark all
served though the other had left due slots for later.

Change: each heap's texture queue keeps a revision, raised by every slot
write, every slot made due anew and every pass that begins; a pass that
ran alone (no other pass of the heap meanwhile) and served all due slots
of a bake marks that revision covered. A bake skips its pass only while
its own heap's revision is the covered one and no memory notes wait, as
before. Ordinary passes still make the next bake look again.

Port: upstream's queue has more than ours (a bitset of queued slots,
waits kept per slot); only the revision, the pass guard and the three
methods are taken, and our two places that numbered writes number them
by the revision. draw.rs is upstream's.

Tests (upstream's): bake_coverage_is_local_to_the_heap_and_the_pass_revision,
overlapping_texture_passes_cannot_certify_a_bake.

Checks: cargo clippy -p victory-gpu --all-targets, with and without
--all-features; cargo test -p victory-gpu --lib descriptor::host::.
Silhouette looked at it first: a bug of global state, not the cause of
the wall's strip, no file shared with its clears.

(cherry picked from commit 0d7de37f0ffe08fa382f8248ef50f56af9ea3a4e)
From Vice-Tay fa8fc1d ("Correct Direct3D 12 bindings and NVIDIA pipeline
reuse", by Taynan Piza with Jeremy Goldberg, readmet3xt-lab and Indy2l),
its ambient part only: the comparison list's own queue call, the read-back
timings and the NVIDIA static samplers are other parts, not taken here.

Cause: the stand-in for the indirect light (ambient.rs) ran all its
passes under one root signature with a descriptor table of an SRV (t0,
the depth) before the image's UAV table. Only the resolve's passes
(place, gather, raise) read the depth; for the radiance and the air
passes draw.rs put the image's own UAV handle in that SRV table. A UAV
descriptor where the root signature says SRV is not valid in D3D12,
read or not (a driver may look at a table's descriptors when it is set).
And the depth of the resolve was taken from whatever view sat at its
place in the table, a shader or an unordered one, of any dimension or
plane.

Change: the resolve's passes have a root signature of their own, the
depth table last; the others have none for it, and nothing is bound
there. The depth is a 2D shader view of the first plane, not the
stencil, of one sample and the image's size; else the resolve has no
stand-in (said once). The image is an unordered view.

Port: upstream's ambient.rs has more (an indirect hold, a fourth UAV of
counts, 16 constants); here the same split on ours: two root signatures
chosen by the part, parameters 0 constants, 1 image, 2 cells, 3 points,
4 depth (resolve only). draw.rs's checks and is_depth_srv are upstream's.

Tests: depth_srv_checks_the_plane_not_the_number_of_levels (upstream's);
the_passes_build makes every pass, so both root signatures.

Checks: cargo clippy -p victory-gpu --all-targets, with and without
--all-features; cargo test -p victory-gpu --features diagnostics --lib
ambient:: draw::tests:: on WARP.

(cherry picked from commit faa66d7b6110125cf65793f7ce8f91276f380561)
Cause: the stand-in for the indirect light (ambient.rs) looked for the
scene's depth of the resolve (CS_ScreenProbes_TemporalResolve) at
DEPTH = (0, 464), table 0, 464 dwords in, the program's register 213.
What the title has there is the stencil plane of its D32S8 depth: a
Texture2D view in X32_TYPELESS_G8X24_UINT, plane 1. The place, gather and
raise passes read stencil bits as a float depth (Texture2D<float> on a
UINT view): their creases and their depth-weighted interpolation worked
from that, though raise still did its other work (it takes the magenta of
the probes' memory out of the title's light, then raises it).

Since the previous commit (fa8fc1d's check, is_depth_srv) that view is
refused as depth, rightly, and the resolve had no stand-in at all: the
magenta blocks of the probes' memory showed (on the papers at the cell's
right, guards_purple.py's share 0.54-0.56 from the first cell frame on,
guards-gatec-cold and guards-now-bis2; 0 in every other launch of the
day) and the frame was darker (54.3 against 59.7, from the missing
light, not from anything closer to the reference).

The depth is in the program's tables: (0, 688), register 59, a Texture2D
view in R32_FLOAT_X8X24_TYPELESS, plane 0, of the same 1280x720
R32G8X24_TYPELESS texture (all the table views it reads listed in run
guards-now-bis4). Upstream Vice-Tay has DEPTH at (0, 464) too.

Change: DEPTH is (0, 688); the old place is STENCIL. The resolve takes the
depth plane of a depth texture (two-dimensional, one sample, the light's
size, ALLOW_DEPTH_STENCIL, is_depth_srv) at DEPTH, or else wherever the
program reads one through its tables (a variant laid out otherwise). With
none found it reads the view at STENCIL as before, said once: the light
is raised and the magenta taken out all the same. VICTORY_AMBIENT_DEPTH=0
reads the view at STENCIL, as before (VICTORY_AB can name it).

Measured: in-run A/B, guards-now-depthab (VICTORY_AB=20,VICTORY_AMBIENT_DEPTH,
frames 1500-6400 every 100, each put in its phase by the time it was
written: guards_cellab.py), against reference-cell.png:

| depth the resolve reads | frames | wall | frame | purple box RGB (B-G) | ms |
|---|---|---|---|---|---|
| stencil plane, as before | 27 | 45.5 | 60.5 | 27.2 18.3 18.1 (-0.2) | 42.4 |
| depth plane | 26 | 43.9 | 59.2 | 24.5 14.9 14.0 (-0.9) | 42.6 |
| reference | 1 | 20.9 | 53.8 | 20.1 8.9 5.3 (-3.6) | |

Every measure moves toward the reference, a little; the frame is the
same. No purple block in either phase (share worst 0.044), no silhouette;
"found no depth plane" never said.

Test: the_resolves_stencil_view_is_not_its_depth (the two descriptions
seen in the runs: the stencil plane is refused, the depth plane taken).

Checks: cargo clippy -p victory-gpu --all-targets, with and without
--all-features; cargo test -p victory-gpu --features diagnostics --lib
ambient:: draw::tests:: on WARP.

(cherry picked from commit 6042361e92ec8cae03d3f7b7e23e6a922ca564d9)
Cause: with title buffers from 64 KiB up in the card's memory
(VICTORY_CARD_BUFFERS_MIN_KB=64) there are some 3,700 such copies in the
Series S cell (the frame line's "host copies in the card's memory"), and
two things looked at every one of them, under the lock of all:

- each submission's card_dirty, which takes what changed on their CPU
  sides: a Weak upgrade, an atomic swap and a drop for each copy, 16 times
  a frame, for the few dozen that had changed. In a timeline of main
  (parts-prof-tl, the submitting thread sampled) "copies in the card's
  memory: what changed" was 1.96 of the part's 6.58 ms a frame, and the
  walk itself the hottest function of the thread (4.6 % of its samples);
  split's timeline of the same tree found 3.0 ms;
- each title buffer copy done at submission (send_copied), which made a
  Vec of every copy (an upgrade each) to find the few its bytes land in:
  0.55 ms a frame of the lists' steps.

Change: a copy whose CPU side changes (its `touched` going from false to
true, under its dirty lock) puts itself in TOUCHED, and card_dirty takes
those alone; CARDED keeps each copy's title range, and send_copied upgrades
only the copies that hold some of the bytes. Copies that went are let go
from CARDED every 64th card_dirty. What is taken, and when, is as before: a
change made before card_dirty took the list is in it, one made after goes
to the next. VICTORY_CARD_NEAR=0 walks every copy, as before (and is
switched by VICTORY_AB for in-run comparisons).

Measured (Series S, prologue cell, i9-12900K + RTX 4090, play.ps1's 4090
settings; in-run A/B, VICTORY_AB=30,VICTORY_CARD_NEAR: the switch flips
every 30 s, the frame lines' blocks of the settled world split by phase;
medians, ms a frame):

| launch | blocks off/on | frame | submitting thread worked | its copies in the card's memory | its CPU (user) |
|---|---|---|---|---|---|
| parts-a-ab1 | 24 / 24 | 51.8 -> 49.9 | 49.5 -> 48.2 | 8.9 -> 6.7 | 24.2 -> 22.3 |
| parts-a-ab2 | 24 / 20 | 53.9 -> 51.6 | 51.6 -> 49.9 | 9.8 -> 7.4 | 26.0 -> 23.8 |

The A/B phase lines' own frame medians: 50.6 -> 49.1 and 53.5 -> 50.8 ms.
The baseline, main 7cae3c5 in the same session: 51.8 and 50.1 ms
(parts-main-warm, parts-main-1).

Again on 73ec8de5 (the lane split off, the clear fix in), one launch with
two other switches flipping as well (VICTORY_AB=30,VICTORY_CARD_NEAR,
VICTORY_NOOP_PIECES,VICTORY_FRONT_KEEP), each switch's blocks off and on:

| launch | blocks off/on | frame | the lane worked | its copies in the card's memory | its CPU (user) |
|---|---|---|---|---|---|
| parts-now-nra-ab1 | 33 / 30 | 39.5 -> 38.5 | 37.2 -> 36.2 | 10.4 -> 8.8 | 23.5 -> 23.2 |
| parts-now-a-ab3 (this switch alone) | 25 / 30 | 41.0 -> 40.3 | 38.4 -> 38.1 | 10.5 -> 8.8 | 24.9 -> 24.3 |

The part is 1.6-1.7 ms shorter in both; in the second some of it went to
waiting under the flights' writes (7.2 -> 8.2 ms). Phase lines' frame
medians 40.5 -> 39.9 ms.

Checks: a test (only the copies that changed are taken, once each).
(cherry picked from commit 18d69b1d59bf423a26a049e94c95de5623a6bc5e)
Diagnostics (VICTORY_UNDER_WHO=1, diagnostics builds): per 64 KiB block
of title memory, since the start, the pages merge_under_writes put the
title's bytes into and their changed runs; how often a landing's plan
declared the block's pieces written and how often the card's compare
found them changed; and the declarations of a megabyte or more
(wide_write) over those blocks, by what declares them. Every tenth
counters' line logs the busiest spans, and the busiest one block by
block.

What it found (run land-who-1, main c214714b's settings, Series S cell;
averages since the start; 324 pages and 96k runs a frame at the end):
- the title's 174 MB heap (0x62f0000+0xae00000) holds ~110 of the pages
  and ~61k of the runs a frame (63%): 0x62f0000+0x1b20000 89.5 pages and
  51.4k runs, 0xbe20000+0x170000 10.2 and 4.6k, 0xd010000+0x1b0000 10.2
  and 5.0k;
- the one declaration over it is a table view of the whole heap, 8.7
  times a frame (card_steps.rs: the skinning dispatches' view at offset
  5920 of the bindless table, capture replay2);
- the card's compare found the big span's pieces changed 1.84 times a
  frame of 703 declared piece checks (0.26%), the two small spans 7.3 of
  38 and 5.9 of 44;
- 0x960710000+0x2d00000 (45 MB): 14.9 pages a frame and no run (the
  title's bytes are as the copy held them); real shader output, the card
  changes 38% of its declared checks.

Checks: with the next commit, cargo clippy --workspace --all-targets
--locked -- -D warnings with and without --all-features, cargo test
--workspace --locked and cargo xtask policy; this commit alone builds
(cargo check -p victory --features diagnostics).

(cherry picked from commit 888937f776e0945308f4a4d96effb65957e62a6f)
Cause: of some 10,500 refreshes of host copies a frame in the Series S
cell, 9,000-9,500 copy nothing. Each submission's refresh_front gathered
every refresh step of its lists into tables (the copies, front_spans'
spans, the ranges ahead) and then looked at the journal for each copy
(nothing_new: the copy's locks, the journal's read lock, a walk over its
pages): some 2.3 ms a frame of the lane (run parts-now-prof1, timeline
parts-now-tl1), and making each look cheaper measured within noise.

Change: a copy keeps a stamp, the range of it that a look found holding
every write the journal holds. A look that finds nothing new sets it,
under the journal's read lock; every note of a page takes the stamps of
the copies that hold some of the page's bytes, under the journal's write
lock, before the note is in (Journal::unstamp, through an index of page
-> stamps in the journal, filled when a copy's first look finds nothing
new and emptied when it is dropped). A refresh its copy's stamp holds,
of memory whose journal is whole for it now (write-watched: the
submission's standing asking holds the range; view memory: its blocks'
bits), is left out at first sight: in refresh_front's walk of the steps,
before any table, and in the lists' steps (Batch::add), with no lock
taken and nothing asked. VICTORY_REFRESH_STAMPS=1 (or naming it in
VICTORY_AB, which keeps the stamps in both phases) turns it on; off by
default, and without it nothing is registered or stamped.

What a stamp may say is what the journal would (the invariants):
1. Every change of the journal is Journal::note (ask_ahead, ask_rest,
   writes and its guards, wrote and the pages' other views, landed_beside
   and theirs), and each note clears the stamps it touches first.
2. A stamp is set only under the journal's read lock, right after the
   look: no note comes between them.
3. A copy's taken numbers (copied, ranged) never fall for a page that was
   current (copy_stale, merge_under_writes, landed raise them or rewrite
   pages a note made stale).
4. Whether the journal is whole is asked at each use: the standing asking
   (its number, STANDING, changes with ask_rest and ask_once_end, so a
   step that wrote title memory unseen ends it) or the blocks' bits, which
   faults, puts beside the guards, remaps and frees clear.
5. A copy is in the index before its first stamp and out of it before
   its memory goes.
6. A refresh left out under shader writes is what update() does there:
   it never writes those ranges, and outside them would copy only pages
   with a newer note.

Measured (Series S, prologue cell, i9-12900K + RTX 4090, vt-go.ps1's
4090 settings, on c214714b; in-run A/B, VICTORY_AB=30,
VICTORY_REFRESH_STAMPS, medians of the settled world's frame-line
blocks, ms a frame):

| launch | blocks off/on | frame | the lane worked | its lists' steps | its refreshes | spans refreshed | of them known to copy nothing |
|---|---|---|---|---|---|---|---|
| noop-ab2 | 20 / 18 | 36.9 -> 36.4 | 36.1 -> 35.35 | 13.7 -> 12.25 | 7.85 -> 6.65 | 10,507 -> 1,251 | 9,450 -> 471 |
| noop-ab3 | 19 / 18 | 38.1 -> 37.6 | 36.9 -> 36.45 | 13.5 -> 12.5 | 7.5 -> 6.45 | 10,371 -> 1,244 | 9,400 -> 464 |

The A/B phase lines' own frame medians: 36.5 -> 35.8 and 37.7 -> 36.6.
Some 22,000 refresh steps a frame are left out by stamps (a copy's steps
in refresh_front and again in the lists' steps). The refreshes are 1.0 to
1.2 ms shorter; the lane gains 0.45 to 0.75 ms of it, the frame 0.5. The
notes' side, in both phases (stamps are kept in both): clearing stamps
under the journal's write lock 0.29 ms a frame of all threads; waits for
the journal's read lock 1.17 -> 0.66 and 1.35 -> 0.63 ms, for its write
lock 0.73 -> 0.67 and 0.76 -> 0.69 ms. (Title threads' faults take the
guards' lock, never the journal's.) The phases off match main (fin-main
w1-w3: lists' steps 13.4-13.8, refreshes 7.6-7.9).

Checks: VICTORY_REFRESH_CHECK=1 now also compares every refresh left out
with title memory (outside shader-write ranges; a 64 KiB block differing
at three looks in a row is said), and for each left out by a stamp runs
the journal's look too. Stamps on (noop-chk3-on): of 1.08 million left
out by a stamp where the journal would not have, 7 differed once, none
three times; 63 blocks said, all where the journal left the refresh out
as well. Stamps off (noop-chk3-off): 65 blocks said, the same copies
(overlapping 4 and 8 MiB windows of write-watched memory, card copies'
CPU sides): there before this change. Tests: a note takes only the
stamps it touches; a note beside concurrent looks leaves no stamp of its
page; writes through another view (a fault, a landing beside the guards,
a title copy of ours) take a view's stamp; the standing asking ends with
ask_once_end; an unregistered stamp is out of the index; refreshes left
out by stamps hold title memory (title writes, landings, our copies,
shader writes); the randomized refresh test with stamps. cargo clippy
--workspace --all-targets (with and without --all-features), cargo test
--workspace (and victory-gpu with VICTORY_REFRESH_STAMPS=1), cargo xtask
policy.

(cherry picked from commit 9d4a6d25c1f97eada14fcec73f460bb9f729aab9)
The stamps of e3d14a2d (refreshes nothing new came for, left out) are
kept and used unless VICTORY_REFRESH_STAMPS=0, as the other proven
levers; play.ps1 is unchanged. VICTORY_AB still switches them.

Gate: noop-gate (noop-stamps4.exe: e3d14a2d's code run with
VICTORY_REFRESH_STAMPS=1, which is this default; ssfps-gate.ps1, a fresh
shader cache).
- Cold and three warm launches: 38.3, 37.6, 37.6 and 38.0 ms a frame
  (pooled 26.4 fps, p10 24.4). Land's gate at the same hour, without the
  stamps, pooled the same 37.8 ms; main's fin-main warm launches earlier
  in the evening 37.1.
- 12-minute session: 36.5-38.2 ms a minute from minute 1, and 24.4-25.7
  GB private, flat, as land-gate-long's and fin-main-long's.
- No device lost, crash or panic. 246-266 draws dropped a frame, the
  ray-tracing builder's, as on the base. The head, the hair and the glass
  as the reference; the wall's flat pairs 7.2-7.4 % (fin-main-w1 7.1).
- Silhouette, by sil's recount of cell frames: the cold launch is SIL (22
  of 22 frames); warm1-3 and the session are clean. That is the known
  per-launch left-wall state: 12 of 193 launches of 2026-11-27 without the
  stamps had it; with them 1 of 10 (the four gate launches, the six A/B
  and check launches).
- A REFRESH_CHECK launch of the same exe (noop-chk4, stamps on, to frame
  3300): some 1.7 million refreshes left out by a stamp where the journal
  would not have, none differing from title memory; 64 blocks said, all
  where the journal left the refresh out too, as without stamps
  (noop-chk3-off: 65, the same copies).

Checks: cargo clippy --workspace --all-targets (with and without
--all-features), cargo test -p victory-gpu (by default and with
VICTORY_REFRESH_STAMPS=0), cargo xtask policy.

(cherry picked from commit 7ca8d601336d58cc2e6f43eed025744f651c0b79)
Two tests asked the write watch as a submission does (ask_once, or
ask_ahead and ask_rest, to ask_once_end) without the lock the other such
tests take (watch::SUBMITTING): unchanged_ranges_are_known and
the_rest_of_the_one_asking_has_a_number_of_its_own. Two askings at once
can leave one standing that never asked its ranges (one takes the other's
ranges and puts them back after it), and a refresh test beside them then
found a copy that differed from title memory: refreshes_left_out_by_stamps_hold_title_memory
failed 2 runs in 5 of the refresh and stamp tests together, none in 20
with the lock. Submissions ask only from the lane, one at a time.

(cherry picked from commit 5627c6fac7502a89ee84153160c5fafc24908da8)
Cause: with the refresh stamps (9d4a6d25), the lane still walked every
refresh step of a submission twice before its lists' steps, and looked at
a stamp for each step twice: once for the write-watch asking (a table of
each copy's span), once in front of the steps (refresh_front: each step's
stamp, then the copies, front_spans' table, the ranges ahead), and again
in the lists' steps (Batch::add, a stamp each). In a timeline of main
64a9f28d (noop-m64-tl) the walk in front was 1.06 ms a frame of the lane,
the asking's 0.40; in a sampled profile (noop-m64-prof) the stamps' looks,
some 44,000 a frame for some 10,500 copies, were 3.3 % of the lane.

Change: one walk before the asking (Batch::gather) takes, per copy, the
span its refreshes ask about, what is refreshed in front of the steps (as
front_spans has it: its refreshes up to its first write by shaders in each
part) and the copy itself; the textures due as before. The asking asks
about the first; after it (refresh_walked) each copy's stamp is looked at
once, for all it refreshes in front, and what is not fresh is refreshed
there as before. The lists' steps find in the same table what was done in
front, or found fresh there, until a step writes title memory (Batch::add,
title_written), and look at a stamp only for the rest (ranges after a
copy's shaders wrote it). VICTORY_ONE_WALK=0 walks as before.

Measured (Series S, prologue cell, i9-12900K + RTX 4090, vt-go.ps1's
4090 settings, on 64a9f28d; in-run A/B, VICTORY_AB=30,VICTORY_ONE_WALK,
medians of the settled world's frame-line blocks, ms a frame):

| launch | blocks off/on | frame | the lane worked | its lists' steps | its asking | stamps looked at a frame | the lane's CPU (user) |
|---|---|---|---|---|---|---|---|
| noop-walk-ab1 | 19 / 20 | 36.6 -> 36.05 | 35.3 -> 34.75 | 13.0 -> 12.3 | 4.6 -> 5.0 | 22,289 -> 10,204 | 22.8 -> 22.0 |
| noop-walk-ab2 | 19 / 15 | 36.4 -> 35.8 | 35.1 -> 34.9 | 13.2 -> 11.5 | 4.4 -> 4.8 | 21,079 -> 5,101 | 22.3 -> 21.7 |

The A/B phase lines' own frame medians: 35.9 -> 35.6 and 36.0 -> 35.6. A
bootstrap of the blocks puts the frame's difference at -0.55 (90 %:
-1.30 to +0.55) and -0.60 (-1.00 to -0.10). The walk now sits in the
asking's part (+0.4); the lists' steps lose the stamps' looks.

Checks: a test (the walk takes from the same steps what front_spans and
the asking's table take, and holds what is done in front and nothing
else). cargo clippy --workspace --all-targets (with and without
--all-features), cargo test --workspace, cargo xtask policy.

(cherry picked from commit 0217262923b83fa4bec59dc7e36f2c9205d8cb80)
Cause: with flights in the air, each submission walked its steps once more
for the copies shaders may be writing (stale_under_flights: a table look
at every refresh step, and again at each round of settle_stale), after the
one walk (02172629) had gone over the same steps. In a sampled profile of
main 64a9f28d (noop-m64-prof) that walk was 1.5 % of the lane's samples.

Change: the one walk also keeps, per copy, the span of all its refreshes
and the order of its first refresh; stale_under_flights takes from there
the copies shaders may be writing, in the same order and with the same
spans (stale_walked), and the rest is as before (the title's bytes put in
under the flights' writes, or what is stale under them, stale_of).
VICTORY_STALE_WALKED=0 walks the steps, as before; so does a submission
without the one walk.

Measured (Series S, prologue cell, i9-12900K + RTX 4090, vt-go.ps1's
4090 settings, on 02172629; in-run A/B, VICTORY_AB=30,VICTORY_STALE_WALKED,
the one walk on in both phases, medians of the settled world's frame-line
blocks, ms a frame):

| launch | blocks off/on | frame | the lane worked | its title bytes under flights' writes | the lane's CPU (user) |
|---|---|---|---|---|---|
| noop-stale-ab1 | 17 / 15 | 35.2 -> 34.8 | 34.3 -> 34.1 | 6.4 -> 6.3 | 21.2 -> 20.7 |
| noop-stale-ab2 | 20 / 16 | 35.3 -> 34.95 | 34.35 -> 34.05 | 6.1 -> 5.75 | 21.35 -> 21.1 |

The A/B phase lines' own frame medians: 34.7 -> 34.2 and 34.8 -> 34.4. A
bootstrap of the blocks puts the frame's difference at -0.40 (90 %:
-0.70 to +0.10) and -0.35 (-0.80 to +0.10): the same way in both, within
what two halves of one launch differ by.

Checks: the one walk's test also checks the order and the spans. cargo
clippy --workspace --all-targets (with and without --all-features), cargo
test --workspace, cargo xtask policy.

(cherry picked from commit 532384de1021f4da08b7131aa424288b15c0b14e)
The A/B phase line gave the frames' mean, median and nine tenths; it now
ends with the one tenth (p10) as well, to see whether a switch spreads the
frame times both ways, not only the slow ones. Appended at the end of the
line, so what reads it up to p90 (ab_parts.py, guards_ab.py) reads it as
before.

(cherry picked from commit 3ef255bd40832903460d4ba1dbec4da1eab76aa1)
Cause: with flights in the air the line's thread plans a submission's
steps on the card twice. cut_for (in execute_parts, for submissions with
a copy at its place in a list, VICTORY_PLACED_ORDER) runs does_of and
plan to see whether the submission is to be cut; when it is not, the
same submission's Host::card_steps runs both again moments later, over
the same lists, with the same flights in the air. Profile land-c3a6-prof1
(main c3a61b7c, Series S cell), the line's thread, ms a frame: cut_for
1.2 (plan 0.73, does_of 0.36), take_steps' does_of and plan 0.95 more.
Inside plan, a boxed iterator for each taken step (some 2,800 fills a
frame) was an allocation and a free each: 152 of plan's 471 samples;
does_of grew its two vectors from empty: 151 samples of pushes.

Change (on by default; VICTORY_PLAN_ONCE=0: made twice, as before;
VICTORY_AB switches it while the title runs): the plan cut_for makes for
a submission it does not cut is kept (card_steps::PLANNED, one), with
what it was made of; Host::card_steps takes it (plan_of) if it was made
of the same, else makes its own as before, and lets the kept one go
either way. And, as plain code: plan's levels walk the steps ahead
without a boxed iterator, and does_of sizes its vectors from the lists'
step counts.

What "the same" is, and why that is enough:
- The lists, by address, with their steps' counts and their epochs.
  Every reset and every change noted on a list moves its epoch on (a
  global counter, next_epoch), so a list given back to the pool and
  recorded anew, or one recorded into since, is not the same.
- What flights may write (the line's written ranges), compared whole:
  does_of's `asked` is made of them and the steps' ranges alone.
- Whether copies at their place keep their order (placed_order, which
  VICTORY_AB may switch between the two).
- stage() is read once for the run.
plan and does_of are made of nothing else. Between cut_for and
card_steps nothing records into the submission's lists (execute_parts,
send_late, submit up to card_steps), and a cut submission has other lists
than the plan's. A kept plan that is not taken by the next card_steps is
let go by it: none outlives one submission's taking.

MEASURED

Tests: card_steps::tests::a_kept_plan_is_taken_for_the_same_submission_only
(taken for the same lists, flights and order; let go and made anew with
other flights, another order, other lists, a list changed, a step more;
what is made now is what does_of and plan make). The card steps' tests,
and the whole way with VICTORY_RELAY=2 VICTORY_CARD_STEPS=2
VICTORY_RELAY_COPY=1 VICTORY_PLACED_ORDER=1, pass.

CHECKS

(cherry picked from commit 0cbf5537b381cad92aa568efc5a4d4b62477860a)
…_NOT

Every switch brought over from Biskwit/VIctory-reloaded is now off unless
set to 1: VICTORY_PLACE_APART, VICTORY_PLACE_LANE, VICTORY_FAULT_FAST,
VICTORY_REFRESH_STAMPS, VICTORY_WIDE_WAKE, VICTORY_XMEM_WATCHED,
VICTORY_AMBIENT_DEPTH, VICTORY_CLEAR_UAV (=1 clears, unset = no-op as in
f4b48ad). Reloaded's shader-hash VICTORY_LAND_NOT is renamed
VICTORY_LAND_NOT_SHADERS so it does not clash with PR #13's
length-based VICTORY_LAND_NOT.

Change written by DeepSeek (mistral-bridge), applied verbatim.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FLuVRo7Q6qg2cYBG795Fwu
Needs library::loads() from Vice-Tay, which our base does not have; the
test target did not compile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FLuVRo7Q6qg2cYBG795Fwu
@oceansde012 oceansde012 self-assigned this Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants