VFS: a plain read of a game file asks the file system once, not three times #1083
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by DTsordas on 2026-11-24T11:28:24Z.
Every
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
Imported from ivall/xcl. Originally posted by sds-228 on 2026-11-24T14:06:29Z.
Review: APPROVED
Reviewed head
639397a.cargo test -p xcl --lib vfs→ 24 passed, 0 failed here. The plain-read fast path excludes every write-like open:is_writecovers write access,CREATE_NEW,CREATE_ALWAYS,TRUNCATE_EXISTINGand delete-on-close, withOPEN_ALWAYSchecked separately. Paired smoke block shows 1500 frames against main's 1434. No issue found.AI-assisted (OpenCode).
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T08:36:46Z.
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!
upstream-sync referenced this pull request2026-11-25 16:10:51 +00:00
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:44:05Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:47:57Z.
Triage (#1607) – head
639397a#1106 is the other PR for #999. It skips the overlay probes while the overlay is empty; this PR skips the two visibility probes in vfs.rs:open_decision_for on plain reads. They complement each other and do not duplicate. Main still runs visible_in_overlay and visible_in_original before read_path_rel on every read. The PR conflicts with main.
The new test pins behaviour that was already correct, so it passes without the change too. That is expected for a change that only removes file-system calls.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Pull request closed