Fix the world-entry crash the table-slot skip causes; coalesce refreshes; opt-in readable-range copies #827
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!827
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-827"
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?
@traidy2222 on GitHub · 2026-11-25 09:21 UTC · original
traidy2222:tabled-window-copy-coalesce→main· +540 −20 · 7 files · 11 commits · draftWhat this is
Three small, behaviour-preserving changes to the processor side of the frame,
written while running the title on a 16 GB / RTX 3080 box, plus the one thing
they found: the descriptor-sync skip window crashes the title at world entry,
and the window is the cause, not the skipping.
Measured on: i7-12700F, 16 GB DDR4, RTX 3080 10 GB, Windows 11, Series X
profile, build
9376fd6+ these changes. Same scene (frames with >= 1500draws), medians:
a26859f+ the README's speed switches9376fd6+ switches +VICTORY_HEAP_SYNC_TABLES=1COPY_FAST)Loading into the world: 232 s (cold shader cache) -> 84 s (warm cache + these).
1. The world-entry crash:
tabled_lately's 240-frame windowThree runs of
9376fd6with no switches died at the same place, reproducibly:HostHeap::tabled_latelyleaves a slot to its draws if it was a table's withinTABLED_FRAMES(240) frames, and does not ask whether a draw read it througha table. A slot the title stops reading through a table keeps being skipped for
eight seconds, so a draw that now reads it directly gets a record no pass made.
VICTORY_TABLED_SKIP_FRAMES=<n>asks the stricter question: skip only if adraw read the slot through a table within
nframes (the read bit isalready in
tabled). With=2: two clean runs through the world, noexception; with the shipped window: three crashes. Unset keeps today's
behaviour exactly.
Note for the maintainer: the OOM report of the crash carries
memory.load_percent94-97-99, so a slower run survives by reaching the walllater; the window is still the thing that decides whether a skipped slot is
ever made.
2. Refreshes of one title buffer, coalesced
Batch::flushhandsShadow::update25,000-90,000 ranges a frame of 11-21 KBeach (the new
copies moved per frameline). Ranges of the same copy within64 KB now become one call; the bytes between them are title memory as well, and
Shadow::updatestill cuts the merged range around what shaders write.Result: 60-90k calls -> 24-50k for the same bytes.
3.
VICTORY_COPY_FAST: amemcpywhen the range is readablecopy_mappedreads title memory withReadProcessMemory(600 MB/s here).With the flag, a range the kernel reports readable is moved with the CPU:
700-1,300 MB/s measured. Off by default: the title can unmap a page between
the question and the copy (the page pool's pages move when streaming replaces
them) and a fault there kills the process. It needs a guarded copy (vectored
handler) before it can default on; until then it is an experiment, and it is
not needed by the crash fix.
4.
watch::forgot, and one more thing it showedThe layer's own write-back into title memory sets the kernel's write-watch
dirty bits, so the next refresh reports them as the title's writes and copies
the same bytes up again.
forgotresets them after the layer's write.Measured: title-memory copies through this path are only 0.5-2.5 MB a frame,
so this is small; the 460-1,530 MB a frame of copies are in the texture queue.
Not in this PR, and the biggest number left
The pass over the heap still mirrors 34,483 records a frame at ~25 us each
(~250-800 ms). Skipping more of them is what makes it 3 ms and kills the
title; the window above only makes the skipping safe. Making a mirror cheap
(batch the view creation, cache by resource+description) is the next step, and
I have not written it.
The texture queue is the other: 18,333 slots due a frame against a 2 GB card
budget, uploaded, evicted, due again. Capping the stage
(
VICTORY_TEXTURE_STAGE_MB=64) took a 1.5 s frame to 0.44-0.48 s; ordering thequeue by last use is the fix I would write next.
cargo test -p victory-gpu --lib: 142 passed, 2 failed(
pipeline::host::tests::a_mesh_pipeline_loads_from_the_library,...::depth_bounds_pipeline_loads_and_filters_draws), both asserting thepipeline library is loaded from rather than compiled again - they touch nothing
in this diff and fail the same way here on
9376fd6without it.@Lancito01 on GitHub · 2026-11-25 09:26 UTC · original · edited 2026-11-25 09:33 UTC
One data point on the
+0x23cf683crash from my own test runs (same card: RTX 3080 10 GB, 32 GB RAM, Windows 11), in case it helps separate the window from memory pressure. One run, so a lead, not a result.I got the same exception at the same offset on a tree that has no
tabled_latelywindow at all: fork310c6eb+ #571, the #115 line, #51, #606, #112, #25, #644, #294, #646, #186, #648, #691, #544, #640, #489, #683, #220, launched withVICTORY_BVH_BUILDER=1 VICTORY_BVH_QUARANTINE=1.Context of that run:
So on this machine
+0x23cf683also appears with no skip window, at the point the system runs out of commit, which fits your note aboutmemory.load_percent94-99. It looks like the title's own reaction to a failed allocation, which the window can bring on, but not something only the window causes. That doesn't argue againstVICTORY_TABLED_SKIP_FRAMES=2: your 3-crashes vs 2-clean comparison is on the same tree. It may just be worth logging commit headroom next to these crash reports.@MamaLeVrai on GitHub · 2026-11-25 09:54 UTC · original
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head
f681125intomain9376fd6in a throwaway tree (no conflict).cargo clippy --workspace --all-targets --locked -- -D warningsfails, with the same two errors asmainitself on this machine (function placed_filler_twins is never used,field depth_written is never read,victory-gpu): this PR adds none and removes none.cargo test --workspace --locked: 540 passed, 0 failed, 10 ignored, two runs (mainalone: 540 passed). The title was not run, so this says nothing about in-game effect. No game data.AI-assisted (Claude Code); no game data.
@sagouindupm on GitHub · 2026-11-25 11:33 UTC · original
Tested this PR (
f681125) together with #824 (9dae0a7) on Windows 11 Pro (Intel i5-12400F, 32 GB RAM, NVIDIA GeForce RTX 3050 8 GB) under--console series-s, compared against the same local base (9376fd6+ #188 + #518 + #610 +VICTORY_LITE=1280x5120, 20 window-title samples taken every ~10 s starting at 100 s):bench_k0): entered 3D draws (926 draws) at sample 10/20, peak frame time 2,357.9 ms/frame (sample 17/20), ended at 234.3 ms/frame (2711 draws, sample 20/20), interior walls intact.bench_k1): entered 3D draws (965 draws) at sample 2/20, max frame-time spike across all 20 samples dropped to 628.3 ms/frame (zero multi-second spikes), and the last 5 samples stabilized at 211.9–225.8 ms/frame (mean 218.5 ms/frame, ~4.6 FPS; log peak 4.9 fps / 205.2 ms/frame), interior walls intact.(Note: #827 and #824 were measured together in the same build, so the speedup and spike reduction reflect their combined effect on 8 GB Windows hardware.)
AI-assisted: benchmark analysis and write-up prepared with AI assistance.
@npanu420 on GitHub · 2026-11-25 12:41 UTC · original
Data point on
VICTORY_COPY_FAST=1, from an RTX 3070 8 GB + i9-9900X (Windows 11, Series S profile). This PR and #154 were merged onto ExoCalibra'sd034ac1(fork mainf85101b), plus #809, #95 and #108.The race your doc comment describes does happen in practice. In 1 of 3 launches with
COPY_FAST=1, about 160 s in, during the first world frames:unhandled exception 0xc0000005 at VCRUNTIME140.dll (memcpy) (read 0xa3b827240: reserved, never committed), length0x378dc0, insidecopy_mapped's fast branch.The page passed the
committed(src, len)check and was gone at the copy. There were no crashes in 7 launches without it.Speed when it survives, median over world frames 60-400 (same build, single runs):
DIRECT_COPYon)COPY_FAST=1So the fast path is worth about 50 ms here, but it needs fault-tolerant reads (or a guard against pages moving) before it can be on by default. Merging this PR alone (fast path off) already took our copies from 76 to about 32 ms a frame. Thanks!
(AI-assisted, Claude Code. No game data.)
@ofc0urse on GitHub · 2026-11-25 12:50 UTC · original
An A/B where this PR changed what reaches the screen, in case it helps narrow it down.
RTX 4060 Ti 8 GB (driver 621.24), i5-14400F, 32 GB, Windows 11, diagnostics build,
--console series-s,VICTORY_TEXTURE_DROP_MIPS=1,VICTORY_TEXTURE_NO_WAIT=1, same automated walk into the first room, 13 minutes each. Both trees aref85101b+ #610 + #802 + #798 + #834 + #823; the only difference is this PR's commits (5ff1ffb..0e2d5ab, clean cherry-picks).The card is well under budget in both, so room is not what holds the uploads back. In the captures with this PR the yard through the cell window has untextured ground, tables and chairs, and the cell stays dark; without it they are textured. On Series X the same pair gave 20,232 after 17 minutes with it against 48,803 after 10 minutes without.
I did not bisect inside the branch. My guess is
44694f4(each view made once and copied into the slots that show it again) or the skip window, since both change which slots the by-index texture pass sees, but that is a guess.🤖 Generated with Claude Code
@npanu420 on GitHub · 2026-11-25 14:01 UTC · original
On the texture question above, a counter-point from a different tree. RTX 3070 8 GB, Series S,
TEXTURE_NO_WAIT=1, withoutTEXTURE_DROP_MIPS.The tree is ExoCalibra's
d034ac1+ #809, #95, #108 + a port of #523 + fork main0b0074e, with this PR and #154 merged or not. Six-minute runs, "textures picked by index" at the end:With this PR, the yard through the cell window is textured in our captures (ground, tables, chairs) and so is the window glass. So on this tree it does not starve the by-index pass.
Our tree has neither #610 nor
TEXTURE_DROP_MIPS, and that may be the difference in yours: #610 changes which mips a slot's texture holds, and the view reuse in44694f4keys on the view.(AI-assisted, Claude Code. No game data.)
@LeonardoS11 on GitHub · 2026-11-25 17:11 UTC · original
Two things from carrying this PR on an RTX 3080 Ti (12 GB, 64 GB RAM), in case they are useful.
What
VICTORY_TABLED_SKIP_FRAMEScosts here. Series S profile, the first room standing still, one build (f85101bwith this PR and others), 300 s a run:VICTORY_TABLED_SKIP_FRAMESWith the switch the per-draw tables the title rewrites every frame are mirrored again and become marks for the buffer pass, so that pass more than doubles: about 33 ms a frame. It is the same with a pass that looks only at marked slots (#467). I am not arguing against the switch — only giving the price on a machine where the crash is rare.
How often the crash shows without it. On 64 GB: once, the same
0xc0000005at+0x23cf683, in a few dozen launches into the world; none in the last 40 or so. #959 says that address is the title's own watchdog, firing about 30 s after the submitting thread is stuck on a fence that never comes — so a stale slot would be one cause of it among others (anything that hangs or loses the card silently). With #959's bounded wait in, the log should name the cause the next time; I will add it here if it comes back.(Runs by me on the hardware above; read from the logs and written with Claude Code.)
@slauko on GitHub · 2026-11-26 15:39 UTC · original
The coalescing item in this PR, measured on a Linux/Wine line (RTX 3080 Ti, vkd3d-proton
ec20719, uiliannn's base), in the cell at ~5,000 draws:watch::writescalls a frame — 18,887 answered from the journal, 16,395 by the kernel — 40.6–41.2 ms, and the copies 166–173 MB/17 ms for what the write watch named.Batch::flushupdating a copy's touching ranges in one pass instead of one pass per recorded range: 8,965 calls, 5.9–6.4 ms asking, 52–57 MB/5.9 ms copied, preparing 100–110 → 57–63 ms.VICTORY_COPY_SAMPLE=1on this line: 83–85% of the words sampled in those copies were already equal — the writes inside the named pages are sparse.So the count is the lever, not the copy: 193 MB at 9.4–10.3 GB/s is 19–21 ms, the asking around it was 38–43.
@slauko on GitHub · 2026-11-26 17:05 UTC · original
A correction to my numbers above, for the coalescing item: the merged run keeps the title on its prologue card.
m66-m79: 3,000-3,100 draws on the prologue's card).m76: 4,976 draws, 209.8-214.8 ms); sorted, in recording order and capped at 4 MiB all do not.m80, 4,968-5,000 draws), asking 34.3-34.6 ms at ~34,000 calls.So: coalescing the ~34,000 refreshes a frame is the right target (34 ms of asking), but merging the ranges changes something the intro's transition needs on this stack. A coalescing that keeps each range's own
update(one asking ahead, many updates) would be the shape to try, not one update per merged span.@slauko on GitHub · 2026-11-26 18:03 UTC · original
Closing the coalescing item with the measurement from my line (Linux/Wine, RTX 3080 Ti, vkd3d-proton
ec20719):GetWriteWatchfor everything the submission refreshes of it, each range's update served from that answer, order unchanged): cell 193.7/200.3 ms against 205.1 (m80), the copies 20-22 ms for 156-167 MB against 55-60 for 170-180 — but one of the two runs is visibly broken (floating polygons, garbage geometry, black clipping on the character).0360aad5); with the merged-range variant (34 ms of asking saved, title stays on its prologue card) four shapes of this lever are now measured and rejected. The asking stays per range, and the ~34 ms it costs are not reachable by moving or widening it.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.