VFS: a plain read of a game file asks the file system once, not three times #1092
No reviewers
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!1092
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1092"
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 11:28 UTC · original
DTsordas:vfs-read-open-one-probe→main· +31 −0 · 1 files · 1 commits · openEvery
CreateFileW/CreateFileA/CreateFile2of a game file goes throughVfs::open_decision. For a read,open_decision_forcalledvisible_in_overlayandvisible_in_originalto work out whether the open writes, thenread_path_relcalledvisible_in_overlayagain. A plain read (no write access, notOPEN_ALWAYS) never uses the first two answers: the decision is alwaysread_path_rel's. Each check is astd::fs::metadata, which costs about as much as the title's open itself. Now a plain read goes straight toread_path_rel.OPEN_ALWAYS,TRUNCATE_EXISTING, delete-on-close and any write access take the unchanged path. Fixes #999.Measured with a scratch benchmark (not part of the PR): 200 game files under a
G:mount, release build, median of 15 rounds of 200 opens. Main and this PR were run back to back three times, and the table gives the median of the three runs.GENERIC_READ,OPEN_EXISTING)47efa2eopen_decisionopen_decision+File::openof its pathFile::open(reference)The remaining check is the overlay copy, which costs almost as much on a path that doesn't exist. Skipping it while the overlay is empty is its own PR.
What is in it
crates/xcl/src/vfs.rs: the early return for a plain read inopen_decision_for, andreads_take_the_original_and_read_only_open_always_still_creates, which pins the edge of the fast path: a read-onlyOPEN_ALWAYSof a missing file still creates it in the overlay. The existingreads_never_touch_and_writes_copy_on_write,delete_is_a_persistent_whiteoutandtruncate_existing_validation_errorscover the read and validation decisions and pass unchanged.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4at639397a(on main47efa2e), two runs:e2elost its GPU at "coherent window headroom" ("GPU fence 1 not reached", then 0x887A0005 for the GPU checks after it). No file check failed.cargo test -p xcl --test e2ealone, three times: 3 passed each time.cargo test -p xcl --lib vfs: all VFS tests pass excepttruncate_existing_validation_errors, which fails when it's the first test to callunder_wine()(127 instead of 5, on main too); #633 fixes that test.Regression run
The title's 60 s smoke run (
scripts/smoke.ps1, release builds, same machine, back to back with a warm shader cache).main:
PR:
Not tested
AI use
🤖 Generated with Claude Code
github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@DavidM1911 on GitHub · 2026-11-25 08:36 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.