dstorage, fs: LEONIDA_IO_TRACE logs every read the title asks for, flushed as it goes (RT-IO-TRACE) #1931
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1931
Loading…
Reference in a new issue
No description provided.
Delete branch "io-trace"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as RT-IO-TRACE: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7167534627
Problem
When a boot stops,
--tracenames the files the title opened (the first 600 opens), but not what it was reading. Most of the reading goes through DirectStorage requests andReadFileon 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 themem-probelines do):ds: each DirectStorage request atEnqueueRequest, 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: eachReadFile,ReadFileExandReadFileScatteron a disk file, with path, offset (theOVERLAPPED'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._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.himplements it, with hooks indstorage.cppandfile_system.cpp.docs/boot.mddocuments the variable.Tested (Windows 11 Pro 26300, VS 2026 RelWithDebInfo)
io_tracecovers 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.dstorageandfile_systempass too.anim.rpf,levels.rpf,core_bvh4.rpfandpacks.rpf, with all reads stopping at the moment of the loss.🤖 Generated with Claude Code
Verified on Windows 11 (
10.0.26200.9974) with MSVC19.44.35228(x64,/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2) againstmaind48a957bb+a6e0360f44(claim#2570#issuecomment-7238954420):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); opensLEONIDA_IO_TRACEwith_SH_DENYNO, flushes timestampeddsandrfread lines under a mutex, queriesGetFinalPathNameByHandleWper disk handle, and guardsrequest.Namereads with__try/__except.check_no_game_data.py,test_docs_encoding,test_docs_links, andLEONIDA_IO_TRACEenv-var doc coverage all pass.d48a957bb+ PR test):io_trace_test.cppfails to build (rc=2,fatal error C1083: Cannot open include file: 'io_trace.h': No such file or directory).d48a957bb+a6e0360f44merge): Auto-merges cleanly across all 4 modified files (rc=0), compilesio_trace_test.exewith0warnings under/W4 /permissive-and passes (io_trace: positioned, overlapped and DirectStorage lines, written through and shared for reading,rc=0), and builds/passes fulldstorage_test.exe(rc=0) while emitting2,855live flushedds/rftrace lines underLEONIDA_IO_TRACE.AI-assisted.
With clang-cl, the new
io_tracetest crashes instead of catching the unreadable name:wine: Unhandled page fault on read access to 0000000000000010, inrt::io_trace::copy_name(runtime/shims/io_trace.h:70) called fromio_trace_test.cpp:60,safe_name(reinterpret_cast<const char*>(16)). Fails 3/3 runs (MEASURED; Apple M3, macOS 26.5.1, Wine 11.0, clang-cl cross-build, head29141b471merged ontomainef02e9a9b).runtime/CMakeLists.txtsays why next todstorage.cpp: "These sources use __try to handle access violations. MSVC always catches them; clang-cl needs asynchronous exceptions".dstorage.cpp, the runtime file that callssafe_name, already gets/EHathere, so the runtime side is covered; the newio_trace_testtarget does not. With the same option on it,the test passes, 3/3 runs (MEASURED, same machine). With MSVC it passes as is, which matches the MSVC run above; I have not run MSVC myself.
Not checked by a second agent or human yet.
AI-assisted (Claude Code).
Thanks, confirmed and fixed in 7d571f75:
io_trace_testnow gets$<$<CXX_COMPILER_ID:Clang>:/EHa>as you suggested, and the comment oncopy_namesays a caller needs it under clang-cl (dstorage.cpp, the only caller in the runtime, already has it through its source property, so the shim itself was not affected). Reproduced here with clang-cl 21 + xwin under Wine, same compile flags as the CMake target: without/EHa3/3 runs end inUnhandled page fault on read access to 0000000000000010, with it 3/3 pass. MSVC is unchanged (the expression is empty there).AI-assisted (Claude Code); I ran the builds and checked the results.
Generated by Claude Code
#1931 | head 7d571f75b7e126e69f8eb61d151ac7f11d866803 (merged cleanly onto origin/main c8bf0e7b65) | Windows 11 (10.0.26200.9974), MSVC 19.44.35228 (x64), Python 3.12.10 | AI-assisted: yes
Summary — PASS (Re-verification of updated head
7d571f75b7e1)Re-verified
7d571f75b7e126e69f8eb61d151ac7f11d866803merged cleanly ontoorigin/main(c8bf0e7b6568f471b42540010e335ca6413d4c58,git merge-tree --write-treeexit0) on native Windows 11 (x64).Red -> Green Verification
origin/mainc8bf0e7b65):runtime/shims/io_trace.handruntime/test/io_trace_test.cppare absent onorigin/main, and neitherfile_system.cppnordstorage.cppemits unbufferedLEONIDA_IO_TRACErecords.origin/main+#1931):MSVC 19.44.35228,/std:c++20 /O2 /MD /EHsc /W4 /permissive- /utf-8 /link /OPT:NOREF):runtime/test/io_trace_test.cppcompiled cleanly (0warnings) and passed in0.075s(rc=0:io_trace: positioned, overlapped and DirectStorage lines, written through and shared for reading), covering unset/emptyLEONIDA_IO_TRACE,LEONIDA_IO_TRACE=-(stderr),FILE_SHARE_READconcurrent open while tracing is active, positioned &OVERLAPPEDReadFilelines (rf), DirectStorage file/memory/unreadable-name request lines (ds), unbuffered write-through across abruptTerminateProcesswithoutatexit/fflush, and multi-threaded atomicWriteFileline integrity.MSVC 19.44.35228,/c /std:c++20 /O2 /MD /EHsc /W4 /permissive- /utf-8):runtime/shims/file_system.cppandruntime/shims/dstorage.cppboth compiled cleanly withio_trace.hwired in (rc=0,0warnings).python tests/test_ctest_registration.py->OKdocs/boot.mdrelative-link & anchor check ->0issuesVerified by OreoFR
aa918e5d9+ PR head7d571f75bctest -R ^io_trace$io_trace.his added by the PR)d3d12_queue_handover_shared_queuefailed once under load and passes on a serial rerun)Note: shares
runtime/CMakeLists.txtwith the open #2566; a rebase may be needed if #2566 lands first.AI-assisted (Claude Code, Claude Opus 5.5).
Merged. Tested by @OreoFR on head 7d571f75b (RTX 4070 Laptop 8GB, Windows 11): io_trace ctest: new test does not compile on main; passes with PR, full ctest no new failure. The CI jobs that are red on this head were also red on main at the time of the run. Thanks @kawaii-shakal!
AI-assisted: yes