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

Open
opened 2026-11-26 21:19:28 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1931
Author: @kawaii-shakal
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: io-trace


📝 Commits (2)

  • 9439e60 dstorage, fs: LEONIDA_IO_TRACE logs every read the title asks for, flushed as it goes (RT-IO-TRACE)
  • a6e0360 Merge upstream main into io-trace

📊 Changes

6 files changed (+218 additions, -0 deletions)

View changed files

📝 docs/boot.md (+7 -0)
📝 runtime/CMakeLists.txt (+7 -0)
📝 runtime/shims/dstorage.cpp (+15 -0)
📝 runtime/shims/file_system.cpp (+4 -0)
➕ runtime/shims/io_trace.h (+100 -0)
➕ runtime/test/io_trace_test.cpp (+85 -0)

📄 Description

Claimed in the coordination issue as RT-IO-TRACE: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7167534627

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1931 **Author:** [@kawaii-shakal](https://github.com/kawaii-shakal) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `io-trace` --- ### 📝 Commits (2) - [`9439e60`](https://github.com/ubiquitarianism/leonida/commit/9439e6083dd23bce6c8d4021ccc0d3a21644942d) dstorage, fs: LEONIDA_IO_TRACE logs every read the title asks for, flushed as it goes (RT-IO-TRACE) - [`a6e0360`](https://github.com/ubiquitarianism/leonida/commit/a6e0360f44fb836e9bb40266fb4ebf76f6d331a1) Merge upstream main into io-trace ### 📊 Changes **6 files changed** (+218 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/boot.md` (+7 -0) 📝 `runtime/CMakeLists.txt` (+7 -0) 📝 `runtime/shims/dstorage.cpp` (+15 -0) 📝 `runtime/shims/file_system.cpp` (+4 -0) ➕ `runtime/shims/io_trace.h` (+100 -0) ➕ `runtime/test/io_trace_test.cpp` (+85 -0) </details> ### 📄 Description Claimed in the coordination issue as RT-IO-TRACE: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7167534627 ### 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#1937
No description provided.