Skip to content

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

Open
kawaii-shakal wants to merge 3 commits into
ProjectLeonida:mainfrom
kawaii-shakal:io-trace
Open

kawaii-shakal wants to merge 3 commits into
ProjectLeonida:mainfrom
kawaii-shakal:io-trace

Conversation

@kawaii-shakal

@kawaii-shakal kawaii-shakal commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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

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

…ushed as it goes (RT-IO-TRACE)

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 <noreply@anthropic.com>
Conflict resolution assisted by Codex.
@zmasi

zmasi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Verified on Windows 11 (10.0.26200.9974) with MSVC 19.44.35228 (x64, /std:c++20 /EHsc /W4 /permissive- /utf-8 /O2) against main d48a957bb + a6e0360f44 (claim #2570#issuecomment-7238954420):

  • Line-by-line diff audit: Clean (docs/boot.md, runtime/CMakeLists.txt, runtime/shims/dstorage.cpp, runtime/shims/file_system.cpp, runtime/shims/io_trace.h, runtime/test/io_trace_test.cpp); opens LEONIDA_IO_TRACE with _SH_DENYNO, flushes timestamped ds and rf read lines under a mutex, queries GetFinalPathNameByHandleW per disk handle, and guards request.Name reads with __try / __except. check_no_game_data.py, test_docs_encoding, test_docs_links, and LEONIDA_IO_TRACE env-var doc coverage all pass.
  • Red (d48a957bb + PR test): io_trace_test.cpp fails to build (rc=2, fatal error C1083: Cannot open include file: 'io_trace.h': No such file or directory).
  • Green (d48a957bb + a6e0360f44 merge): Auto-merges cleanly across all 4 modified files (rc=0), compiles io_trace_test.exe with 0 warnings under /W4 /permissive- and passes (io_trace: positioned, overlapped and DirectStorage lines, written through and shared for reading, rc=0), and builds/passes full dstorage_test.exe (rc=0) while emitting 2,855 live flushed ds / rf trace lines under LEONIDA_IO_TRACE.

AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants