memory: keep a packed structure's pages when another one replaces it at the same address #1878
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!1878
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1878"
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?
@xteral67 on GitHub · 2026-11-29 01:22 UTC · original
xteral67:fix-packed-replace→main· +25 −1 · 1 files · 1 commits · merged 2026-11-29 08:16 UTCNo issue filed: found while profiling city driving with ray tracing on.
What it changes
What was wrong. With ray tracing on, driving fast through a city made the game drop to 0.3-2 fps for 5-60 s at a time. Often it did not recover even when standing still, and on the release build it often ended in a device removal (
0x887A0005, the card hung past the TDR delay). GPU timing showed the ray walk shaders (indirect-walk) going from 2-15 ms to 340-670 ms a frame. The builder itself stayed cheap.Memory dumps (
VICTORY_MEMORY_DUMP) taken during the slowdown showed 23-36 instances of the walked top level structures pointing at bottom level structures whose arena pages still held the packed header (0x...81020006). Rays walked packed bytes as nodes until their iteration limit.A per-structure history of
Memory::landshowed the same sequence for every one of them:landsees another header and callsgone(A): A's pages go back to the free list and their directory entries become 0.Structures landing at a fresh address never broke. Only replacements at the same address did. That happens a lot when streaming in fast.
What this does. When a known packed structure gives way to another one at the same address, the new
Memory::replaceddrops it likegonedoes, but keeps its pages where they are. The new structure takes the same places, so the directory does not change and the builder unpacks where the rays later read.Works together with #1161 (merged, off by default). This fix only shows when the compacted sizes reach the title's copies (
VICTORY_BVH_SIZE_COPY=1). Without that, the copies of compacted structures are still wrong and the slowdown stays, with or without this change. Neither of the two alone stops it; together they do (numbers below).Trade-off. If the new structure is shorter than the old one, the old one's tail pages stay held with no owner until the address is reused. This is a small, bounded leak, traded for not touching the directory in the middle of a submission.
How it was tested
VICTORY_BVH_BUILDER=1,VICTORY_AMBIENT=0). The same city route at high speed by car in every run. Numbers are fps per 5 s interval, in game only.v2026.11.28.03 + #1161 cherry-picked (
VICTORY_BVH_SIZE_COPY=1):0x887A0005)v2026.11.28.03 alone (no #1161): with or without this fix, the slowdown to 0-3 fps and a device removal at speed.
A build close to v2026.11.27.9 that already has the compacted size copies, switching one thing at a time:
Diagnostics build, same place and route:
d585f88. Therememory.rsgained #1062 and #722 (gonenow tells the write watch about the directory entries it clears, and faulted pages are kept under a budget); the only conflict was the two new functions sitting next to each other. The driving runs above are on v2026.11.28.03 and on a build close to v2026.11.27.9,cargo testond4b5d51; this exact rebased commit was not driven again.cargo testpassed for the crates it touches: yes,cargo test --release -p victory-gpuon main atd4b5d51with this change: 550 passed, 0 failed. In one earlier rundescriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytesfailed once (view width 6291456 instead of 65536) and passed on the next run with no change; it does not touch title memory by address, so it looks flaky (tests sharing a pool while running in parallel?).Checked for overlap
landdrops a replaced packed structure.🤖 Generated with Claude Code
@xteral67 on GitHub · 2026-11-29 01:31 UTC · original
A note on #1161, since it is merged but off by default (
VICTORY_BVH_SIZE_COPY):With the title's ray tracing on (
VICTORY_BVH_BUILDER=1), the size copies look required rather than optional. In the runs above, city at speed on an RTX 3080 Ti:0x887A0005), with or without this PR;So it may be worth turning
VICTORY_BVH_SIZE_COPYon whenever the builder is on, or by default.