Synchronisation core: commit leak fix, exact refresh runs, list summaries, heap hooks on, and a night of NVIDIA/Ampere work #3650
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!3650
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3650"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@happyrain01 on GitHub · 2026-11-30 02:58 UTC · original
happyrain01:perf-sync-core→main· +6437 −380 · 51 files · 3 commits · closed without mergingThis 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)
OpenExistingHeapFromFileMappingon a SEC_COMMIT section leaves the wholesection'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
OpenExistingHeapFromAddresson aMapViewOfFileview of the same section leaves nothing. WithVICTORY_PORT_SECTIONSthe 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, keptuntil the section goes (
SECTION_VIEWS,section_view_gone, unmapped byhost::retireafter the flights in the air), and opens the heap on theview. 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=0restores the old behaviour.unattributed commit 3.1 GB in total; -0.06 GB on driver 621.40.
mainstill usesOpenExistingHeapFromFileMapping(
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-watchasking (
copy_spans) all used one span per copy, from the lowest byte namedto 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).VICTORY_SPAN_GAP_KB(64).Batch::ahead) keeps exact runs, so a gap isnever taken as done.
VICTORY_SPAN_ENVELOPE=1(switchable withVICTORY_AB) restores theenvelope.
3. One summary per list (
HostList::summary)copy to shaders, all runs read, and whether it does; plus the list's
texture steps.
VICTORY_LIST_SUMMARY=0turns it off."Up to date for certain" lists (
VICTORY_LIST_CERTAIN, off by default since section 9)done,
HostList::certifychecks two things: what the list reads in frontof shader writes is up to date, and all of it lies in published (guarded,
clean) blocks. If so, it notes a sequence number.
watch::REOPENEDis a lock-free ring of every block that stops beingpublished or gets bytes beside a guard.
check at all.
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.
VICTORY_LIST_CERTAIN=1turns iton): 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_HOOKSis now on (=0turns it off). An executable whosebytes 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.tsvstayed empty).5. Relay and landing
VICTORY_LAND_REST_MS, 50;0asbefore) 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 everyasking.
VICTORY_RELAY_COPY(the relay's fetches on the copy queue) is on bydefault, as the launchers already set it.
6. Card copies from title memory (
VICTORY_CARD_FROM_TITLE,_WC,_HOLES)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.
with the reason.
7. Wave64 diagnostics
program took on a 32-lane host (
wave64=: exact, folded, without skips,wave-wide branches, local waves idiom / APPROXIMATE, ...).
2561af9577c47289, up to ~50 ms ofcard 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_ABhelpers.9. Second commit (2026-11-30)
Remapped-range queue (
VICTORY_REMAP_SLACK, on;=0as before)RemapQueue::record(descriptor/host.rs, code that came with upstream PR2607) 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.
0.012 after, no gap over 6,000 reads.
Lock-free sort of refreshes (
VICTORY_LOCKFREE_NEW, on;=0as before)flush_alltook the snapshot of the ranges asked for, then still callednothing_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_withwith that snapshot. The lock-free variantexisted (upstream too), but nothing called it.
Landing
Shadow::landedno longer waits for a copy's lock while a refresh holdsit: 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).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:2561af9577c47289andc06aa62112ffba4caslocal waves before folding (upstream PR 3717; part of the shader cache key).
VICTORY_SEND_KEEP=1(switchable withVICTORY_AB): with tight RAM, thesend spares handed back since the last sweep stay (idea of upstream PR
3411). A "send spares under memory pressure" line every 5 sweeps.
3705), under
VICTORY_FRONT_SIFT, still off.Measurement only
each part, the by-age listing and the dead render targets included.
VICTORY_CARD_METERandVICTORY_CARD_SPANScan be switched in game byVICTORY_AB.VICTORY_HOT_PROBE=1(off, counts only): the share of the pages foundwritten that lie in 64 KB blocks written almost every frame.
Builds
perf(fat LTO, one codegen unit) intarget/perf;scripts/play-foxhound.ps1 -Build perf.--cfg victory_pgo_genand-Cprofile-generate,crates/victory-gpu/src/pgo.rswrites the profile every minute and justbefore each exit (window closed and F1 menu, the title's
exit,ExitProcessandTerminateProcess).atexit, and none of theseexits runs it on Windows (rust-lang/rust#77553).
__llvm_profile_write_filecalls add up the counts:%mmerges each write into the file, and without it the runtime appends.
Hence a file name of its own, written whole and then renamed.
-Build pgo-gen/pgo-useinplay-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;=1to 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_MSbounds the other walks, not this one. In the runs of 2026-11-30 the card was
over its line nearly all the time.
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.
copies a look.
With
VICTORY_SWEEP_AGE_PART=1the walk stops afterVICTORY_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_ABcan 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(releasebuild, 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:
Hitches, from the per-second lines that fall inside a phase:
at p90;
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).
lines grew 10 % per phase (p = 0.027).
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
from run to run, so ±30 %):
VICTORY_AB) yet.VICTORY_SPAN_ENVELOPEcan be A/B'd in game.known "OTHER pages there now" lines, also present before the branch.
cargo build --release --locked -p victory --features abpasses, and sodo the
perfprofile and the instrumented PGO build of the second commit;the unit tests were not run on this branch.
VICTORY_AB=6,VICTORY_REMAP_SLACK(release build, 6 s phases), scenes of 3,000 draws and more.
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).
frame over all threads. The preparing thread went from 92.9 to 89.6 ms;
the card's time did not move.
A/B. Between two runs (±30 %), the landing changes did not move the guard
time (38.8 ms a frame over all threads).
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_MSdoes not bound the walk overthe by-age list. The third commit does (section 10).
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).
perfbuilds, 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:
perf, 12.3 to12.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;
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
@POMXARK on GitHub · 2026-11-30 10:39 UTC · original
Hi @happyrain01 — since #3650 is already rebased onto
v2026.11.29.05(41adb55) and targets the synchronisation core, sharing two orthogonalgit am-ready patches for41adb55in #3556 (https://github.com/trustno1-coder/VIctory-NVIDIA/discussions/3556#discussioncomment-20023964):xmem.rs(VICTORY_LOW_PRIVATE_WATCH): backs the un-aliased185 MiB32-bit graphics reservation withMEM_PRIVATE | MEM_WRITE_WATCHinstead ofSEC_RESERVEMEM_MAPPED(-86.6%VirtualProtect,-71.3%VEH faults,-43.7%GUARDSwait, 4 KiBGetWriteWatchinstead of 64 KiB block-fault copies;47/47xmemtests pass on41adb55).watch.rs(VICTORY_WIDE_WATCH): parallelizesask_ahead/ask_onceGetWriteWatchacross disjoint reservations viawide_each_scoped.I'm not opening separate PRs — feel free to pick up or adapt either patch if useful alongside #3650.
@mstrmoos on GitHub · 2026-11-30 20:32 UTC · original
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=1was changed between the two runs.VICTORY_HEAP_HOOKS=1The 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 on GitHub · 2026-11-30 21:31 UTC · original
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)toggled!read,VICTORY_ABflips it every 6 s at the same spot).0001 (
VICTORY_LOW_PRIVATE_WATCH)GUARDSlock: 8.8 % / 8.6 %;NtGetWriteWatch: 15.1 % / 8.0 %;NtProtectVirtualMemory: 1.6 % / 1.8 %.Both are measured with the same tools as the numbers in the PR description.
🤖 Generated with Claude Code
@happyrain01 on GitHub · 2026-11-30 21:36 UTC · original
@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=1by default.I'm turning this PR into a draft and retiring it as a bundle. Checked against main at
e1251c3(v2026.11.30.03):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, andRemapQueue::recordbacks off after a compaction that does not shrink the queue.VICTORY_PORT_SECTIONS, which this branch adds and main does not have. On main,OpenExistingHeapFromFileMappingis only called by theVICTORY_INPLACE_PROBEprobe, which is off by default. So it is not a fix for main, and our line "upstream main still usesOpenExistingHeapFromFileMapping" was misleading.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
@trustno1-coder on GitHub · 2026-12-01 18:50 UTC · original
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