Skip to content

GPU: cheaper guards and copy refreshes in the world (seven switches, all off by default) - #987

Draft
cybx wants to merge 10 commits into
fxceless:mainfrom
cybx:fps-switches
Draft

cybx wants to merge 10 commits into
fxceless:mainfrom
cybx:fps-switches

Conversation

@cybx

@cybx cybx commented Nov 25, 2026

Copy link
Copy Markdown

Draft. This branch itself has not been run in the game yet. Every frame time and count below was measured on our integration branch (this repository's main with several open pull requests and these commits on top), not on this branch. Each number names the run it comes from. The checks that were run on this branch are listed further down.

Why

In the world of the title we test with, a large share of each frame went into keeping the host copies of title memory current, on the submitting thread:

  • the guards of view memory took about 18 ms a frame (run int-c);
  • the guards asked Windows about memory 10,000 to 12,000 times a frame (runs int-i-1, int-k-2, st-o-kv);
  • card_dirty walked all 3,540 card copies at each of about 29 submissions a frame (run int-m-kb);
  • a refresh took, and sent to the card, every 64 KiB page the write watch named, about 97 MB a frame, where about 12 MB had changed (runs st-t-k, st-t-rc).

What changes

Always on. These change how an answer is found, not the answer:

  • The guards answer clean ranges from a bit set (watch.rs). clean (and absent) are bit sets, 64 blocks to a word. Whether a range is all clean is answered a word at a time. writes looks up once whether a range is a view the guards know, and writes_into fills a list the caller keeps between askings. A test checks the bit set against a tree of blocks. Diagnostics builds log the guards' askings, the questions to Windows and the protections asked, per frame.
  • A refused protection is retried run by run (watch.rs). It is still retried block by block, but a block that is not committed answers for the whole uncommitted run it begins: one question to Windows, and no protection asked for the rest of the run. The blocks noted absent are the same as before.
  • Lookups of title buffer copies share a lock (shadow.rs). BUFFERS and LOOSE are behind an RwLock. A lookup that finds the copy (nearly every one) takes the lock shared.
  • Card copies are queued when they change (shadow.rs). card_dirty now empties a queue of the copies that changed, instead of walking every copy in the card's memory at every submission. The same ranges are sent, in the same submissions.
  • queue::presented() is in every build, not only diagnostics builds.

Behind switches, all off unless set:

Switch What it does What it gives up
VICTORY_INDIRECT_WINDOW_DRAWS=1 With VICTORY_INDIRECT_WINDOW=1, a draw ends an indirect draw window only if its shaders can store to buffers, or if its host pipeline is not known. Dispatches and new host lists still end the window. Assumes that a draw whose shaders cannot store to buffers writes neither the argument buffer nor the list's scratch buffer. Not measured on its own.
VICTORY_CARD_BUFFERS_MIN_KB=<KiB> Sets the smallest title buffer copied to the card's memory, in KiB, below 1 MiB too (0: every title buffer). The total stays within VICTORY_CARD_BUFFERS_MB. More card memory: 3,540 copies (1,182 MB) in run int-m-kb, against 97 copies (941 MB) with the 1 MiB floor in run int-m-1.
VICTORY_GUARD_HOLES_FRAME=1 What Windows says of an uncommitted run is kept until the next frame is presented, or until the runtime maps or unmaps memory. A block that the title commits without a word from the runtime, after the frame's first question about it, is copied as zeros until the next frame.
VICTORY_GUARD_HOLES_FRAME=2 A hole holds, with no question to Windows, until the runtime tells of a mapping or of a commit there. The commits told of are: the title's VirtualAlloc, XMemVirtualAlloc with MEM_COMMIT, XMemAllocDefault, and the layer's own allocations for the title. As a safety net, each hole is looked at again once every VICTORY_GUARD_HOLES_RECHECK frames (16 if unset; 0: never). A hole found committed with no word from the runtime is logged. Memory committed in a way the runtime does not tell of is copied as zeros until its hole is looked at again: at most 16 frames by default.
VICTORY_REFRESH_COMPARE=1 A refresh compares the written pages it took before with the copy. It takes, and marks to be sent to the card, only the 4 KiB steps that differ. Every written page is read twice, so the refresh takes about as long on the submitting thread as before.
VICTORY_WIDE_COMPARE=1 With VICTORY_REFRESH_COMPARE=1, a refresh with 1 MiB or more to compare is split into pieces of about 256 KiB. The snapshot threads and the refreshing thread share them. Keeps more threads busy. The frame time did not change measurably (below).
VICTORY_VIEW_RECHECK=<N> Meant for VICTORY_VIEW_GUARD=0. Once a frame, a share of the clean guarded blocks is reported written once, so each block's copies read it again every N frames. With VICTORY_REFRESH_COMPARE=1 only the bytes that differ are taken. No protection is asked of Windows. A copy can still be up to N frames behind. This is a bound, not the guarantee that VICTORY_VIEW_GUARD=1 gives.

On the integration branch we ran these switches together: VICTORY_GUARD_HOLES_FRAME=2 VICTORY_REFRESH_COMPARE=1 VICTORY_WIDE_COMPARE=1 VICTORY_CARD_BUFFERS_MIN_KB=0 VICTORY_CARD_BUFFERS_MB=2048 VICTORY_INDIRECT_WINDOW=1 VICTORY_INDIRECT_WINDOW_DRAWS=1. We also set VICTORY_VIEW_GUARD=0 VICTORY_VIEW_RECHECK=64, which trades correctness for time (see the table below).

Measured on our integration branch, not on this branch

Machine: Ryzen 7 9800X3D, RTX 5070 Ti 16 GB, 32 GB RAM, Windows 11. Frame times are the readings of the frame-rate line in the first world cell, several per run; the noise from run to run is about 3-4 ms. "Before" and "after" are neighbouring runs of the integration branch, so other changes may lie between them where noted.

Change Runs, before → after Before After
Bit set of blocks int-c → int-h-1, int-i-1, int-j-1 (other changes in between) guards 18.1-18.4 ms a frame guards 11.3-12.2 ms a frame
VICTORY_GUARD_HOLES_FRAME=1 int-k-2 → int-k-3 11,864-11,872 questions to Windows a frame; the submitting thread's kernel time in submissions 18.1-25.6 ms a frame 6,276-6,600 questions; 15.6-16.9 ms
Card queue int-m-kb → st-o-kv card_dirty 352-370 ms in a 10 s profile; preparing a frame 50.6-52.8 ms card_dirty 19 ms; preparing 48.4-49.6 ms. Frames 70.7-71.5 ms against 65.6-71.5 ms: no change
VICTORY_GUARD_HOLES_FRAME=2 st-o-kv → st-q-kv2 (repeat: st-q-kv2r) 12,210-12,219 questions a frame; guards 12.0-12.1 ms; preparing 48.4-49.6 ms; frames 70.7-71.5 ms 443-445 questions (493-503 in the repeat); guards 5.0 ms; preparing 40.2-42.4 ms; frames 65.2-67.8 ms. No hole that was looked at again was found committed
VICTORY_REFRESH_COMPARE=1 st-t-k → st-t-rc 97.4-97.9 MB a frame sent to the card, in 797-870 ranges; frames 72.0-73.6 ms 11.0-11.2 MB in 480-494 ranges (96.1 MB read, 11.7 MB differed); frames 69.9-72.2 ms
VICTORY_WIDE_COMPARE=1 (with VICTORY_HEAP_SYNC=0) st-t-rc-hs0 → st-u-wc-hs0 Shadow::update_free 2,676 ms in a 10 s profile; frames 60.9-63.7 ms 2,226 ms; frames 60.3-61.7 ms, within the noise
VICTORY_VIEW_RECHECK=64 (with VICTORY_VIEW_GUARD=0) st-u-wc → st-v-rk64, st-v-rk64b frames 68.5-72.3 ms frames 69.4-75.7 ms; 421-431 blocks a frame made due
VICTORY_CARD_BUFFERS_MIN_KB=0 int-m-1, int-m-2 → int-m-kb (same build) frames 100.6-109.7 ms frames 65.6-71.5 ms. The logs do not record the other switches of these runs, so this gain is not shown to come from this switch alone

The trade-off behind VICTORY_VIEW_RECHECK: with VICTORY_VIEW_GUARD=1 the world ran at 96.0-100.8 ms a frame (st-u-vg), against 68.5-72.3 ms with it off (st-u-wc). With it off, our notes record a wall of the first world room missing in 7 of 10 runs, because a write through another view of the same pages does not reach the guarded copy. The wall was drawn in all three runs with VICTORY_VIEW_RECHECK (st-v-rk64, st-v-rk64b, st-v-rk16). Three runs are few, so that cause is still a hypothesis.

With all of this and the other pull requests, the integration branch still runs the title at about 13-17 fps in the world: 68.1-77.1 ms a frame with the default switches (st-z-play), and 57.0-64.9 ms with VICTORY_HEAP_SYNC=0 VICTORY_MERGE_GAP=64 (st-z-hs0-gap).

Checks on this branch

All on this branch's tree (Windows 11, the toolchain of rust-toolchain.toml):

  • cargo build --profile diag -p victory --locked (without diagnostics): builds.
  • cargo build --profile diag -p victory --features diagnostics --locked: builds.
  • cargo test --profile diag -p victory-gpu --locked: 175 passed, 0 failed, 5 ignored, in each of the last two runs. One earlier run of the same tree stopped with an access violation in the test process after 54 tests had passed. Run again one test at a time, that binary had 174 passed and 1 failed (indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields, which passed in both later runs). The access violation did not come back, and its cause was not found.
  • cargo xtask policy: passes.
  • Not run in the game.

Left out

  • The heap pass in slot order (heap_pass::Picked::plan over B-tree maps). It needs heap_pass.rs from GPU: heap buffer pass looks only at marked slots; time split and visi… #523, which is still open. On the integration branch it took Picked::plan from 1,195 ms to 262 ms in a 10 s profile (st-x-play → st-y-play). It can follow GPU: heap buffer pass looks only at marked slots; time split and visi… #523.
  • VICTORY_RELAY_COPY_QUEUE, which we also ran with. It is not our work, so it is not part of this pull request.
  • Our fill-ahead modes (VICTORY_FILL_AHEAD). No gain was measured, and main already reads ahead by default (fill_ahead; VICTORY_FILL_WAIT=1 turns it off).
  • Our larger pool of idle lists and VICTORY_MERGE_RUNS. main already has both (IDLE_MOST is 512 there).
  • Our always-on set of known views. This branch keeps main's viewed set behind VICTORY_VIEW_KNOWN, off by default; our variant behaved like VICTORY_VIEW_KNOWN=1.
  • Commits that only add diagnostics, such as logging why an indirect window was clamped.

Related

cybx added 10 commits November 25, 2026 12:07
In the world the guards of view memory took about 18 ms a frame (run
int-c: "guards 18.1-18.4 ms"). Most askings find their whole range
clean (1,572 of 2,619 a frame in run int-h-1), and finding that out
counted the range's clean blocks one by one in a tree of blocks.

- `clean` is a set of bits, 64 blocks to a word: whether all of a range
  is clean is answered a word at a time (`Blocks::holds`), and the
  clean blocks of a range are read off the words in order.
- `writes` asks whether the range is a view the guards already know
  once, and hands the answer to `guard`, which looked it up a second
  time under the lock.
- `writes_into` fills a list the caller keeps between askings: building
  a new list at each asking showed in the submitting thread's profile
  (run int-b: vectors built from tree iterators 3.9% and 3.1% of its
  samples, their growth 3.3%). `writes` keeps its form on top of it.
- Diagnostics builds count, per frame, the guards' askings, those of
  ranges known as views, those found all clean, the blocks the others
  walk, the questions to Windows about memory and the protections asked.

What is reported written does not change. In later runs with other
changes in between, the guards took 11.3-12.2 ms a frame (runs int-h-1,
int-i-1, int-j-1). A test checks the bit set against a tree of blocks
over random insertions, removals and ranges.
…VICTORY_INDIRECT_WINDOW_DRAWS, off by default)

With VICTORY_INDIRECT_WINDOW=1 the indirect records clamped in one pass
stay usable by the next indirect draws (a window) until something may
have written the arguments. Every direct draw and mesh dispatch ended
the window, so the next indirect draw paid a clamping pass of its own.

With VICTORY_INDIRECT_WINDOW_DRAWS=1 only a draw whose shaders can store
to buffers (or whose host pipeline is not known) ends it: no other draw
writes the argument buffer or the list's scratch buffer. Dispatches, a
new host list and everything else that ended a window still do.

Off by default. Measured only together with the other switches of this
branch (see the pull request); not measured on its own.
The title's recording threads and the submitting thread look up the
host copies of title buffers (BUFFERS) and of memory outside buffers
(LOOSE) thousands of times a frame, and each lookup took one Mutex:
in a 10 s profile of run int-b, `lookup` was 12.4% of a recording
thread's samples, a thread that spent 33.8% in contended locks.

- Both maps are behind an RwLock. A lookup that finds the copy made
  (nearly every one) holds the lock shared; making a copy takes it
  alone and picks again, since another thread may have made the copy
  in between. Letting idle windows go still takes the lock alone, so no
  window is handed out while it is being let go.
- The refreshes on the submitting thread keep their list of written
  pages in a thread-local between askings (`watch::writes_into`).

No change in what is copied or when. Not measured in the game on its
own: the frame-rate table of the pull request covers it together with
the other changes.
…FFERS_MIN_KB, off by default)

The host copies of title buffers kept in the card's memory had a floor
of 1 MiB (VICTORY_CARD_BUFFERS_MIN_MB cannot go lower), so shaders read
the smaller title buffers over the bus from the copy in the processor's
memory.

VICTORY_CARD_BUFFERS_MIN_KB gives the floor in KiB instead (0: every
title buffer), still within VICTORY_CARD_BUFFERS_MB. Unset, nothing
changes.

With 0, run int-m-kb kept 3,540 copies (1,182 MB) in the card's memory
where runs int-m-1 and int-m-2 of the same build kept 97 (941 MB), and
its frames took 65.6-71.5 ms against 100.6-109.7 ms. The logs do not
record the other switches of those runs, so the gain is not shown to
come from this switch alone.
…frame (VICTORY_GUARD_HOLES_FRAME, off by default)

The title's streamed buffers lie over placeholders with holes, and the
guards asked Windows (VirtualQuery) about every uncommitted run they
walked, at every asking: 10,258-11,872 questions a frame in the world
(runs int-i-1, int-k-2), inside the submitting thread's kernel time.

- With VICTORY_GUARD_HOLES_FRAME=1 the end of an uncommitted run is
  kept until the next frame is presented, or until the runtime maps or
  unmaps memory. What is given up: a block the title commits with an
  ordinary commit (no word from the runtime) after the frame's first
  question about it is copied as zeros until the next frame.
- A protection refused for a range is tried again block by block as
  before, but a block that is not committed now answers for the whole
  uncommitted run it begins (one question, no protection asked for the
  rest of it). The blocks noted absent are the same.
- `queue::presented()` is in every build, not only diagnostics builds.

Run int-k-3 against int-k-2: 6,276-6,600 questions a frame against
11,864-11,872, and the submitting thread's kernel time in its
submissions 15.6-16.9 ms a frame against 18.1-25.6 ms; the picture of
the first world cell was right.
…ked at every submission

`card_dirty` walked every copy kept in the card's memory at every
submission (Vec::retain over weak references) to find the few that
changed. With the title's small buffers on the card that was 3,540
copies times 29 submissions a frame: 352-370 ms in a 10 s profile of
the submitting thread (run int-m-kb).

- A card copy has a `queued` mark and goes into CARD_QUEUE with the
  first range that changes on its CPU side; `card_dirty` empties only
  that queue, clearing the mark under the copy's `dirty` lock, so a
  change after that queues it again.
- CARDED holds weak references by the copy's address (a weak reference
  keeps the allocation, so no other copy can have that address while
  the entry is there). Entries of copies that are gone are swept when
  they may be half of the map.
- The test that builds a `Card` by hand sets the new field.

The same ranges are sent to the card, in the same submissions. Run
st-o-kv against int-m-kb: `card_dirty` took 19 ms of a 10 s profile and
preparing a frame 48.4-49.6 ms against 50.6-52.8 ms; the frame time did
not change (70.7-71.5 ms against 65.6-71.5 ms, within the scenes'
spread).
…mit (VICTORY_GUARD_HOLES_FRAME=2, off by default)

With VICTORY_GUARD_HOLES_FRAME=1 the guards still asked Windows about
every uncommitted run once a frame: 12,210-12,219 questions a frame in
the world (run st-o-kv), nearly all with the answer of the frame
before.

- VICTORY_GUARD_HOLES_FRAME=2 keeps a hole, its blocks counted as
  clean, with no question and no walk, until the runtime tells of a
  mapping there (`title_memory_remapped`) or of a commit
  (`title_pages_changed`). The commits told of are the title's
  `VirtualAlloc` (stood in front of only while this level is on),
  `XMemVirtualAlloc` with MEM_COMMIT, `XMemAllocDefault`, and the
  layer's own allocations for the title (`resource::Memory`). They are
  queued and applied by the next asking, so the title's threads never
  wait for the guards.
- As a safety net a share of the holes is looked at again every frame,
  each hole once every VICTORY_GUARD_HOLES_RECHECK frames (16 unset; 0
  never). A hole found committed or mapped with no word from the
  runtime is logged with what Windows says of it.
- `absent` is a set of bits like `clean`.

What is given up: memory committed in a way the runtime does not tell
of is copied as zeros until its hole is looked at again (at most 16
frames by default).

Run st-q-kv2 against st-o-kv: 443-445 questions a frame against
12,210-12,219, guards 5.0 ms a frame against 12.0-12.1 ms, preparing a
frame 40.2-42.4 ms against 48.4-49.6 ms, frames 65.2-67.8 ms against
70.7-71.5 ms. No hole looked at again was found committed (no such
line in the log of st-q-kv2 or of its repeat st-q-kv2r).
…y (VICTORY_REFRESH_COMPARE, off by default)

The write watch is kept by 64 KiB page and names a page for one byte
written, our own writes included: what a landing puts into title memory
is in the copy already, yet the next refresh took the whole page again
and, for a copy in the card's memory, sent it up to the card.

With VICTORY_REFRESH_COMPARE=1 a refresh reads the named pages the copy
took before, compares them with the copy and takes, and marks to be sent
up, only the 4 KiB steps that differ. Pages the copy never took, and
title memory that cannot be read, are taken whole as before. The frame
line tells what was read and what differed. A test checks the steps
taken against the bytes changed.

Run st-t-rc against st-t-k (same build, without the switch): 96.1 MB a
frame of written pages read, 11.7 MB of them different; sent up to the
card 11.0-11.2 MB a frame in 480-494 ranges against 97.4-97.9 MB in
797-870; frames 69.9-72.2 ms against 72.0-73.6 ms. The refresh takes
about as long on the submitting thread as before: it reads and compares
where it read and wrote.
…s (VICTORY_WIDE_COMPARE, off by default)

With VICTORY_REFRESH_COMPARE=1 the submitting thread reads and compares
about 100 MB of written pages a frame, a page at a time: work bound by
one core's memory speed, as the snapshots were.

- `copy_stale` gathers the runs a refresh has to compare and hands them
  to `copy_changed` at once.
- With VICTORY_WIDE_COMPARE=1 a refresh with 1 MiB or more to compare
  cuts it into pieces of about 256 KiB, at 64 KiB page boundaries, for
  the victory-wide threads and itself. Each piece reads, compares and
  writes only its own bytes of the copy; the change notes (`changed`,
  `card_changed`) and unreadable stretches stay on the refreshing
  thread, after the bytes are in.
- `wide_apart` does not take other callers' work off the queue while
  its caller holds the copy's page lock, and a victory-wide thread never
  spreads work again.

Tests check the cutting at page boundaries and the steps taken.

Measured with VICTORY_HEAP_SYNC=0 (run st-u-wc-hs0 against st-t-rc-hs0,
10 s profiles): `update_free` 2,226 ms against 2,676 ms on the
submitting thread; frames 60.3-61.7 ms against 60.9-63.7 ms, within the
noise: there the card is the limit. With heap sync on, frames 68.5-72.3
ms (st-u-wc) against 69.9-72.2 ms (st-t-rc). Hence off by default.
…EW_RECHECK, off by default)

With VICTORY_VIEW_GUARD=0 (about 30 ms a frame cheaper in the world) a
write through another view of the same pages does not fault at the
guarded view, and the copy there keeps the old bytes for good. In the
first world room a wall was missing in 7 of 10 runs with VIEW_GUARD=0
and drawn in the 3 runs with it on (96.0-100.8 ms a frame, st-u-vg).

With VICTORY_VIEW_RECHECK=N, once a frame, the clean blocks in the words
of blocks whose number is the frame modulo N are made due: the next
asking reports them written once and their copies read them again (with
VICTORY_REFRESH_COMPARE=1 only the bytes that differ are taken). The
blocks stay read-only, so no protection is asked of Windows, and the
holes are left to `holes_due`. Diagnostics builds count the blocks made
due. A test checks a turn's share of the blocks.

What is given up: a copy can still be up to N frames behind; this is a
bound, not the guarantee VIEW_GUARD=1 gives. Without REFRESH_COMPARE
every block made due is taken whole (not measured).

Measured in the world with REFRESH_COMPARE and WIDE_COMPARE on: N=64,
421-431 blocks a frame made due, frames 69.4-75.7 ms (st-v-rk64 and
st-v-rk64b), the wall drawn in both; N=16, 1,691-1,699 blocks a frame,
frames 74.8-81.8 ms (st-v-rk16), wall drawn; without the recheck,
68.5-72.3 ms (st-u-wc). Three runs with the wall drawn are few: that
the wall was lost to writes through other views is a hypothesis
supported by this count only.
x0sman added a commit to x0sman/victory-fork that referenced this pull request Nov 25, 2026
…t time)

Hardware-verified on RTX 5070 Laptop GPU (8 GB) in 95s 3D gameplay (0 crashes).

Includes upstream PRs (#1677, fxceless#987, fxceless#188, fxceless#610) plus Phase 1-3 changes:
- descriptor/host.rs: lock-free AtomicU64 + 64-striped slot_locks/kept in HostHeap::mirror
- host.rs & queue.rs: victory-reaper background thread for COM/late-wait drops; Held::Present 2nd MPO plane support for VICTORY_ASYNC_PRESENT=1
- xmem.rs: XMemMapPhysicalPagesScatter single-lock hoisting, no-op skipping, exact 64 KiB placeholder fast path (preserving 64 KiB page independence)
- shadow.rs: move D3D12 buffer allocations (shared_buffer, card_for, window_card_for, place_for) outside BUFFERS/LOOSE write locks
- draw.rs, host.rs, indirect.rs, list.rs: 2-slot isolated indirect_window_scratch ring synced with draw::State::windows, remove post-clamp global UAV(None) barrier, use targeted uav_barrier_for(src/count) via UAV cleanliness tracking, default VICTORY_TEXTURE_STAGE_MB=48

Measured 1000 Hz profile (baseline -> Phase 3):
- usual frame: 183.2 ms -> 102 ms (-45%)
- GPU all other lists: 70.3 ms -> 36.4 ms (-48%)
- GPU card busy: 47% -> 68%
- shadow RwLock wait: 93.46 ms (P1+2) -> 0.00 ms (-100%)
- execute_indirect: 167.05 ms (P1+2) -> 78.10 ms (-53%)
@UwUCammie

UwUCammie commented Nov 25, 2026 •

Copy link
Copy Markdown

I tried the 4 KiB changed-chunk compare with 64 KiB-and-larger card buffers on an RX 7900 XT (RADV 26.3.1, Wine 11.22). The integration build also tracked dirty card buffers. It presented 665 frames in 73.74 seconds, 9.02 FPS at 4,847 draws/frame. The comparable small-card-buffer run without those two changes was 8.36 FPS. Lower upload volume was visible in the frame measurements, but the two changes were bundled, so this does not isolate the compare’s FPS effect.

I also sampled previously initialized pages about to be refreshed on the RX 7900 XT. Across 9,984 samples from a first-room run, all 646,286,720 bytes were readable. Chunks containing a changed byte covered 31.18% at 4 KiB, 39.27% at 16 KiB and 55.84% at 64 KiB. The samples compare against the CPU staging copy and the renderer still performs its normal refresh. The sampler and build instructions are on my fork.

PiloteCode added a commit to PiloteCode/victory-fork that referenced this pull request Nov 25, 2026
…and questions to Windows per frame, and four switches for re-arming (VICTORY_TRACK_REARM=consume, VICTORY_TRACK_VOLATILE=<n>, VICTORY_TRACK_WIDEN=<size>, VICTORY_TRACK_HYGIENE=1; all off)

Stage 2 of the coherence plan (reports/, "LA solution"): the protocol of
the guards on view memory and the bookkeeping around it. Wave 7's logs
place the cost first. Guard faults are 300-700 a frame, while the title
streams too (copystat's "guard faults", the frame log's "faults: P page,
G guard"); the 30,000-225,000 "page faults" a frame beside them are the
process's soft faults of new mappings, not write traps. What the guards
pay for is the re-arming: 7,000-16,000 view blocks walked and guarded
again a frame ("view memory askings ... walked N blocks"), some 470 calls
a frame guarding the other views of a page, 8-30 ms a frame of "guards".
Re-arms were already made where a copy consumes a block: the check
before each copy, protect then copy.

- Diagnostics, one line with each frame-rate line ("write tracking per
  frame"): guard faults, on how many distinct blocks, on blocks guarded
  with other views and over how many distinct pages, on the submitting
  thread; the handler's time and its wait for the guards' lock; re-arms,
  on how many distinct blocks, in how many protections and their time;
  protections of other views, protections giving write access back, and
  their time; runs of blocks whose protection Windows refused; view
  blocks made not clean by cause (faults, writes told, another view
  written, mappings, first seen); questions to Windows and their time;
  the submitting thread's askings, their time and their waits for the
  journal's and the guards' locks; open blocks; blocks opened around
  faults. Every protection and question of the guards goes through one
  of two timed helpers.
- VICTORY_TRACK_REARM=consume: a check's re-arms are made at its end:
  its runs cut at the runtime's views (a protection asked across two
  views is refused, then retried block by block with a question to
  Windows for each block), and the other views of the check's blocks
  gathered and guarded in runs instead of one protection each.
- VICTORY_TRACK_VOLATILE=<n>: a block found written at n consecutive
  checks that covered it is left open: not guarded again, reported
  written at every check (so copied at every consumption, as it was
  while it faulted), and guarded again once after 32 checks as a probe.
  Never a block with other views, and forgotten when the runtime maps or
  unmaps it or another view of its pages appears.
- VICTORY_TRACK_WIDEN=<size> (256K, 1M; a bare number is KiB): while
  DirectStorage wrote in the last half second, a fault opens every
  guarded block of the aligned window around it.
- VICTORY_TRACK_HYGIENE=1: whether a range is a view is answered from
  the runtime's views when one lies in it (no walk of the address space,
  which steps through each 64 KiB placeholder of a hole); a protection
  refused for a run is retried block by block, and a block found
  uncommitted answers for its whole uncommitted run (one question;
  from fxceless#987, whose bit set of clean blocks and
  answers kept for holes the view set and the parked blocks already
  cover here).

Tests, on memory only: re-arms joined over a check guard the other views
again (a write through a view no copy checks is seen at the checked one,
twice); a block written at every check is left open, probed after 32
checks, and tracked as before once a check finds it clean. With the
switches off the guards work as before: the watch tests pass unchanged.
PiloteCode added a commit to PiloteCode/victory-fork that referenced this pull request Nov 25, 2026
…joined into runs at the check's end (VICTORY_TRACK_REARM=consume), blocks written at every check left open with a probe (VICTORY_TRACK_VOLATILE=n), wider openings while DirectStorage writes (VICTORY_TRACK_WIDEN), view questions from the runtime's view list and refused runs retried (VICTORY_TRACK_HYGIENE=1, from fxceless#987); all off
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.

2 participants