DirectStorage: workers read a file through a handle each #2904

Open
github-bot wants to merge 1 commit from github-bot/gh-2904 into main AGit
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 23:32 UTC · original
0xkn0wh3r3:hle/dstorage-handle-per-worker → main · +182 −7 · 1 files · 1 commits · open

What

Each DirectStorage worker now reads a file through its own handle instead of the one handle the title's OpenFile made. A worker makes its handle with ReOpenFile the 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=0 reads 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:

one handle a handle each
title archive, not in the file cache (the fork's RX 7900 XTX machine) 185 MB/s 990 MB/s
2 GiB file in the file cache (this machine, read_bench) 4.2 GB/s 6.6 GB/s

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 default handles mode. Left out: its overlapped and unbuffered direct modes, 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 test workers_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

  • Not run with the title on this machine. I couldn't measure the uncached rate here (the benchmark file sat in the file cache), so the 185 → 990 MB/s figure is the fork's.
**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 23:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/2904) `0xkn0wh3r3:hle/dstorage-handle-per-worker` → `main` · +182 −7 · 1 files · 1 commits · open ## What Each DirectStorage worker now reads a file through its own handle instead of the one handle the title's `OpenFile` made. A worker makes its handle with `ReOpenFile` the 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=0` reads 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: | | one handle | a handle each | |---|---|---| | title archive, not in the file cache (the fork's RX 7900 XTX machine) | 185 MB/s | 990 MB/s | | 2 GiB file in the file cache (this machine, `read_bench`) | 4.2 GB/s | 6.6 GB/s | Nothing here depends on the GPU vendor. ## Where it comes from From the avatarmanz/VIctory-7900XTX fork, commit [`fbc1830`](https://github.com/avatarmanz/VIctory-7900XTX/commit/fbc183085801939cac7b469eb0ce5956d8e0377f). This PR takes only the fork's default `handles` mode. Left out: its `overlapped` and unbuffered `direct` modes, 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 test `workers_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 - Not run with the title on this machine. I couldn't measure the uncached rate here (the benchmark file sat in the file cache), so the 185 → 990 MB/s figure is the fork's.
Every worker read a file through the one handle the title's open made.
That handle is opened for synchronous reads, and the host does the reads
of such a handle one after the other, so the workers queued behind each
other on every file. Each worker now reads through a handle of its own,
made from the title's with ReOpenFile when it first reads that file (the
title's handle if the host makes none).

48 KiB reads at random, 24 threads: 185 MB/s through one handle and
990 MB/s through a handle each, from an archive not in the file cache
(the fork's measurement); from the cache on this machine, 4.2 GB/s and
6.6 GB/s (read_bench, ignored, on any file named by VICTORY_BENCH_FILE).
VICTORY_DSTORAGE_HANDLES=0 reads through the title's handle alone, as
before.

From avatarmanz/VIctory-7900XTX fbc1830 (its handles mode; the
overlapped and unbuffered modes and the xmem lock changes are left out).

Co-authored-by: local <local@localhost>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:17:09 +00:00
Author
Owner

@⁠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 with ReOpenFile from the title's handle (Files::read_at). If reopening fails it falls back to the title's handle, and VICTORY_DSTORAGE_HANDLES=0 restores 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. CI check passes.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 02:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2904#issuecomment-7180675129) <!-- victory-triage v1 head=487d01e06a3b244f43bd3a8ca7da0d51feb73097 verdict=merge-candidate at=2026-11-26T02:18:28Z --> 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 with `ReOpenFile` from the title's handle (`Files::read_at`). If reopening fails it falls back to the title's handle, and `VICTORY_DSTORAGE_HANDLES=0` restores 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. CI `check` passes. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2904/head:github-bot/gh-2904'
git switch 'github-bot/gh-2904'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2904'
git switch 'github-bot/gh-2904'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2904'
git switch 'github-bot/gh-2904'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2904'
git switch 'main'
git merge --squash 'github-bot/gh-2904'
git switch 'main'
git merge --ff-only 'github-bot/gh-2904'
git switch 'main'
git merge 'github-bot/gh-2904'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2904
No description provided.