dstorage: persistent block cache for game files on slow mounts (VICTORY_READ_CACHE) #101
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/101"
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?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by daidalos4 on 2026-11-26T14:51:49Z.
What this changes
Adds
VICTORY_READ_CACHE=<dir>:<prefix>, an opt-in persistent block cache under the DirectStorage file reads, for game files on a slow network share.When the game folder lives on a NAS or a remote mount, the first boot can spend many minutes on reads (here, about 1 MB/s), and the run never gets past a black screen. With the cache, every 64 KiB block that DirectStorage reads from a file under
<prefix>(checked after resolving links) is kept in<dir>as<name>-<length>.data(sparse) plus a.mapwith one byte per block. The next run reads those blocks from local disk, so each boot gets further than the last.<prefix>are cached.<dir>to reclaim the space.#[cfg]), like the rest of the macOS DirectStorage path. Documented in docs/native-host.md.How it was tested
cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory: victory-hle 227 passed, including the newread_cache::tests::reads_match_the_source_cold_and_warm(cold and warm passes against the source bytes). The probe-based loader tests fail on this machine before and after the change (lld: unable to find library -lkernel32, the cross toolchain isn't installed here).cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings: not run (no Windows target installed). The new code is macOS-only; clippy onx86_64-apple-darwinfor victory-hle reports nothing in the changed files.Checklist
VICTORY_*variable and documentedImported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T15:55:43Z.
Review: CHANGES_REQUESTED
Opt-in and local, so the idea is fine, but before merging:
This is tangential to the story-load crash work, so it is low priority on our side.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T05:41:15Z.
This needs a rebase on main (dstorage.rs conflicts) and the two review points: the cache key should include the file's mtime so a patched file of the same size is not served stale, and the data and map writes need an order (data, sync, then map) so a crash cannot leave a block marked present with nothing behind it. Low priority, but welcome once those are in.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by daidalos4 on 2026-11-27T10:12:30Z.
Merged main and addressed both points: the cache key is now
<name>-<length>-<mtime>, so a patched file of the same size gets a fresh entry, and each fetched run of blocks issync_data'd before its map bytes are written, so a crash can lose blocks but never mark one present with nothing behind it. Docs updated.read_cache::testspasses on x86_64-apple-darwin.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T10:46:13Z.
Thank you. Both points are in: the key has the mtime, and the data is synced before the map byte is written. CI is green on the merge. I have not run it; I rely on your run on the slow share.
Two small notes, neither blocks it: every missing run now ends in a sync, so please say if the first boot felt slower on a fast disk; and clippy for the Windows target was not run on your side, but CI did it. I will review it again and merge.
Merged.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T10:46:25Z.
I ran these five together on my Mac before merging (#101, #267, #288, #289, #291 on main, M5 Pro 48 GB, Series S, warm cache, three runs): two runs stayed in the world until the time limit (139 s and 202 s there, about 2 fps, no failed command buffer, no fault); one ended at the start of the world with a title fault I had not seen before (first chance at image+0x4fafef8, a read of 0x30000065c), with no GPU error before it. I could not tie that one to any of the five. If you see it, please say so.