DirectStorage: workers read a file through a handle each #2904
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2904
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2904"
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?
@0xkn0wh3r3 on GitHub · 2026-11-25 23:32 UTC · original
0xkn0wh3r3:hle/dstorage-handle-per-worker→main· +182 −7 · 1 files · 1 commits · openWhat
Each DirectStorage worker now reads a file through its own handle instead of the one handle the title's
OpenFilemade. A worker makes its handle withReOpenFilethe first time it reads that file. If the host refuses, it falls back to the title's handle, logs a warning, and carries on. The handles close with the file object.VICTORY_DSTORAGE_HANDLES=0reads through the title's handle alone, as before.Why
The title's handle is opened for synchronous reads, and Windows performs the reads on one such handle one at a time. So the scheduler's workers (one per host core) queued behind each other on every file, however many were free.
Measured with 48 KiB reads at random offsets from 24 threads:
read_bench)Nothing here depends on the GPU vendor.
Where it comes from
From the avatarmanz/VIctory-7900XTX fork, commit
fbc1830. This PR takes only the fork's defaulthandlesmode. Left out: itsoverlappedand unbuffereddirectmodes, and its xmem lock rework from the same commit.#234 also targets this serialization, using overlapped reads on one handle, but it bundles that with xmem mapping changes. This PR is only the handle change.
Tested (Windows 11, RTX 5070 Ti)
cargo test -p victory-hle: 153 passed, 1 ignored (the benchmark). New testworkers_read_a_file_through_handles_of_their_own: six threads read through three handles, and through the title's handle alone, at offsets across a 300,001-byte file and past its end. It checks the bytes and checks that each handle slot a thread used was made.read_bench(ignored):VICTORY_BENCH_FILE=<file> cargo test --release -p victory-hle --lib read_bench -- --ignored --nocapture. The cached-file numbers above come from it.cargo clippy -p victory-hle --all-targets -- -D warnings: clean.Not tested
@Marvisak on GitHub · 2026-11-26 02:18 UTC · original
Automated triage for the maintainers.
Merge candidate (a recommendation to look, not an approval). In
modules/dstorage.rs, each scheduler worker now reads a file through its own handle, made lazily withReOpenFilefrom the title's handle (Files::read_at). If reopening fails it falls back to the title's handle, andVICTORY_DSTORAGE_HANDLES=0restores the old behaviour. Reads are still positional (seek_read), so sharing a handle never depended on a file position; the change only removes the per-handle serialisation, and the PR measured 185 vs 990 MB/s. The test checks that the bytes and end-of-file results match with and without extra handles. CIcheckpasses.Generated by Claude Code
@kotekompotek on GitHub · 2026-11-25 23:35 UTC · original · reviewed
Correct — a synchronous handle serializes reads on the host side, so N workers through one handle queue behind each other; a lazy per-worker handle (OnceLock indexed modulo worker count) removes that contention while keeping the title's handle semantics. The =0 escape hatch is there. LGTM.
@fuzeofficlal on GitHub · 2026-11-25 23:43 UTC · original · reviewed
Verified head
487d01e0cleanly onorigin/main(63bcca43) on Windows 11 x64.Code Review
ReOpenFile(..., GENERIC_READ, FILE_SHARE_READ, 0)creates distinct kernelFILE_OBJECTs per worker (unlikeDuplicateHandle), eliminating synchronous-I/O lock serialization across worker threads while keepingseek_readoffsets independent.OnceLock, fall back cleanly tofirstifReOpenFilefails (or whenVICTORY_DSTORAGE_HANDLES=0), and drop cleanly onInstance<File>release.Local Verification
cargo test --locked -p victory-hle: 153/153 unit tests passed (1 ignoredread_bench; includesworkers_read_a_file_through_handles_of_their_own), plusfidelityfx(1/1) andno_dll_planting(1/1).cargo clippy --locked -p victory-hle --tests -- -D warnings(default and--features diagnostics) &cargo xtask policy(191 files ok): clean.Looks clean and ready to merge.
@Dukestar69 on GitHub · 2026-11-26 08:13 UTC · original · approved these changes
Verified against
origin/main(63bcca4):cargo test -p victory-hle --lib modules::dstorage:: -- --test-threads=1: 17/17 passed (1 ignored bench; includingworkers_read_a_file_through_handles_of_their_own).cargo clippy -p victory-hle --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Giving each DirectStorage worker its own file handle avoids contention on shared handles while keeping all existing queue/decompression invariants intact.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@futurepro62 on GitHub · 2026-11-26 18:25 UTC · original
NVIDIA full-suite run, to go with the reports above by Dukestar69, since none of them names a GPU run. Tested exact head
487d01e(on its base842b0cb).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 11 ignored.workers_read_a_file_through_handles_of_their_own.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
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.