Synchronisation core: commit leak fix, exact refresh runs, list summaries, heap hooks on, and a night of NVIDIA/Ampere work #3650

Closed
happyrain01 wants to merge 3 commits from upstream-pr/3650 into main
happyrain01 commented 2026-11-30 02:58:08 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by happyrain01 on 2026-11-30T02:58:08Z.


This is a squashed change from a fork tuned on an RTX 3080 (10 GB, no
Resizable BAR), Ryzen + 32 GB, Windows 26300, driver 617.42 then 621.40,
Series S profile at 1440p. It sits on top of v2026.11.29.05 (41adb551).
Everything new is behind a switch, and the switch names below give the way
back to the previous behaviour. A second commit (section 9) adds the work
of 2026-11-30, and a third (section 10) bounds the 1 Hz sweep's walk.

1. Commit leak: every run leaked ~4.7 GB of system commit (fixed)

OpenExistingHeapFromFileMapping on a SEC_COMMIT section leaves the whole
section's commit charge behind after the process ends, however it ends
(killed, normal exit, heap released first). Proven with a standalone probe
on driver 617.42. A heap opened with OpenExistingHeapFromAddress on a
MapViewOfFile view of the same section leaves nothing. With
VICTORY_PORT_SECTIONS the title's three page-pool sections (194 + 4,170 +
311 MB) were opened that way at every launch, so after a few dozen runs
since boot the game died with "LLVM ERROR: out of memory", DirectStorage
error 1450 or HLSL compile refusals, until a reboot.

  • inplace::open, From::Section: maps a view of the whole section, kept
    until the section goes (SECTION_VIEWS, section_view_gone, unmapped by
    host::retire after the flights in the air), and opens the heap on the
    view. If the view is refused (a view above 4 GiB gives E_INVALIDARG), the
    memory is copied: there is no fallback to the leaking call.
  • VICTORY_SECTION_BY_VIEW=0 restores the old behaviour.
  • Checked in game: +1.2 GB of system commit after a run instead of ~+4.7;
    unattributed commit 3.1 GB in total; -0.06 GB on driver 621.40.
  • Upstream main still uses OpenExistingHeapFromFileMapping
    (inplace.rs, From::Section).

2. Refreshes on exact runs instead of min..max envelopes

A copy's refreshes in front of a submission (front_spans_into,
written_spans), the pending refreshes while steps are recorded
(Batch::add / flush_one / flush) and the submission's one write-watch
asking (copy_spans) all used one span per copy, from the lowest byte named
to the highest. Two draws reading a few bytes at both ends of the title's
174 MB frame buffer made the journal and the write watch look at all of it:
31.7 GB named and 9.55 GB checked per frame, 9.50 GB of it unchanged
(diagnostics build, copystat).

  • Runs are now kept apart, joined only where they overlap or lie closer than
    VICTORY_SPAN_GAP_KB (64).
  • What was refreshed ahead (Batch::ahead) keeps exact runs, so a gap is
    never taken as done.
  • VICTORY_SPAN_ENVELOPE=1 (switchable with VICTORY_AB) restores the
    envelope.

3. One summary per list (HostList::summary)

  • Per copy, the summary keeps the runs read before the list first gives the
    copy to shaders, all runs read, and whether it does; plus the list's
    texture steps.
  • It is made once, and made again only if steps were added.
  • The submission's walks read the summary instead of the steps.
  • VICTORY_LIST_SUMMARY=0 turns it off.

"Up to date for certain" lists (VICTORY_LIST_CERTAIN, off by default since section 9)

  • When a list closes, on the thread that closes it and before it is marked
    done, HostList::certify checks two things: what the list reads in front
    of shader writes is up to date, and all of it lies in published (guarded,
    clean) blocks. If so, it notes a sequence number.
  • watch::REOPENED is a lock-free ring of every block that stops being
    published or gets bytes beside a guard.
  • At submission, a list none of whose blocks were reopened since needs no
    check at all.
  • The certification must happen before the list is marked done: done
    afterwards, the line could move the host list while its lock was held, and
    the moved copy stayed locked forever. That hang was found and fixed here.
  • Off by default since the second commit (VICTORY_LIST_CERTAIN=1 turns it
    on): it spared 2 to 3 ranges a frame, for a check of about 216 lists at
    close on the threads that translate them (11 to 16 µs more per translated
    call).

4. Descriptor heap hooks on by default

VICTORY_HEAP_HOOKS is now on (=0 turns it off). An executable whose
bytes differ at a site is left alone, as before. In game: about 131,500
slots a frame come from the journal, and no write escaped the hooks
(heap-writers.tsv stayed empty).

5. Relay and landing

  • Blocks a landing opens now rest open (VICTORY_LAND_REST_MS, 50; 0 as
    before) instead of being guarded again by the next refresh and reopened
    by the next landing, one protection change per block, twice a frame. As
    with VICTORY_GUARD_HOT, a resting block counts as written at every
    asking.
  • VICTORY_RELAY_COPY (the relay's fetches on the copy queue) is on by
    default, as the launchers already set it.

6. Card copies from title memory (VICTORY_CARD_FROM_TITLE, _WC, _HOLES)

  • A copy in the card's memory takes the title's changed bytes by a copy the
    card makes from the title's own memory, a heap placed over the page-pool
    sections, instead of a CPU copy and an upload.
  • _HOLES (on): buffers with pages the title has not mapped are taken too;
    the holes go up once as zeros, and a page mapped into a hole later hands
    the copy back to the CPU.
  • A log line names any big copy (16 MB or more) that goes back to the CPU,
    with the reason.

7. Wave64 diagnostics

  • The "shader translated" line now gives the form a console wave64 compute
    program took on a 32-lane host (wave64=: exact, folded, without skips,
    wave-wide branches, local waves idiom / APPROXIMATE, ...).
  • On this scene the dominant pass is 2561af9577c47289, up to ~50 ms of
    card time a frame. It is folded, and so is c06aa62112ffba4c.
  • VICTORY_WAVE_FOLDED_SKIP_HASH=<hash>,... (keyed in the shader cache)
    leaves named programs unfolded. Here that meant approximate forms and more
    dropped work, so it stays off.

8. Also in this branch (from the 29/11 port), all behind switches

VICTORY_MOUSE_AS_STICK (mouse as the right stick, README), VICTORY_MIMALLOC
(mimalloc allocator), VICTORY_GUARDS_LOCKFREE (atomic mirrors of the guards'
clean/held sets), VICTORY_TELL_FIRST, VICTORY_TITLE_FIRST,
VICTORY_CCX_HUDDLE (thread placement), VICTORY_LAND_BATCH,
VICTORY_UPLOAD_NO_WAIT, VICTORY_TEXTURE_SWEEP_BESIDE,
VICTORY_SWEEP_BUDGET_MS, VICTORY_EARLY_REFRESH (off: measured -0.9 %),
VICTORY_VIEWS_SHARDED, VICTORY_PC_WINDOWS_IN_PLACE, VICTORY_PORT_MAP
(kept off here: shared GPU memory ran out at 15.6 GB), VICTORY_SECTION_COMMIT,
VICTORY_WC_PARTS, VICTORY_WATCH_PIPELINES, VICTORY_DSTORAGE_CACHE,
VICTORY_AB helpers.

9. Second commit (2026-11-30)

Remapped-range queue (VICTORY_REMAP_SLACK, on; =0 as before)

RemapQueue::record (descriptor/host.rs, code that came with upstream PR
2607) keeps 32,768 entries of history. Full within the first minutes, every
record that did not merge took out, sorted and put back all the unread
entries, under the lock that the title's threads, the landing threads and
the placed-texture pass share. It now compacts once per slice.

  • Isolated bench, 1,700 records per read: 9 to 13 µs per record before,
    0.012 after, no gap over 6,000 reads.
  • In game: +4.2 % frames per second (A/B, see the end).

Lock-free sort of refreshes (VICTORY_LOCKFREE_NEW, on; =0 as before)

flush_all took the snapshot of the ranges asked for, then still called
nothing_new, which reads the journal again under its lock for each copy
(7,000 to 9,000 ranges a frame): the lock the landing threads take to write.
It now calls nothing_new_with with that snapshot. The lock-free variant
existed (upstream too), but nothing called it.

Landing

  • Shadow::landed no longer waits for a copy's lock while a refresh holds
    it: that refresh may be copying megabytes of the title's 174 MB frame
    memory. Busy, the block is left as written and the next refresh takes it,
    as before VICTORY_LAND_TAKEN (counted per frame, LANDED_BUSY).
  • Separate counters and timers: what our view notes and what lands at the
    title's address, reopened blocks, waits on the journal's lock, other views
    of the pages.

Off by default, not measured here

  • VICTORY_LIGHT_LOOP_LOCAL=1: 2561af9577c47289 and c06aa62112ffba4c as
    local waves before folding (upstream PR 3717; part of the shader cache key).
  • VICTORY_SEND_KEEP=1 (switchable with VICTORY_AB): with tight RAM, the
    send spares handed back since the last sweep stay (idea of upstream PR
    3411). A "send spares under memory pressure" line every 5 sweeps.
  • The parallel sort of refreshes without allocation (idea of upstream PR
    3705), under VICTORY_FRONT_SIFT, still off.

Measurement only

  • The 1 Hz sweep logs a line when it holds a submission 20 ms or more, with
    each part, the by-age listing and the dead render targets included.
  • The "refresh sorting per frame" line also outside the diagnostics build.
  • VICTORY_CARD_METER and VICTORY_CARD_SPANS can be switched in game by
    VICTORY_AB.
  • VICTORY_HOT_PROBE=1 (off, counts only): the share of the pages found
    written that lie in 64 KB blocks written almost every frame.

Builds

  • Cargo profile perf (fat LTO, one codegen unit) in target/perf;
    scripts/play-foxhound.ps1 -Build perf.
  • PGO: with --cfg victory_pgo_gen and -Cprofile-generate,
    crates/victory-gpu/src/pgo.rs writes the profile every minute and just
    before each exit (window closed and F1 menu, the title's exit,
    ExitProcess and TerminateProcess).
    • LLVM's runtime writes the profile only from atexit, and none of these
      exits runs it on Windows (rust-lang/rust#77553).
    • Repeated __llvm_profile_write_file calls add up the counts: %m
      merges each write into the file, and without it the runtime appends.
      Hence a file name of its own, written whole and then renamed.
    • Without the cfg nothing changes. -Build pgo-gen / pgo-use in
      play-foxhound.

10. Third commit (2026-11-30): time-bounded walk of the 1 Hz sweep

Walk over the by-age list (VICTORY_SWEEP_AGE_PART, off; =1 to use)

When the card is over its line, the 1 Hz sweep lists host copies by age
and walks the list until it has let go enough. VICTORY_SWEEP_BUDGET_MS
bounds the other walks, not this one. In the runs of 2026-11-30 the card was
over its line nearly all the time.

  • One run of 11 minutes, medians of the logged looks: the walk looked at
    88,000 copies a look. It let go 47 of them (7 MB of the 1,238 MB asked
    for) and took 60 ms of the submitting thread.
  • In the 30-minute run below, with the switch off, it looked at 119,000
    copies a look.

With VICTORY_SWEEP_AGE_PART=1 the walk stops after VICTORY_SWEEP_AGE_MS
(10 ms by default). The next look goes on after the last copy it looked at,
and goes back to the oldest after the end of the list. Off, the walk covers
the whole list as before. VICTORY_AB can flip it while the title runs.
The sweep's line now gives the walk's time, the copies it looked at, let go
and found held, and the bytes let go against those asked for.

In-game A/B over 30 minutes, VICTORY_AB=6,VICTORY_SWEEP_AGE_PART (release
build, 6 s phases), scenes of 3,000 draws and more:

  • +5.5 % frames per second: median of 93 pairs, faster in 69, sign test
    p < 0.0001, bootstrap 95 % interval +3.3 to +6.9 %.

  • At 6,000 draws and more: +4.8 % (51 pairs, p = 0.002, +2.0 to +6.5 %).

  • The card's time did not move (+0.5 %). The preparing thread's time fell
    6 %.

  • The effect was larger in the second half of the run, +7.6 % against
    +3.7 % in the first. The by-age list grows as a run goes on.

  • Per phase, medians:

    Off On
    Submission held by the sweep 93 ms 53 ms
    Walk 60 ms 9.7 ms
    Copies looked at, per look 119,000 16,600
    MB let go by age, per look 11.4 2.2
  • Hitches, from the per-second lines that fall inside a phase:

    • longest frame of each second: 164 → 127 ms at the median, 267 → 180 ms
      at p90;
    • frames over 100 ms: 9.7 % → 7.9 %.
  • The cost we looked for is a card that stays over its line longer, since
    copies are let go later. By arithmetic, a round of the list takes about 7
    looks (119,000 copies at 16,600 a look).

    • The "brought up to date although the card has no room for new ones"
      lines grew 10 % per phase (p = 0.027).
    • Per 100 frames they grew only 4 % (p = 0.55, interval -4 to +12 %). The
      rise per phase mostly comes from the extra frames.
  • It stays off by default in this branch; we play with it on.

What was measured, and what was not

  • The leak fix: measured, as above.
  • With items 2 to 6 together, unattended 3-minute runs (different scenes
    from run to run, so ±30 %):
    • preparing time 37-52 ms against 52-80 ms before;
    • CPU copies 16-25 ms and 50-70 MB a frame against 29-52 ms and 70-127 MB;
    • window copies 17.6 against 31.4 MB a frame;
    • CPU-copied ranges outside the sections 5.8 against 11.8 MB a frame;
    • landing guard time 31.5 against 41.8 ms a frame over all threads.
  • None of items 2 to 6 has been through an in-game A/B (VICTORY_AB) yet.
    VICTORY_SPAN_ENVELOPE can be A/B'd in game.
  • No image regression was seen in those runs. The only errors were the
    known "OTHER pages there now" lines, also present before the branch.
  • cargo build --release --locked -p victory --features ab passes, and so
    do the perf profile and the instrumented PGO build of the second commit;
    the unit tests were not run on this branch.
  • Second commit, in game: 21 minutes with VICTORY_AB=6,VICTORY_REMAP_SLACK
    (release build, 6 s phases), scenes of 3,000 draws and more.
    • The remapped-range queue fix gave +4.2 % frames per second (median of 77
      pairs, faster in 50, sign test p = 0.012; bootstrap 95 % interval +0.8 to
      +5.4 %). At 6,000 draws and more: +3.3 % (69 pairs, p = 0.053).
    • The CPU time of "telling placed textures" fell from 40.7 to 0.20 ms a
      frame over all threads. The preparing thread went from 92.9 to 89.6 ms;
      the card's time did not move.
  • The other changes of the second commit have not been through an in-game
    A/B. Between two runs (±30 %), the landing changes did not move the guard
    time (38.8 ms a frame over all threads).
  • Seen in that run, not addressed yet: the 1 Hz sweep holds a submission
    142 ms (median of the logged sweeps, those of 20 ms and more: 933 in 21
    minutes). The sweeps that list textures by age (697) hold 172 ms, the
    others (236) 31 ms. VICTORY_SWEEP_BUDGET_MS does not bound the walk over
    the by-age list. The third commit does (section 10).
  • PGO: the instrumented build wrote its profile 12 times in an 11-minute
    run (every minute, then when the window closed; about 7 MB and 7 to 9 ms
    a write). The build that uses it (-Cprofile-use, same commit) compiles;
    only the 7 functions the cfg changes lose their profile (rustc's
    hash-mismatch warnings).
  • The PGO and perf builds, one 21-minute run each with the same switches,
    against three release runs of the same morning. This compares runs, not
    an A/B. Medians over scenes of 3,000 draws and more:
    • list translation: 12.1 µs a call with PGO, 13.1 with perf, 12.3 to
      12.5 with release. The same measure reads 31.1 µs in the instrumented
      build, and moves from 9 to 13.5 µs with the scene within one run;
    • refresh copies: 0.43 ms a MB in all of them.
      No gain shows at this scale, so measurements stay on the release build.
      The place weighs far more than the build: where both runs ended, at about
      5,400 draws, they gave 16.7 and 15.7 frames per second (39 and 7 samples)
      against 10.2 and 10.3 elsewhere at the same draw count, with 3.4 and 6.1
      MB of window copies a frame against 23.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5558162971 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3650). Originally posted by [happyrain01](https://github.com/happyrain01) on 2026-11-30T02:58:08Z. --- This is a squashed change from a fork tuned on an RTX 3080 (10 GB, no Resizable BAR), Ryzen + 32 GB, Windows 26300, driver 617.42 then 621.40, Series S profile at 1440p. It sits on top of v2026.11.29.05 (41adb551). Everything new is behind a switch, and the switch names below give the way back to the previous behaviour. A second commit (section 9) adds the work of 2026-11-30, and a third (section 10) bounds the 1 Hz sweep's walk. ## 1. Commit leak: every run leaked ~4.7 GB of system commit (fixed) `OpenExistingHeapFromFileMapping` on a SEC_COMMIT section leaves the whole section's commit charge behind after the process ends, however it ends (killed, normal exit, heap released first). Proven with a standalone probe on driver 617.42. A heap opened with `OpenExistingHeapFromAddress` on a `MapViewOfFile` view of the same section leaves nothing. With `VICTORY_PORT_SECTIONS` the title's three page-pool sections (194 + 4,170 + 311 MB) were opened that way at every launch, so after a few dozen runs since boot the game died with "LLVM ERROR: out of memory", DirectStorage error 1450 or HLSL compile refusals, until a reboot. - `inplace::open`, `From::Section`: maps a view of the whole section, kept until the section goes (`SECTION_VIEWS`, `section_view_gone`, unmapped by `host::retire` after the flights in the air), and opens the heap on the view. If the view is refused (a view above 4 GiB gives E_INVALIDARG), the memory is copied: there is no fallback to the leaking call. - `VICTORY_SECTION_BY_VIEW=0` restores the old behaviour. - Checked in game: +1.2 GB of system commit after a run instead of ~+4.7; unattributed commit 3.1 GB in total; -0.06 GB on driver 621.40. - Upstream `main` still uses `OpenExistingHeapFromFileMapping` (`inplace.rs`, `From::Section`). ## 2. Refreshes on exact runs instead of min..max envelopes A copy's refreshes in front of a submission (`front_spans_into`, `written_spans`), the pending refreshes while steps are recorded (`Batch::add` / `flush_one` / `flush`) and the submission's one write-watch asking (`copy_spans`) all used one span per copy, from the lowest byte named to the highest. Two draws reading a few bytes at both ends of the title's 174 MB frame buffer made the journal and the write watch look at all of it: 31.7 GB named and 9.55 GB checked per frame, 9.50 GB of it unchanged (diagnostics build, `copystat`). - Runs are now kept apart, joined only where they overlap or lie closer than `VICTORY_SPAN_GAP_KB` (64). - What was refreshed ahead (`Batch::ahead`) keeps exact runs, so a gap is never taken as done. - `VICTORY_SPAN_ENVELOPE=1` (switchable with `VICTORY_AB`) restores the envelope. ## 3. One summary per list (`HostList::summary`) - Per copy, the summary keeps the runs read before the list first gives the copy to shaders, all runs read, and whether it does; plus the list's texture steps. - It is made once, and made again only if steps were added. - The submission's walks read the summary instead of the steps. - `VICTORY_LIST_SUMMARY=0` turns it off. ### "Up to date for certain" lists (`VICTORY_LIST_CERTAIN`, off by default since section 9) - When a list closes, on the thread that closes it and before it is marked done, `HostList::certify` checks two things: what the list reads in front of shader writes is up to date, and all of it lies in published (guarded, clean) blocks. If so, it notes a sequence number. - `watch::REOPENED` is a lock-free ring of every block that stops being published or gets bytes beside a guard. - At submission, a list none of whose blocks were reopened since needs no check at all. - The certification must happen before the list is marked done: done afterwards, the line could move the host list while its lock was held, and the moved copy stayed locked forever. That hang was found and fixed here. - Off by default since the second commit (`VICTORY_LIST_CERTAIN=1` turns it on): it spared 2 to 3 ranges a frame, for a check of about 216 lists at close on the threads that translate them (11 to 16 µs more per translated call). ## 4. Descriptor heap hooks on by default `VICTORY_HEAP_HOOKS` is now on (`=0` turns it off). An executable whose bytes differ at a site is left alone, as before. In game: about 131,500 slots a frame come from the journal, and no write escaped the hooks (`heap-writers.tsv` stayed empty). ## 5. Relay and landing - Blocks a landing opens now rest open (`VICTORY_LAND_REST_MS`, 50; `0` as before) instead of being guarded again by the next refresh and reopened by the next landing, one protection change per block, twice a frame. As with `VICTORY_GUARD_HOT`, a resting block counts as written at every asking. - `VICTORY_RELAY_COPY` (the relay's fetches on the copy queue) is on by default, as the launchers already set it. ## 6. Card copies from title memory (`VICTORY_CARD_FROM_TITLE`, `_WC`, `_HOLES`) - A copy in the card's memory takes the title's changed bytes by a copy the card makes from the title's own memory, a heap placed over the page-pool sections, instead of a CPU copy and an upload. - `_HOLES` (on): buffers with pages the title has not mapped are taken too; the holes go up once as zeros, and a page mapped into a hole later hands the copy back to the CPU. - A log line names any big copy (16 MB or more) that goes back to the CPU, with the reason. ## 7. Wave64 diagnostics - The "shader translated" line now gives the form a console wave64 compute program took on a 32-lane host (`wave64=`: exact, folded, without skips, wave-wide branches, local waves idiom / APPROXIMATE, ...). - On this scene the dominant pass is `2561af9577c47289`, up to ~50 ms of card time a frame. It is folded, and so is `c06aa62112ffba4c`. - `VICTORY_WAVE_FOLDED_SKIP_HASH=<hash>,...` (keyed in the shader cache) leaves named programs unfolded. Here that meant approximate forms and more dropped work, so it stays off. ## 8. Also in this branch (from the 29/11 port), all behind switches `VICTORY_MOUSE_AS_STICK` (mouse as the right stick, README), `VICTORY_MIMALLOC` (mimalloc allocator), `VICTORY_GUARDS_LOCKFREE` (atomic mirrors of the guards' clean/held sets), `VICTORY_TELL_FIRST`, `VICTORY_TITLE_FIRST`, `VICTORY_CCX_HUDDLE` (thread placement), `VICTORY_LAND_BATCH`, `VICTORY_UPLOAD_NO_WAIT`, `VICTORY_TEXTURE_SWEEP_BESIDE`, `VICTORY_SWEEP_BUDGET_MS`, `VICTORY_EARLY_REFRESH` (off: measured -0.9 %), `VICTORY_VIEWS_SHARDED`, `VICTORY_PC_WINDOWS_IN_PLACE`, `VICTORY_PORT_MAP` (kept off here: shared GPU memory ran out at 15.6 GB), `VICTORY_SECTION_COMMIT`, `VICTORY_WC_PARTS`, `VICTORY_WATCH_PIPELINES`, `VICTORY_DSTORAGE_CACHE`, `VICTORY_AB` helpers. ## 9. Second commit (2026-11-30) ### Remapped-range queue (`VICTORY_REMAP_SLACK`, on; `=0` as before) `RemapQueue::record` (`descriptor/host.rs`, code that came with upstream PR 2607) keeps 32,768 entries of history. Full within the first minutes, every record that did not merge took out, sorted and put back all the unread entries, under the lock that the title's threads, the landing threads and the placed-texture pass share. It now compacts once per slice. - Isolated bench, 1,700 records per read: 9 to 13 µs per record before, 0.012 after, no gap over 6,000 reads. - In game: +4.2 % frames per second (A/B, see the end). ### Lock-free sort of refreshes (`VICTORY_LOCKFREE_NEW`, on; `=0` as before) `flush_all` took the snapshot of the ranges asked for, then still called `nothing_new`, which reads the journal again under its lock for each copy (7,000 to 9,000 ranges a frame): the lock the landing threads take to write. It now calls `nothing_new_with` with that snapshot. The lock-free variant existed (upstream too), but nothing called it. ### Landing - `Shadow::landed` no longer waits for a copy's lock while a refresh holds it: that refresh may be copying megabytes of the title's 174 MB frame memory. Busy, the block is left as written and the next refresh takes it, as before `VICTORY_LAND_TAKEN` (counted per frame, `LANDED_BUSY`). - Separate counters and timers: what our view notes and what lands at the title's address, reopened blocks, waits on the journal's lock, other views of the pages. ### Off by default, not measured here - `VICTORY_LIGHT_LOOP_LOCAL=1`: `2561af9577c47289` and `c06aa62112ffba4c` as local waves before folding (upstream PR 3717; part of the shader cache key). - `VICTORY_SEND_KEEP=1` (switchable with `VICTORY_AB`): with tight RAM, the send spares handed back since the last sweep stay (idea of upstream PR 3411). A "send spares under memory pressure" line every 5 sweeps. - The parallel sort of refreshes without allocation (idea of upstream PR 3705), under `VICTORY_FRONT_SIFT`, still off. ### Measurement only - The 1 Hz sweep logs a line when it holds a submission 20 ms or more, with each part, the by-age listing and the dead render targets included. - The "refresh sorting per frame" line also outside the diagnostics build. - `VICTORY_CARD_METER` and `VICTORY_CARD_SPANS` can be switched in game by `VICTORY_AB`. - `VICTORY_HOT_PROBE=1` (off, counts only): the share of the pages found written that lie in 64 KB blocks written almost every frame. ### Builds - Cargo profile `perf` (fat LTO, one codegen unit) in `target/perf`; `scripts/play-foxhound.ps1 -Build perf`. - PGO: with `--cfg victory_pgo_gen` and `-Cprofile-generate`, `crates/victory-gpu/src/pgo.rs` writes the profile every minute and just before each exit (window closed and F1 menu, the title's `exit`, `ExitProcess` and `TerminateProcess`). - LLVM's runtime writes the profile only from `atexit`, and none of these exits runs it on Windows (rust-lang/rust#77553). - Repeated `__llvm_profile_write_file` calls add up the counts: `%m` merges each write into the file, and without it the runtime appends. Hence a file name of its own, written whole and then renamed. - Without the cfg nothing changes. `-Build pgo-gen` / `pgo-use` in play-foxhound. ## 10. Third commit (2026-11-30): time-bounded walk of the 1 Hz sweep ### Walk over the by-age list (`VICTORY_SWEEP_AGE_PART`, off; `=1` to use) When the card is over its line, the 1 Hz sweep lists host copies by age and walks the list until it has let go enough. `VICTORY_SWEEP_BUDGET_MS` bounds the other walks, not this one. In the runs of 2026-11-30 the card was over its line nearly all the time. - One run of 11 minutes, medians of the logged looks: the walk looked at 88,000 copies a look. It let go 47 of them (7 MB of the 1,238 MB asked for) and took 60 ms of the submitting thread. - In the 30-minute run below, with the switch off, it looked at 119,000 copies a look. With `VICTORY_SWEEP_AGE_PART=1` the walk stops after `VICTORY_SWEEP_AGE_MS` (10 ms by default). The next look goes on after the last copy it looked at, and goes back to the oldest after the end of the list. Off, the walk covers the whole list as before. `VICTORY_AB` can flip it while the title runs. The sweep's line now gives the walk's time, the copies it looked at, let go and found held, and the bytes let go against those asked for. In-game A/B over 30 minutes, `VICTORY_AB=6,VICTORY_SWEEP_AGE_PART` (release build, 6 s phases), scenes of 3,000 draws and more: - **+5.5 % frames per second**: median of 93 pairs, faster in 69, sign test p < 0.0001, bootstrap 95 % interval +3.3 to +6.9 %. - At 6,000 draws and more: +4.8 % (51 pairs, p = 0.002, +2.0 to +6.5 %). - The card's time did not move (+0.5 %). The preparing thread's time fell 6 %. - The effect was larger in the second half of the run, +7.6 % against +3.7 % in the first. The by-age list grows as a run goes on. - Per phase, medians: | | Off | On | |---|---|---| | Submission held by the sweep | 93 ms | 53 ms | | Walk | 60 ms | 9.7 ms | | Copies looked at, per look | 119,000 | 16,600 | | MB let go by age, per look | 11.4 | 2.2 | - Hitches, from the per-second lines that fall inside a phase: - longest frame of each second: 164 → 127 ms at the median, 267 → 180 ms at p90; - frames over 100 ms: 9.7 % → 7.9 %. - The cost we looked for is a card that stays over its line longer, since copies are let go later. By arithmetic, a round of the list takes about 7 looks (119,000 copies at 16,600 a look). - The "brought up to date although the card has no room for new ones" lines grew 10 % per phase (p = 0.027). - Per 100 frames they grew only 4 % (p = 0.55, interval -4 to +12 %). The rise per phase mostly comes from the extra frames. - It stays off by default in this branch; we play with it on. ## What was measured, and what was not - The leak fix: measured, as above. - With items 2 to 6 together, unattended 3-minute runs (different scenes from run to run, so ±30 %): - preparing time 37-52 ms against 52-80 ms before; - CPU copies 16-25 ms and 50-70 MB a frame against 29-52 ms and 70-127 MB; - window copies 17.6 against 31.4 MB a frame; - CPU-copied ranges outside the sections 5.8 against 11.8 MB a frame; - landing guard time 31.5 against 41.8 ms a frame over all threads. - None of items 2 to 6 has been through an in-game A/B (`VICTORY_AB`) yet. `VICTORY_SPAN_ENVELOPE` can be A/B'd in game. - No image regression was seen in those runs. The only errors were the known "OTHER pages there now" lines, also present before the branch. - `cargo build --release --locked -p victory --features ab` passes, and so do the `perf` profile and the instrumented PGO build of the second commit; the unit tests were not run on this branch. - Second commit, in game: 21 minutes with `VICTORY_AB=6,VICTORY_REMAP_SLACK` (release build, 6 s phases), scenes of 3,000 draws and more. - The remapped-range queue fix gave +4.2 % frames per second (median of 77 pairs, faster in 50, sign test p = 0.012; bootstrap 95 % interval +0.8 to +5.4 %). At 6,000 draws and more: +3.3 % (69 pairs, p = 0.053). - The CPU time of "telling placed textures" fell from 40.7 to 0.20 ms a frame over all threads. The preparing thread went from 92.9 to 89.6 ms; the card's time did not move. - The other changes of the second commit have not been through an in-game A/B. Between two runs (±30 %), the landing changes did not move the guard time (38.8 ms a frame over all threads). - Seen in that run, not addressed yet: the 1 Hz sweep holds a submission 142 ms (median of the logged sweeps, those of 20 ms and more: 933 in 21 minutes). The sweeps that list textures by age (697) hold 172 ms, the others (236) 31 ms. `VICTORY_SWEEP_BUDGET_MS` does not bound the walk over the by-age list. The third commit does (section 10). - PGO: the instrumented build wrote its profile 12 times in an 11-minute run (every minute, then when the window closed; about 7 MB and 7 to 9 ms a write). The build that uses it (`-Cprofile-use`, same commit) compiles; only the 7 functions the cfg changes lose their profile (rustc's hash-mismatch warnings). - The PGO and `perf` builds, one 21-minute run each with the same switches, against three release runs of the same morning. This compares runs, not an A/B. Medians over scenes of 3,000 draws and more: - list translation: 12.1 µs a call with PGO, 13.1 with `perf`, 12.3 to 12.5 with release. The same measure reads 31.1 µs in the instrumented build, and moves from 9 to 13.5 µs with the scene within one run; - refresh copies: 0.43 ms a MB in all of them. No gain shows at this scale, so measurements stay on the release build. The place weighs far more than the build: where both runs ended, at about 5,400 draws, they gave 16.7 and 15.7 frames per second (39 and 7 samples) against 10.2 and 10.3 elsewhere at the same draw count, with 3.4 and 6.1 MB of window copies a frame against 23. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
POMXARK commented 2026-11-30 10:39:54 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by POMXARK on 2026-11-30T10:39:54Z.


Hi @happyrain01 — since #3650 is already rebased onto v2026.11.29.05 (41adb55) and targets the synchronisation core, sharing two orthogonal git am-ready patches for 41adb55 in #3556 (https://github.com/trustno1-coder/VIctory-NVIDIA/discussions/3556#discussioncomment-20023964):

  1. xmem.rs (VICTORY_LOW_PRIVATE_WATCH): backs the un-aliased 185 MiB 32-bit graphics reservation with MEM_PRIVATE | MEM_WRITE_WATCH instead of SEC_RESERVE MEM_MAPPED (-86.6% VirtualProtect, -71.3% VEH faults, -43.7% GUARDS wait, 4 KiB GetWriteWatch instead of 64 KiB block-fault copies; 47/47 xmem tests pass on 41adb55).
  2. watch.rs (VICTORY_WIDE_WATCH): parallelizes ask_ahead / ask_once GetWriteWatch across disjoint reservations via wide_each_scoped.

I'm not opening separate PRs — feel free to pick up or adapt either patch if useful alongside #3650.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7275909387 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3650#issuecomment-7275909387). Originally posted by [POMXARK](https://github.com/POMXARK) on 2026-11-30T10:39:54Z. --- Hi @happyrain01 — since #3650 is already rebased onto `v2026.11.29.05` (`41adb55`) and targets the synchronisation core, sharing two orthogonal `git am`-ready patches for `41adb55` in #3556 (https://github.com/trustno1-coder/VIctory-NVIDIA/discussions/3556#discussioncomment-20023964): 1. **`xmem.rs` (`VICTORY_LOW_PRIVATE_WATCH`):** backs the un-aliased `185 MiB` 32-bit graphics reservation with `MEM_PRIVATE | MEM_WRITE_WATCH` instead of `SEC_RESERVE` `MEM_MAPPED` (`-86.6%` `VirtualProtect`, `-71.3%` VEH faults, `-43.7%` `GUARDS` wait, 4 KiB `GetWriteWatch` instead of 64 KiB block-fault copies; `47/47` `xmem` tests pass on `41adb55`). 2. **`watch.rs` (`VICTORY_WIDE_WATCH`):** parallelizes `ask_ahead` / `ask_once` `GetWriteWatch` across disjoint reservations via `wide_each_scoped`. I'm not opening separate PRs — feel free to pick up or adapt either patch if useful alongside #3650.
mstrmoos commented 2026-11-30 20:32:44 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by mstrmoos on 2026-11-30T20:32:44Z.


On section 4 (heap hooks on by default), one data point from a CPU-bound machine.

The machine was an RTX 5080 16 GB with a Ryzen 7 9800X3D on Windows 11: Series X, 1440p, DLSS Balanced, frame generation off, same save, 90 s bench route. The build was a branch of main from 2026-11-29 plus other open PRs, without this PR. Only VICTORY_HEAP_HOOKS=1 was changed between the two runs.

per frame hooks off VICTORY_HEAP_HOOKS=1
frame median 32.9 ms 34.1 ms
submitting thread, in its submissions 24.7 ms 26.9 ms
of it, refreshes 9.1 ms 10.4 ms
changing protections (all threads) 12.0 ms 4.8 ms
waiting for the guards (all threads) 5.2 ms 6.3 ms
blocks made read-only 362 236
hook journal 160,651 slots taken, 10,644 title copies into the heap, 2,870 blocks told to the watch

The hooks do what they promise for protection work: it falls by more than half. But the slot journal and the per-block telling of the watch cost the submitting thread more than that saves, so the frame got slower here.

This is one pair of runs, and run-to-run noise on this route is about ±0.5–1 ms, so treat the frame median as "not faster" rather than a precise loss. The protection and journal counts are from the layer's own per-frame lines and were steady across the run.

My guess is that telling the watch per range instead of per block, or batching the journal, would turn this into a gain. I haven't tried either. I can rerun with whatever switches you suggest.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7291093715 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3650#issuecomment-7291093715). Originally posted by [mstrmoos](https://github.com/mstrmoos) on 2026-11-30T20:32:44Z. --- On section 4 (heap hooks on by default), one data point from a CPU-bound machine. The machine was an RTX 5080 16 GB with a Ryzen 7 9800X3D on Windows 11: Series X, 1440p, DLSS Balanced, frame generation off, same save, 90 s bench route. The build was a branch of main from 2026-11-29 plus other open PRs, without this PR. Only `VICTORY_HEAP_HOOKS=1` was changed between the two runs. | per frame | hooks off | `VICTORY_HEAP_HOOKS=1` | |---|---|---| | frame median | 32.9 ms | 34.1 ms | | submitting thread, in its submissions | 24.7 ms | 26.9 ms | | of it, refreshes | 9.1 ms | 10.4 ms | | changing protections (all threads) | 12.0 ms | 4.8 ms | | waiting for the guards (all threads) | 5.2 ms | 6.3 ms | | blocks made read-only | 362 | 236 | | hook journal | | 160,651 slots taken, 10,644 title copies into the heap, 2,870 blocks told to the watch | The hooks do what they promise for protection work: it falls by more than half. But the slot journal and the per-block telling of the watch cost the submitting thread more than that saves, so the frame got slower here. This is one pair of runs, and run-to-run noise on this route is about ±0.5–1 ms, so treat the frame median as "not faster" rather than a precise loss. The protection and journal counts are from the layer's own per-frame lines and were steady across the run. My guess is that telling the watch per range instead of per block, or batching the journal, would turn this into a gain. I haven't tried either. I can rerun with whatever switches you suggest.
happyrain01 commented 2026-11-30 21:31:04 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by happyrain01 on 2026-11-30T21:31:04Z.


Thanks @POMXARK, both patches are ported onto our branch (same base as #3650) and measured in game. Setup: RTX 3080 10 GB, a fixed outdoor scene of about 2,600 draws at about 20 fps, the card over its DXGI budget most of the time.

0002 (VICTORY_WIDE_WATCH)

  • Made switchable in game (toggled! read, VICTORY_AB flips it every 6 s at the same spot).
  • Result: 122 pairs of phases, -0.6 % fps. Faster in 39 % of pairs, sign test p = 0.014, bootstrap 95 % interval -1.1 to 0.0 %.
  • So no gain here. Our refreshes already run on 5 helper threads, and the extra wake-ups seem to cost more than the parallel asking saves.
  • We keep it off.

0001 (VICTORY_LOW_PRIVATE_WATCH)

  • A review of the patch found four ways it changes behaviour when the title touches that heap after setting it up:
    • unmapping and mapping a page there gives fresh zeros instead of the section's bytes;
    • scatter and alias views cannot be made over private memory;
    • freeing one piece of a split reservation frees the whole heap;
    • a freed page number still points into the heap.
  • So we counted what the title does with the heap. Over 25 minutes in the scene above: 5 mappings and 4 frees at startup, then nothing.
  • It is read once at startup, so it cannot be flipped in game. We measured it in three 8-minute runs (off / on / off), with no player.
    • The first run got another camera spot, so the comparison below is between the second and the third. Both looked at the same street, at about 4,800 to 5,100 draws.
    • With the switch on, the heap is 185 MB of private write-watched pages in 5 ranges. The run had no crash or close failure, and the picture looked right.
  • Frame rate, from the game log (medians):
    • 1 to 3 minutes in: 16.8 fps on, 16.4 fps off;
    • 4 to 8 minutes in: 16.0 fps on, 16.1 fps off.
    • Between two runs the noise is much larger than that here, so we see no gain.
  • Where the submitting thread's time goes, from a 60 s sampling profile of each run (on / off):
    • waiting for the GUARDS lock: 8.8 % / 8.6 %;
    • NtGetWriteWatch: 15.1 % / 8.0 %;
    • NtProtectVirtualMemory: 1.6 % / 1.8 %.
  • The game log agrees: the write watch takes 14.4 to 14.8 ms a frame on, against 10.1 to 10.2 off. Copies into the card's memory take 3.1 to 3.7 ms on, against 5.2 to 5.3 off.
  • So on this machine the time moves from the guards to asking the kernel which pages were written; the lock wait does not go down. We keep it off. We have not found why the lock wait stays the same here.

Both are measured with the same tools as the numbers in the PR description.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7292518282 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3650#issuecomment-7292518282). Originally posted by [happyrain01](https://github.com/happyrain01) on 2026-11-30T21:31:04Z. --- Thanks @POMXARK, both patches are ported onto our branch (same base as #3650) and measured in game. Setup: RTX 3080 10 GB, a fixed outdoor scene of about 2,600 draws at about 20 fps, the card over its DXGI budget most of the time. **0002 (`VICTORY_WIDE_WATCH`)** - Made switchable in game (`toggled!` read, `VICTORY_AB` flips it every 6 s at the same spot). - Result: 122 pairs of phases, **-0.6 % fps**. Faster in 39 % of pairs, sign test p = 0.014, bootstrap 95 % interval -1.1 to 0.0 %. - So no gain here. Our refreshes already run on 5 helper threads, and the extra wake-ups seem to cost more than the parallel asking saves. - We keep it off. **0001 (`VICTORY_LOW_PRIVATE_WATCH`)** - A review of the patch found four ways it changes behaviour when the title touches that heap after setting it up: - unmapping and mapping a page there gives fresh zeros instead of the section's bytes; - scatter and alias views cannot be made over private memory; - freeing one piece of a split reservation frees the whole heap; - a freed page number still points into the heap. - So we counted what the title does with the heap. Over 25 minutes in the scene above: 5 mappings and 4 frees at startup, then nothing. - It is read once at startup, so it cannot be flipped in game. We measured it in three 8-minute runs (off / on / off), with no player. - The first run got another camera spot, so the comparison below is between the second and the third. Both looked at the same street, at about 4,800 to 5,100 draws. - With the switch on, the heap is 185 MB of private write-watched pages in 5 ranges. The run had no crash or close failure, and the picture looked right. - Frame rate, from the game log (medians): - 1 to 3 minutes in: 16.8 fps on, 16.4 fps off; - 4 to 8 minutes in: 16.0 fps on, 16.1 fps off. - Between two runs the noise is much larger than that here, so we see no gain. - Where the submitting thread's time goes, from a 60 s sampling profile of each run (on / off): - waiting for the `GUARDS` lock: 8.8 % / 8.6 %; - `NtGetWriteWatch`: 15.1 % / 8.0 %; - `NtProtectVirtualMemory`: 1.6 % / 1.8 %. - The game log agrees: the write watch takes 14.4 to 14.8 ms a frame on, against 10.1 to 10.2 off. Copies into the card's memory take 3.1 to 3.7 ms on, against 5.2 to 5.3 off. - So on this machine the time moves from the guards to asking the kernel which pages were written; the lock wait does not go down. We keep it off. We have not found why the lock wait stays the same here. Both are measured with the same tools as the numbers in the PR description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
happyrain01 commented 2026-11-30 21:36:20 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by happyrain01 on 2026-11-30T21:36:20Z.


@mstrmoos thanks, that pair settles section 4 for us. We had checked that no heap write escaped the hooks, but we never measured hooks on against hooks off. We won't ask for VICTORY_HEAP_HOOKS=1 by default.

I'm turning this PR into a draft and retiring it as a bundle. Checked against main at e1251c3 (v2026.11.30.03):

  • Texture sweep (section 10) and remapped-range queue (section 9, VICTORY_REMAP_SLACK). These are the two parts we measured in game (+5.5 % and +4.2 % frames per second). Main now has its own fix for both: the sweep lists at most 8,192 textures a look and stops after 4 ms, and RemapQueue::record backs off after a compaction that does not shrink the queue.
  • Commit leak (section 1). It only happens with VICTORY_PORT_SECTIONS, which this branch adds and main does not have. On main, OpenExistingHeapFromFileMapping is only called by the VICTORY_INPLACE_PROBE probe, which is off by default. So it is not a fix for main, and our line "upstream main still uses OpenExistingHeapFromFileMapping" was misleading.
  • Sections 2 to 6. None went through an in-game A/B. The two outside measurements go against two of them: section 4 (above), and a fork's A/B of section 2, slower there (49.9 against 47.8 ms a frame, github.com/bigboss22869/VIctory-RTX5070Ti@d90720c493).

What we measured in game and main does not have is thread placement:

  • VICTORY_TITLE_FIRST (our helper threads below the title's priority): +3.4 %.
  • VICTORY_CCX_HUDDLE (the submitting thread and its helpers on one CCX of a Ryzen 9 3900X): +3.4 %.

We will measure both again on main, and open small opt-in PRs only if the gain holds.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7292639492 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3650#issuecomment-7292639492). Originally posted by [happyrain01](https://github.com/happyrain01) on 2026-11-30T21:36:20Z. --- @mstrmoos thanks, that pair settles section 4 for us. We had checked that no heap write escaped the hooks, but we never measured hooks on against hooks off. We won't ask for `VICTORY_HEAP_HOOKS=1` by default. I'm turning this PR into a draft and retiring it as a bundle. Checked against main at `e1251c3` (v2026.11.30.03): - **Texture sweep (section 10) and remapped-range queue (section 9, `VICTORY_REMAP_SLACK`).** These are the two parts we measured in game (+5.5 % and +4.2 % frames per second). Main now has its own fix for both: the sweep lists at most 8,192 textures a look and stops after 4 ms, and `RemapQueue::record` backs off after a compaction that does not shrink the queue. - **Commit leak (section 1).** It only happens with `VICTORY_PORT_SECTIONS`, which this branch adds and main does not have. On main, `OpenExistingHeapFromFileMapping` is only called by the `VICTORY_INPLACE_PROBE` probe, which is off by default. So it is not a fix for main, and our line "upstream main still uses `OpenExistingHeapFromFileMapping`" was misleading. - **Sections 2 to 6.** None went through an in-game A/B. The two outside measurements go against two of them: section 4 (above), and a fork's A/B of section 2, slower there (49.9 against 47.8 ms a frame, https://github.com/bigboss22869/VIctory-RTX5070Ti/commit/d90720c4936a5de32b545c07b481b6df4de0137b). What we measured in game and main does not have is thread placement: - `VICTORY_TITLE_FIRST` (our helper threads below the title's priority): +3.4 %. - `VICTORY_CCX_HUDDLE` (the submitting thread and its helpers on one CCX of a Ryzen 9 3900X): +3.4 %. We will measure both again on main, and open small opt-in PRs only if the gain holds. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
trustno1-coder commented 2026-12-01 18:50:04 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:50:04Z.


Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321637274 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3650#issuecomment-7321637274). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:50:04Z. --- Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

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