pipeline: cache writes no longer wait on the disk during play #100

Manually merged
github merged 1 commit from github-bot/gh-100 into gh-pr/100/base 2026-12-01 20:58:45 +00:00 AGit
Owner

@⁠luniiya on GitHub · 2026-12-01 19:09 UTC · original
luniiya:pipeline-writes-off-disk-sync → main · +178 −8 · 3 files · 1 commits · merged 2026-12-01 20:55 UTC

(Re-opened from #87 after accidentally deleting and re-creating the fork.)

What

During play, nothing in the pipeline cache waits on the disk any more:

  • First-use pipelines (prepared.rs): the file is handed to a victory-pipeline-store thread 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.
  • Pipeline lists (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-pipeline book (known.rs): appended without a flush; it is flushed only after a GPU failure.
  • victory warm still 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:

  • The pipeline workers sat in jbd2_log_wait_commit for 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.
  • The 12-second list saves rename over existing files, and ext4 (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 in blk_mq_get_tag (disk queue full) and do_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.log are a fair measure of them. First 5 minutes (start and loading) left out:

Build Play time Stalls > 2 s Stalls > 4 s Longest
Before this change 36.5 min 41 (67/h) 13 (21/h) 20.5 s
With this change 9.4 min 0 0 1.1 s

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:

  • the last pipelines made, and the last appends to the book;
  • for prepared.rs files, any file cut short by a crash is refused when read back (name and blake3 hash check) and the pipeline is made again;
  • the book is read up to its last whole record.

So the worst case is remaking a few pipelines on the next run. victory warm keeps 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):

  • #35 setup.sh: a rebuilt vkd3d reaches the prefix
  • #48 env.sh: patched() compares full blob hashes
  • #34 run.sh: MUTE=1 as an argument mutes
  • #45 Fix black sand and terrain in indirect mesh dispatches
  • #47 texture: keep what a GPU copy wrote from uploads asked for before it
  • #67 formats, texture: BC7 dictionary indices as BCPack.dll reads them; GPU copies reach views placed before them
  • #44 gpu: page mover off the title's path, honest VRAM budget, tighter texture pool
  • #31 texture pool: VICTORY_POOL_MOVE moves textures in use out of blocks being emptied (#21)
  • #43 gpu, mesa: HW RT UAV barrier/memory_ready and NIR image_heap coherency
  • #75 ambient: keep VICTORY_AMBIENT_RT opt-in with ray tracing (#61)
  • #63 resolution: 4K interface plane at 2560x1440 (VICTORY_UI_PLANE)

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.

**@⁠luniiya** on GitHub · 2026-12-01 19:09 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/100) `luniiya:pipeline-writes-off-disk-sync` → `main` · +178 −8 · 3 files · 1 commits · merged 2026-12-01 20:55 UTC *(Re-opened from #87 after accidentally deleting and re-creating the fork.)* ## What During play, nothing in the pipeline cache waits on the disk any more: - **First-use pipelines** (`prepared.rs`): the file is handed to a `victory-pipeline-store` thread 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. - **Pipeline lists** (`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-pipeline book** (`known.rs`): appended without a flush; it is flushed only after a GPU failure. - `victory warm` still 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: - The pipeline workers sat in `jbd2_log_wait_commit` for 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. - The 12-second list saves rename over existing files, and ext4 (`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 in `blk_mq_get_tag` (disk queue full) and `do_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.log` are a fair measure of them. First 5 minutes (start and loading) left out: | Build | Play time | Stalls > 2 s | Stalls > 4 s | Longest | |---|---|---|---|---| | Before this change | 36.5 min | 41 (67/h) | 13 (21/h) | 20.5 s | | With this change | 9.4 min | 0 | 0 | 1.1 s | 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: - the last pipelines made, and the last appends to the book; - for `prepared.rs` files, any file cut short by a crash is refused when read back (name and blake3 hash check) and the pipeline is made again; - the book is read up to its last whole record. So the worst case is remaking a few pipelines on the next run. `victory warm` keeps 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): - #35 setup.sh: a rebuilt vkd3d reaches the prefix - #48 env.sh: patched() compares full blob hashes - #34 run.sh: MUTE=1 as an argument mutes - #45 Fix black sand and terrain in indirect mesh dispatches - #47 texture: keep what a GPU copy wrote from uploads asked for before it - #67 formats, texture: BC7 dictionary indices as BCPack.dll reads them; GPU copies reach views placed before them - #44 gpu: page mover off the title's path, honest VRAM budget, tighter texture pool - #31 texture pool: VICTORY_POOL_MOVE moves textures in use out of blocks being emptied (#21) - #43 gpu, mesa: HW RT UAV barrier/memory_ready and NIR image_heap coherency - #75 ambient: keep VICTORY_AMBIENT_RT opt-in with ray tracing (#61) - #63 resolution: 4K interface plane at 2560x1440 (VICTORY_UI_PLANE) `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.
During play, a first-use pipeline's file is written by a thread of its own
and not flushed; the draw that waits for it gets it at once. The pipeline
lists are saved every 60 s instead of every 12 s, only when they changed,
and the new file is flushed by our thread before the rename, so the rename
(done by Wine's server) has nothing left to write. The known-pipeline book
is flushed only after a GPU failure. `victory warm` still flushes every file.

With the cache on a rotating disk that the title's streaming keeps busy,
each flush forced a journal commit that waited seconds behind the title's
reads, and Wine's server (one thread for the whole process) waited with
it, so every thread stood still: freezes of 2 to 8 s.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 19:12:34 +00:00
github-bot referenced this pull request from a commit 2026-12-01 20:58:42 +00:00
github-bot changed target branch from main to gh-pr/100/base 2026-12-01 20:58:42 +00:00
github manually merged commit d8fd34b4f7 into gh-pr/100/base 2026-12-01 20:58:45 +00:00
github-bot referenced this pull request from a commit 2026-12-01 21:04:22 +00:00
github-bot referenced this pull request from a commit 2026-12-04 19:05:27 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.