DirectStorage: report file bytes before decompression #3789

Open
Prime1997 wants to merge 1 commit from upstream-pr/3789 into main
Prime1997 commented 2026-12-03 14:45:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Prime1997 on 2026-12-03T14:45:07Z.


Add opt-in attribution for the bytes DirectStorage reads from each file before decoding. This covers main’s serial and pooled reads, including bytes returned by Windows from its file cache. The activity log keeps the busiest paths and aggregates the rest.

What is in it

  • XCL_DSTORAGE_FILE_IO=1 adds an interval report alongside XCL_ACTIVITY=1.
  • Count bytes returned on partial reads and reset the counters between intervals.
  • This patch instruments main’s existing file paths. #3364 covers worker-owned handles.

Tested

  • Exact head 14cdbf7f9c425714e430fb913be95c4030c426ab on Windows x64.
  • cargo test --locked -p xcl --lib -- --test-threads=1 --nocapture --exact with the partial-read accounting, sequential short-read, and pooled retirement fixtures. 3 passed, 0 failed, 0 ignored, 0 skips. The fixtures used synthetic files.

Regression run

  • The paired retail smoke is pending for this draft.

Not tested

  • Physical SSD transfer attribution, the retail title, and the full workspace suite.

AI use

  • OpenAI Codex (GPT-6) investigated the log, wrote the patch and tests, and ran the targeted checks.

Contributors can use this optional temporary Discord to coordinate testing and compare results.

<!-- greyfinch-sync:ivall/xcl:issue:5628748838 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3789). Originally posted by [Prime1997](https://github.com/Prime1997) on 2026-12-03T14:45:07Z. --- Add opt-in attribution for the bytes DirectStorage reads from each file before decoding. This covers main’s serial and pooled reads, including bytes returned by Windows from its file cache. The activity log keeps the busiest paths and aggregates the rest. **What is in it** - `XCL_DSTORAGE_FILE_IO=1` adds an interval report alongside `XCL_ACTIVITY=1`. - Count bytes returned on partial reads and reset the counters between intervals. - This patch instruments main’s existing file paths. #3364 covers worker-owned handles. **Tested** - Exact head `14cdbf7f9c425714e430fb913be95c4030c426ab` on Windows x64. - `cargo test --locked -p xcl --lib -- --test-threads=1 --nocapture --exact` with the partial-read accounting, sequential short-read, and pooled retirement fixtures. 3 passed, 0 failed, 0 ignored, 0 skips. The fixtures used synthetic files. **Regression run** - The paired retail smoke is pending for this draft. **Not tested** - Physical SSD transfer attribution, the retail title, and the full workspace suite. **AI use** - OpenAI Codex (GPT-6) investigated the log, wrote the patch and tests, and ran the targeted checks. Contributors can use this [optional temporary Discord](https://discord.gg/gK3y7WRRY) to coordinate testing and compare results.
Foniass commented 2026-12-03 17:27:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T17:27:41Z.


merge-check
base: 16c2fd082a
head: 14cdbf7f9c
merge: clean
build: ok
tests: 3019 passed, 0 failed, 56 ignored; 28 skipped, the same as on main
review: 3 medium (below)
performance: 60 s smoke run: 1683 → 1653 frames (98 % of main), peak commit 18505 → 18011 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 231 s there, 0 device removals, 0 crashes, 3.5 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: not yet: it is a draft, and PR description is red; otherwise no blocking finding, the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: Adds an opt-in count (XCL_DSTORAGE_FILE_IO=1, printed with XCL_ACTIVITY) of bytes returned by DirectStorage file reads, per path, on both the serial and the pooled read paths. The reading found the counting correct, partial reads included, and nothing on the default path beyond a None check. Nothing blocks it; the textual conflict with #3364 and the lifetime cap on listed paths should be sorted out.

Medium

  1. Conflicts with #3364 in parallel.rs. #3364 (open, decode workers read on their own handle) rewrites the same read_exact_at call in crates/xcl/src/hle/dstorage/parallel.rs ~431, and a test merge of both onto main conflicts there. Whichever lands second has to rebase. When it does, the worker-owned read in #3364 must pass file.read_bytes too, or pooled reads stop being counted.
  2. Path cap never frees slots. FileReads::counter (dstorage.rs ~546) gives a path its own counter only while fewer than 256 distinct names have ever been opened, and entries are never removed. In a long session every archive opened after the 256th lands in "other paths" for good, so the busiest-paths list can miss the files that matter most. Prune entries that read nothing in line(), or cap the paths kept per interval instead of per process.
  3. No issue link. The description links no issue (Fixes #N / Part of #N).
Checked and fine
  • read_exact_at counts each returned chunk before the EOF or error check, so a short read counts the bytes it got (unit test: 3 + 4 = 7 B with a truncated read)
  • line() resets each per-path counter and the other counter with swap(0), so concurrent adds are not lost, and a second call returns None (tested)
  • The pooled path (completion_event_waits_for_parallel_retirement) and the serial path (sequential_short_read) both assert the exact byte counts, short-read request included
  • Default off: file_reads() is a OnceLock, read_bytes is None, and the read loop costs one branch; host.rs prints the line only inside the existing XCL_ACTIVITY block
  • Merges cleanly onto main; about 120 lines in one commit, one logical change; README documents the new variable
How this was tested
  • Merged onto main 16c2fd08, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 16c2fd08 and on this merge; presents per 2 s at the end: 61 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7386545968 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3789#issuecomment-7386545968). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T17:27:41Z. --- merge-check base: 16c2fd082ae2e96967a2ab553bc2e1032e491f70 head: 14cdbf7f9c425714e430fb913be95c4030c426ab merge: clean build: ok tests: 3019 passed, 0 failed, 56 ignored; 28 skipped, the same as on main review: 3 medium (below) performance: 60 s smoke run: 1683 → 1653 frames (98 % of main), peak commit 18505 → 18011 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 231 s there, 0 device removals, 0 crashes, 3.5 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: not yet: it is a draft, and `PR description` is red; otherwise no blocking finding, the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** Adds an opt-in count (XCL_DSTORAGE_FILE_IO=1, printed with XCL_ACTIVITY) of bytes returned by DirectStorage file reads, per path, on both the serial and the pooled read paths. The reading found the counting correct, partial reads included, and nothing on the default path beyond a None check. Nothing blocks it; the textual conflict with #3364 and the lifetime cap on listed paths should be sorted out. #### Medium 1. **Conflicts with #3364 in parallel.rs.** #3364 (open, decode workers read on their own handle) rewrites the same read_exact_at call in crates/xcl/src/hle/dstorage/parallel.rs ~431, and a test merge of both onto main conflicts there. Whichever lands second has to rebase. When it does, the worker-owned read in #3364 must pass file.read_bytes too, or pooled reads stop being counted. 2. **Path cap never frees slots.** FileReads::counter (dstorage.rs ~546) gives a path its own counter only while fewer than 256 distinct names have ever been opened, and entries are never removed. In a long session every archive opened after the 256th lands in "other paths" for good, so the busiest-paths list can miss the files that matter most. Prune entries that read nothing in line(), or cap the paths kept per interval instead of per process. 3. **No issue link.** The description links no issue (Fixes #N / Part of #N). <details><summary>Checked and fine</summary> - read_exact_at counts each returned chunk before the EOF or error check, so a short read counts the bytes it got (unit test: 3 + 4 = 7 B with a truncated read) - line() resets each per-path counter and the other counter with swap(0), so concurrent adds are not lost, and a second call returns None (tested) - The pooled path (completion_event_waits_for_parallel_retirement) and the serial path (sequential_short_read) both assert the exact byte counts, short-read request included - Default off: file_reads() is a OnceLock, read_bytes is None, and the read loop costs one branch; host.rs prints the line only inside the existing XCL_ACTIVITY block - Merges cleanly onto main; about 120 lines in one commit, one logical change; README documents the new variable </details> <details><summary>How this was tested</summary> - Merged onto main `16c2fd08`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `16c2fd08` and on this merge; presents per 2 s at the end: 61 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3789:upstream-pr/3789'
git switch 'upstream-pr/3789'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3789'
git switch 'upstream-pr/3789'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3789'
git switch 'upstream-pr/3789'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3789'
git switch 'main'
git merge --squash 'upstream-pr/3789'
git switch 'main'
git merge --ff-only 'upstream-pr/3789'
git switch 'main'
git merge 'upstream-pr/3789'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
xcl-dev/xcl!3789
No description provided.