dstorage: adaptive read-ahead map for streaming files + HUD telemetry #106
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!106
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-106"
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 19:52 UTC · original
luniiya:read-ahead-map→main· +726 −16 · 9 files · 1 commits · openWhat
Adds a learned, adaptive DirectStorage read-ahead map (
crates/victory-hle/src/modules/read_map.rs) plus live HUD telemetry (Read mapandMap costrows inpanel.rs):LEAD = 1536pieces),(uses × bytes × 16) / (16 + age × 8), skipping one-off sparse reads (< 64 KiB, 1 session).~/.cache/victory/read-map.txtinrun.sh) snapshot compact state under the lock and release it before sorting/formatting, so DirectStorage reads never stall.VICTORY_READ_MAP_DEFAULT,tools/read-map-share.shstrips non-G:\paths; stores only title paths and 1 MiB piece indices, no game bytes).Read map(GB prefetched + first-read hit %) andMap cost(avg hit ms / avg miss ms + background I/O seconds) to the F3 HUD, plusxmem HW-RT/SW-RTin the top badge.VICTORY_READ_MAP=(empty disables),VICTORY_PREFETCH_MB(default40960MiB).Why
When the game files live on a rotating HDD (or slower storage), DirectStorage issues thousands of small scattered reads while streaming the world (~15–45 ms each). Because the OS page cache starts cold (or only holds a few GB), game startup, save loads, and driving through the world stall waiting on disk seeks.
Reading the learned pieces ahead in sorted batches while the title is quiet turns scattered 15–45 ms HDD reads into ~0.01–0.04 ms page-cache hits without storing any extra copies in process RAM (it lives in evictable OS page cache).
Results
Measured on a 2 TB rotating SMR HDD (ST2000DM008) with 125 GB system RAM, RX 7800 XT 16 GB (ReBAR on), Ryzen 7 5800X, Arch/CachyOS, GE-Proton11-14:
read map: last minutelogs & HUD):first_reads_known_not_yet = 0after prefetch completes).Read map: 34.5 GB (61% hit),Map cost: 0.04/0ms 46s bg.Platform
Works on both Linux/Wine and Windows (uses
CreateFileW+FileExt::seek_readto warm the OS file cache, and lock-free atomics for the HUD). Disabled cleanly ifVICTORY_READ_MAPis unset or empty.How this was tested
build.sh checkpasses cleanly with zero warnings onmain(37bb30f).local-stack(main+ PRs #31, #34, #35, #43, #44, #45, #47, #48, #58, #63, #67, #75, #93, #100, #101) withVICTORY_OUTPUT=2560x1440,VICTORY_BVH_HARDWARE=1,VICTORY_UI_PLANE=3840x2160.3fd95e9989to9d6f2865209d6f286520to13cab999db13cab999dbtod676e937f8@Luxuride on GitHub · 2026-12-04 12:03 UTC · original
This is the most speculative thing in this batch: a large heuristic cache that spends 40 GiB of I/O by default, with no tests and no way for a maintainer on Linux to run any of it.
run.sh:33exportsVICTORY_READ_MAPunconditionally, andcrates/victory-hle/src/modules/read_map.rs:150is.unwrap_or(40960)MiB. On the HDD case this is written for, that roughly doubles the reads the title waits behind, from a second handle and a competing thread.run.sh:34exportsVICTORY_READ_MAP_DEFAULT=$(win "$root/config/read-map.txt")but no such file exists in the PR or on main (config/has onlynative-compute.txtandnative-keys.default.txt), so the "shipped map" tier is dead code until someone runstools/read-map-share.sh."xmem RT"tag becomes ahost_bvh()-dependent "xmem HW-RT"/"xmem SW-RT" (main still has plain"xmem RT"atcrates/victory-gpu/src/host/panel.rs:2167). That belongs in its own PR if it is wanted.#[cfg(test)]at all, and the nine HUD atomics are kept in release builds.To make it reviewable: opt-in by default, a budget in the low GiB, ship or delete the default-map tier, pull the panel label out, and test
next_batch/ load-save round-trip / the score.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.