pipeline: cache writes no longer wait on the disk during play #87
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/lobomfz--VIctory-xmem!87
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-87"
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?
@luniiya on GitHub · 2026-12-01 18:00 UTC · original
pipeline-writes-off-disk-sync→main· +178 −8 · 3 files · 1 commits · closed without mergingWhat
During play, nothing in the pipeline cache waits on the disk any more:
prepared.rs): the file is handed to avictory-pipeline-storethread and written without a flush. The draw that waits for the pipeline gets it at once. If that thread's queue (1024) is full, the file is skipped; the next run makes the pipeline again. At the end of a run,save(true)waits up to 10 s for the queue.library.rs): saved every 60 s instead of every 12 s, and not at all when unchanged (compared by hash). Our thread flushes the new file before renaming it over the old one, so the rename has nothing left to write.known.rs): appended without a flush; it is flushed only after a GPU failure.victory warmstill flushes every file, as before.Why
With the cache on a rotating disk that the title's streaming keeps busy (io pressure 50–60 %, average write wait ~216 ms), every flush forced an ext4 journal commit that queued behind the title's reads:
jbd2_log_wait_commitfor 60 s of a 100 s sample. A draw waiting for its first-use pipeline waited for the disk: a small mesh + pixel pass took 10.5 s to make, which ran past the 10 s screen-pass budget and made the present take ~5 s.auto_da_alloc) then flushes the data inside the rename. Under Wine the rename is done by wineserver, one thread for the whole process. It was sampled inblk_mq_get_tag(disk queue full) anddo_get_write_access(journal) for 1–4 s at a time. Every thread that asked the server anything waited with it, including logging and presenting, so the whole emulator froze for 2–8 s. The log gaps ended exactly when those saves did.Results
The freezes silence the log too, so silent stretches in
play.logare a fair measure of them. First 5 minutes (start and loading) left out:System-wide io pressure (
some, 5 min average) went from ~33 % to ~16 %. In play, textures and NPCs now stream in while walking, where before they stayed missing for a while.Caveats: the "after" sample is short and was played in a different area. Part of the faster start came from the previous run's file data still being in the page cache. The test build also had two local changes that are not in this PR: a fix to the texture-lateness statistics, and a recorder of the title's file reads (writes a small file to another disk every 90 s). Neither touches pipeline saving.
Platform
This is not Linux-only: the flushes are skipped on every platform. On Windows there is no wineserver, but each flush still waits on the disk in the same way. What a crash can now lose:
prepared.rsfiles, any file cut short by a crash is refused when read back (name and blake3 hash check) and the pipeline is made again;So the worst case is remaking a few pipelines on the next run.
victory warmkeeps its flushes.How this was tested
Tested on Linux only, on a local branch:
main(37bb30f) plus these open PRs merged in (all merged cleanly):run.conf:VICTORY_OUTPUT=2560x1440,VICTORY_BVH_HARDWARE=0(RDNA3 draws black geometry with it on, #33),VICTORY_POOL_MOVE=1,VICTORY_PLACED_COPIED=1,VICTORY_WARM=0.Machine: Ryzen 7 5800X, RX 7800 XT 16 GB with Resizable BAR on, 125 GB RAM, CachyOS (kernel 7.3), GE-Proton11-14. The game dump and
local/(caches, prefix, log) are on a 2 TB rotating SMR hard drive (ST2000DM008, BFQ), 99% full.Turning on Resizable BAR in the BIOS (Above 4G decoding on, CSM off, Re-Size BAR on) was the biggest single change on this machine: about 3–14 FPS before, 30–46 FPS after, with the 4 GB title pool on the card.
Pull request closed