VFS: a plain read of a game file checks the file system three times before the open (about 4x a native open) #999
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#999
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?
@DTsordas on GitHub · 2026-11-24 10:09 UTC · original
Every
CreateFileW/CreateFileA/CreateFile2of a game file goes throughVfs::open_decision. For a read,open_decision_for(crates/xcl/src/vfs.rs:547) callsvisible_in_overlayandvisible_in_originalto work out whether the open writes, thenread_path_relcallsvisible_in_overlayagain. A plain read (no write access, notOPEN_ALWAYS) never uses the first two answers: the decision is alwaysread_path_rel's. Each of the three checks is astd::fs::metadata, which costs about as much as the title's open itself.Measured on main
077ce40(release build, 200 game files under aG:mount, median of 15 rounds of 200 opens, three runs), per read open (GENERIC_READ,OPEN_EXISTING):read_path_relopen_decisionopen_decision+File::openof its pathFile::open(reference)So a title's read open of its own files costs about 4× a native one now, and about 2× with the change.
I have the change with a test that pins the edge of the fast path (a read-only
OPEN_ALWAYSof a missing file still creates it in the overlay). The full suite passes with it on an RX 9060 XT (debug,cargo test --workspace -- --test-threads=4: 717 passed, 0 failed, 41 ignored, 0 SKIPPED). I'll open the PR once I have the smoke runs on a title.AI use: found, measured and written up with Claude Code (Claude Opus 5.5).
github-bot referenced this issue2026-11-26 04:59:09 +00:00
@DTsordas on GitHub · 2026-11-24 10:24 UTC · original
Follow-up measurement: the remaining check can go too. Most titles never write their game folder, so the overlay holds nothing. With a flag,
visible_in_overlayanswers without a file system call while the overlay is empty. The flag is set at start when the overlay folder holds anything besides.xcl_whiteouts, and bystage_write/prepare_write/create_dirbefore they create anything.Same benchmark (200 game files under
G:, release, median of 15 rounds of 200 opens, three runs each), per read open:077ce40open_decisionopen_decision+File::openFile::open(reference)With both, a title's read open of a game file costs about as much as a native one. They're two independent changes, so either can merge first, and each has its own tests. The full suite passes with each on an RX 9060 XT (debug,
cargo test --workspace --no-fail-fast -- --test-threads=4: 717 / 0 / 41 and 718 / 0 / 41, 0 SKIPPED). I'll open both PRs once I have the smoke runs on a title.AI use: Claude Code (Claude Opus 5.5) wrote the changes, ran the benchmark and the tests, and wrote this comment.