Scratch buffer pool starvation causes excessive allocations and severe FPS degradation #930
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#930
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@moduz87 on GitHub · 2026-11-28 09:15 UTC · original
Hello,
During independent performance testing, we identified a potential flaw in the scratch buffer pool implementation in host.rs, specifically in Spare::give().
When the pool reaches its capacity, newly returned buffers are discarded while older, potentially unused buffers remain cached.
Our measurements showed:
Approximately 415 MB/s of unnecessary buffer allocations.
Approximately 190,000 additional page faults per second.
Performance degradation to 7.5 FPS.
We implemented an eviction policy that removes the oldest cached buffers instead of rejecting newly returned ones.
Results under the tested conditions:
Average FPS: 7.5 → 14.1 (+88%).
P99 frame time: 221 ms → 81 ms.
Continuous buffer allocations eliminated at steady state.
The original behavior is still present in the latest host.rs snapshot we inspected.
We have a working experimental patch and benchmark results available. We would be happy to discuss the findings and contribute the fix.
github-bot referenced this issue2026-11-28 14:31:05 +00:00
@github-actions[bot] on GitHub · 2026-11-28 09:15 UTC · original
Please attach both logs from the run that went wrong. Without them we can only guess. Paste
%LOCALAPPDATA%into the address bar of File Explorer to get there.%LOCALAPPDATA%\victory\logs\: the newestvictory-nvidia-play-<date>-<time>-<number>.log(fromvictory.exe) orvictory-nvidia-<date>-<time>.log(from the script launcher). The window shows its path at the start, on the lineLog: ....%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newestvictory-<date>-<time>-<number>.crash.login%LOCALAPPDATA%\VIctory\data\7952987A\temp\.Also say which GPU, Windows version (10 or 11)
@moduz87 on GitHub · 2026-11-28 09:16 UTC · original
This is not a crash report. We independently identified a performance issue in the scratch buffer pool, specifically in Spare::give() in host.rs.
We have already developed an experimental fix and measured its impact through comparative benchmarks.
Under the affected conditions, performance improved from 7.5 to 14.1 FPS, eliminating approximately 415 MB/s of unnecessary buffer allocations.
GPU: NVIDIA RTX 5070 Ti 16 GB.
CPU: AMD Ryzen 7 3800X.
RAM: 32 GB.
Would you be interested in reviewing our findings, benchmark logs and proposed patch?
@kibagami-nc on GitHub · 2026-11-28 09:44 UTC · original
The code agrees with you. Once the kept bytes would pass the limit,
Spare::givehands the returned chunk back to be freed, whatever the kept ones are.takeasks only for a chunk of the exact size wanted, so kept chunks of a size nobody asks for any more just hold the room.Two things narrow when it bites:
VICTORY_KEEP_FREEDon (the default). It is 128 MiB only whilecrate::residency::limited_host_ram()holds, that is with little free RAM.VICTORY_ALLOCATOR_TRIM=1(on in the launchers), every 10 s the chunks kept and never taken since the last trim are freed.So the churn should be worst under host-memory pressure, between two trims. Your 32 GB with the game's footprint would fit that. If your measurement has the
card memory/ private-bytes lines, they would show whether the 128 MiB limit was the one in force.A pull request with your patch and the benchmark is the way to get it reviewed. The logs the bot asks for are meant for crash reports. A unit test of
Sparemakes it easy to check without the game, for example:The existing
Sparetests near the end ofhost.rsshow the shape.@ANDREANIADS on GitHub · 2026-11-28 10:09 UTC · original
I exercised
Spareon63b902fein debug and optimized builds with synthetic chunk IDs on CPU. I filled the 128 MiB pool with 512 × 256 KiB chunks, calledtrim()to start the observation window, then ran 64 take/give cycles at 4 MiB. There were 0/64 reuse hits before the next trim and 63/64 afterward. The 256 KiB control got 64/64 hits at capacity.One regression case for your patch: start with that same full pool and return one 4 MiB chunk. With oldest-first eviction, the 16 oldest 256 KiB chunks should leave, and the retained total should still be 128 MiB. An immediate
trim()should release the remaining 496 old chunks (124 MiB) and leave the new 4 MiB chunk available totake. This checks the byte count and the trim window when a single return replaces multiple chunks.@jptorres96 on GitHub · 2026-11-28 13:59 UTC · original
@ANDREANIADS Your regression case is in #973 as
one_big_chunk_into_a_full_pool_and_the_trim_after_it, with the same numbers: 512 × 256 KiB fill a 128 MiB pool,trim(), then one 4 MiB chunk is given back. It checks that the 16 oldest leave, that 128 MiB stay kept, that the nexttrim()frees the other 496 (124 MiB), and thattake(4 MiB)returns the new chunk. 456/456victory-gputests pass on that branch.@Robotniq on GitHub · 2026-11-28 21:40 UTC · original
A data point from an RTX 3070 Ti 8 GB / i7-13700F / 32 GB RAM (Windows 11, Series S, DLSS Quality, the title's ray tracing off), diagnostics build of a tree whose
Spare/give_chunkscode is the same as main's.limited_host_ram()(residency.rs:93) comparesullTotalPhys, the total RAM, with 32 GiB. A "32 GB" PC reports about 31.8 GiB, so every PC with 32 GB or less runs withSPARE_MOST(128 MiB) for the whole run, however much RAM is free. Only PCs with more than 32 GiB get the 1 GiB bound.VICTORY_SCRATCH_SPARE_MB): 445 upload buffers per run, 351 MB spare, "new memory waited for" 40,000 times, 9.5 s, longest 47 ms. Scratch memory went from about 200 MB to about 395 MB. The minimum free RAM stayed about the same (~4 GB, with the game at ~21 GB). Median fps after the first minute: 25.3 against 24.7 and 24.9, which is inside this PC's run-to-run noise. Here the waits fall mostly on the list threads, which are not this PC's limit.I did not test #973's eviction.
Measured with AI assistance (Claude Code); the runs were made on my machine.
@kalberts0089-hash on GitHub · 2026-11-29 09:23 UTC · original
@moduz87 @jptorres96 Data point for rebasing #973. Main (
829188e9, the commit v2026.11.29.01 is built from) still has the refusingSpare::give, and #973 now conflicts with it in 5 hunks ofhost.rs.The part that's easy to get wrong: main now drops chunks from the front of
keptin two pressure paths. One is the newSpare::trim_to(crates/victory-gpu/src/host.rs:2911) and the other is thekept.remove(0)loop intrim_spare_chunks(host.rs:3216). Both updatelow, which #973 replaces withold. After the rebase,oldhas to go down by the number drained (old.saturating_sub(n)), not just be clamped tokept.len(). Example: 4 kept at a trim, 2 given back since, then pressure drops the 3 oldest. Ifoldshrinks, the next trim frees[4]. If it is clamped, the trim frees[4, 5, 6], which is ANDREANIADS's bug coming back by another route.The copy-source pool
UPLOAD_SPAREhas the same starvation, and #973 doesn't touch it.give_uploadsuses the same refusinggive(host.rs:3145). The 10 s trim only runs onSPARE/SPARE_SHARED, so this pool is drained only whileresidency::pressured()holds. Synthetic test: 1024 x 1 MiB chunks fill the 1 GiB pool, then 1000 take/give cycles at 2 MiB. The refusinggivereused 0/1000. Oldest-first eviction reused 999/1000. I haven't measured how often this happens in play, and I can't run the game here.@trustno1-coder on GitHub · 2026-11-29 23:07 UTC · original
Closing this one: it was reported on v2026.11.28.02 or earlier, and a lot has changed since (crash fixes, memory, shaders, warm-up and speed).
If it still happens on v2026.11.29.05, please open a new issue with the newest play log from
%LOCALAPPDATA%\victory\logs\andcrashes.log, and we'll look at it there.