dstorage, fs: LEONIDA_IO_TRACE logs every read the title asks for, flushed as it goes (RT-IO-TRACE) #1931

Open
github-bot wants to merge 2 commits from github-bot/gh-1931 into main AGit
Owner

@⁠kawaii-shakal on GitHub · 2026-11-25 16:02 UTC · original
kawaii-shakal:io-trace → main · +218 −0 · 6 files · 2 commits · open

Claimed in the coordination issue as RT-IO-TRACE: #1608

Problem

When a boot stops, --trace names the files the title opened (the first 600 opens), but not what it was reading. Most of the reading goes through DirectStorage requests and ReadFile on files opened long before the stop. In a 1.0.2.1 boot here, the last open came 4 minutes before the device loss.

Change

With LEONIDA_IO_TRACE=<file>, every read is one line, starting with the local time (as the mem-probe lines do):

hh:mm:ss.mmm ds G:\example.rpf off=0x1000 src=4096 dst=16384 zlib=1 bcpack=0 name=-
hh:mm:ss.mmm rf \\?\F:\...\data.bin off=0x1000 size=512
  • ds: each DirectStorage request at EnqueueRequest, with file (or <memory>), file offset, source and destination sizes, zlib, BCPack and the request's name. The name pointer is the title's, so it is copied under SEH.
  • rf: each ReadFile, ReadFileEx and ReadFileScatter on a disk file, with path, offset (the OVERLAPPED's, else the handle's position) and size. The path is asked of the handle every time, because a handle value is reused after a close.
  • On disk at once: every line is flushed, and the file is opened shared for reading (_wfsopen(..., _SH_DENYNO)). The last reads before a crash or device loss are on disk, and the file can be watched during the boot.

It is off by default; without the variable nothing is formatted. runtime/shims/io_trace.h implements it, with hooks in dstorage.cpp and file_system.cpp. docs/boot.md documents the variable.

Tested (Windows 11 Pro 26300, VS 2026 RelWithDebInfo)

  • CTest: io_trace covers positioned, overlapped and reused-handle reads, DirectStorage lines with a good, a bad and a null name pointer, pipes left out, and reading the trace while it is open. dstorage and file_system pass too.
  • Real boot: an earlier build of the same hooks ran during a 1.0.2.1 retail boot on an RTX 5070 Ti. It wrote about 90,000 lines, and the last ones showed the streaming at the world start right before the device loss: anim.rpf, levels.rpf, core_bvh4.rpf and packs.rpf, with all reads stopping at the moment of the loss.

🤖 Generated with Claude Code

**@⁠kawaii-shakal** on GitHub · 2026-11-25 16:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1931) `kawaii-shakal:io-trace` → `main` · +218 −0 · 6 files · 2 commits · open Claimed in the coordination issue as RT-IO-TRACE: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608 ### Problem When a boot stops, `--trace` names the files the title opened (the first 600 opens), but not what it was reading. Most of the reading goes through DirectStorage requests and `ReadFile` on files opened long before the stop. In a 1.0.2.1 boot here, the last open came 4 minutes before the device loss. ### Change With `LEONIDA_IO_TRACE=<file>`, every read is one line, starting with the local time (as the `mem-probe` lines do): ``` hh:mm:ss.mmm ds G:\example.rpf off=0x1000 src=4096 dst=16384 zlib=1 bcpack=0 name=- hh:mm:ss.mmm rf \\?\F:\...\data.bin off=0x1000 size=512 ``` - **`ds`:** each DirectStorage request at `EnqueueRequest`, with file (or `<memory>`), file offset, source and destination sizes, zlib, BCPack and the request's name. The name pointer is the title's, so it is copied under SEH. - **`rf`:** each `ReadFile`, `ReadFileEx` and `ReadFileScatter` on a disk file, with path, offset (the `OVERLAPPED`'s, else the handle's position) and size. The path is asked of the handle every time, because a handle value is reused after a close. - **On disk at once:** every line is flushed, and the file is opened shared for reading (`_wfsopen(..., _SH_DENYNO)`). The last reads before a crash or device loss are on disk, and the file can be watched during the boot. It is off by default; without the variable nothing is formatted. `runtime/shims/io_trace.h` implements it, with hooks in `dstorage.cpp` and `file_system.cpp`. `docs/boot.md` documents the variable. ### Tested (Windows 11 Pro 26300, VS 2026 RelWithDebInfo) - **CTest:** `io_trace` covers positioned, overlapped and reused-handle reads, DirectStorage lines with a good, a bad and a null name pointer, pipes left out, and reading the trace while it is open. `dstorage` and `file_system` pass too. - **Real boot:** an earlier build of the same hooks ran during a 1.0.2.1 retail boot on an RTX 5070 Ti. It wrote about 90,000 lines, and the last ones showed the streaming at the world start right before the device loss: `anim.rpf`, `levels.rpf`, `core_bvh4.rpf` and `packs.rpf`, with all reads stopping at the moment of the loss. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
When a boot stops, the startup trace names the files the title opened, but most of its reading goes
through DirectStorage requests and ReadFile on files it opened long before. With LEONIDA_IO_TRACE=<file>,
each DirectStorage request (file, offset, sizes, zlib/BCPack, request name) and each ReadFile, ReadFileEx
or ReadFileScatter on a disk file (path, offset, size) is one line with the local time.

The line is flushed at once into a file shared for reading, so the last reads before a crash are on disk
and can be watched while the game runs. Paths are asked of the handle each time, because a handle value
is reused after a close. io_trace_test covers positioned, overlapped and reused-handle reads, DirectStorage
lines with good and bad name pointers, and pipes being left out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflict resolution assisted by Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:11:40 +00:00
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/1931/head:github-bot/gh-1931'
git switch 'github-bot/gh-1931'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1931'
git switch 'github-bot/gh-1931'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1931'
git switch 'github-bot/gh-1931'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1931'
git switch 'main'
git merge --squash 'github-bot/gh-1931'
git switch 'main'
git merge --ff-only 'github-bot/gh-1931'
git switch 'main'
git merge 'github-bot/gh-1931'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.