runtime: write opt-in time lines to the stand-in log (X2W_LOG_TIME) #3563
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3563
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3561"
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?
@Leyukaka on GitHub · 2026-11-30 06:58 UTC · original
Leyukaka:arch-review-log-time→main· +143 −1 · 6 files · 3 commits · merged 2026-11-30 17:26 UTCChange
Most stand-in log lines carry no time. After a start-up run, such a line in
stderr.txtcannot beplaced against the launcher's
events.txt, which is timed, except by interpolating between thefew lines that print a time.
X2W_LOG_TIME=1(opt-in, read once per module) makes the stand-ins writebefore a log line when the same module wrote no such line in the last 100 ms. The value is
x2w_local::process_seconds()(seconds since the process was created), printed with threedecimals. It goes to stderr and
X2W_TRAP_LOGlike any other line.triage_run.py(fullmatch) andlive_view.py(startswith) match lines from their firstcharacter.
1, nothing is written; the cost is one cachedtest per log line.
x2w_local::logf, and the two locallogfunctions insrc/startup_stubs/d3d12_xs_device.cppandsrc/startup_stubs/xcrdapi.cpp(one line each).x2w-traplines (x2w_trap::record) andx2w-teardownlines (d3d12_teardown.h) get none.GetLastErrorvalue is kept.This is an independent diagnostic change. No shared interface changes; no existing log line,
manifest or cache key changes.
Verification
Base:
mainat2ff74a6ac. Head:a7078e3f9. Windows, MSVC 19.44, cleandevbuild.Result on
a7078e3f9: build exit 0 (d3d12_xs.dllandXCRDAPI.dlllink);startup_local_log_timePassed,startup_local_log_time_controlPassed, 2/2. The control runsthe same phase with
X2W_LOG_TIME=0and passes only on the output lineFAIL the first logged line follows an x2w-time line(PASS_REGULAR_EXPRESSION).The test redirects stderr to a file and checks: the first line is an
x2w-timeline; each onereads
x2w-time <seconds> swith exactly three decimals; the seconds never go back; the 52logged lines are present and unchanged; stderr and
X2W_TRAP_LOGhold the same bytes; a burst of50 lines shares
x2w-timelines; a line logged 250 ms later follows a new one at least 0.2 slater;
GetLastErroris kept.Existing tests, on the first commit
73f7292cf(the second commit changes only a comment inlocal_log.h, the test and its registration):Result: 8 Passed, 1 Not Run.
startup_local_log_cache_failure_controldid not run because itstarget
startup_local_log_cache_failure_checkwas not in the build list above; it was notchecked. The existing tests were not run again on
a7078e3f9.Mutations, each built and run with the first commands:
logfwithout itstime_anchor();call:startup_local_log_timefails(
the first logged line follows an x2w-time line).now >= due &&->true &&(no 100 ms limit):startup_local_log_timefails(
x2w-time lines are limited to one per 100 ms).time_anchorwithout its stderr write:startup_local_log_timefails(
stderr carries the same lines).X2W_LOG_TIMEis off:startup_local_log_time_controlfails(required FAIL line not found).
Not covered: the one-line call sites in
d3d12_xs_device.cppandxcrdapi.cpp(the test driveslogfonly; they are built, not run), the per-module window when several stand-ins log at once,logging from several threads, and
triage_run.py/live_view.pyon a log that containsx2w-timelines.Evidence and follow-up
The new test phase (
startup_local_log_check --phase log-time) uses only synthetic lineswritten by the test itself; no fixture file is added. Its CTest registration is in a new
fragment,
tests/cmake/startup_local_log_time.cmake, soCMakeLists.txtis not edited.Assumptions:
process_seconds()uses the system clock (GetSystemTimeAsFileTime), so its resolution is thesystem timer tick and a clock change during a run moves the values.
GetTickCount64step) later than thex2w-timelinebefore it only for lines from one thread. Across threads the exchange can race, and stderr and
X2W_TRAP_LOGcan order lines differently.Documentation: one row for
X2W_LOG_TIME=1in the switch table ofdocs/startup-runtime.md,with the reproduction command.
Possible follow-up for anyone: the three copies of the line writer (
local_log.h,d3d12_xs_device.cpp,xcrdapi.cpp) could become one.Checklist
@lukaslw-lab on GitHub · 2026-11-30 09:07 UTC · original · approved these changes
Reviewed
a7078e3fby reading the diff; not built or run.Verdict: approve. Opt-in, off by default, and every existing line stays byte for byte the same. No MUST.
x2w_trap::record(trap.h:153), which is excluded on purpose. The only other stderr output is thestd::fprintflines of the opt-inx2w-cache-probetrace (d3d12_xs_device.cpp:7011-7081), which get nox2w-timeline. That is worth one clause in the doc row, since it says "the stand-ins write".time_anchoris an inline function in a header, so itsstatic nextis one object per DLL across translation units, which gives the per-module window the doc describes.GetLastErroris saved and restored around the anchor inlogfand in both locallogfunctions.nextlets exactly one thread write an anchor per window, and a losing thread just logs its line. That matches the documented "across threads the order can differ".triage_run.pynorlive_view.pyreads the last line or a neighbouring line, so an extrax2w-timeline is just one more unmatched line for them.startup_triage_run_check.pyfailing on "an output UAV interval exceeds the D3D12 buffer view element limit" missing fromCOMPUTE_DISPATCH_REASONS. That is main's failure (#3509), not this change.Tests:
startup_local_log_timechecks the first anchor, the three-decimal format, monotonic seconds, unchanged lines, identical stderr andX2W_TRAP_LOGbytes, the 100 ms limit andGetLastError. TheX2W_LOG_TIME=0control and the four mutations show each check can fail. CI did not run them: they are not in theprpreset's list.@R0Y00 on GitHub · 2026-11-30 17:22 UTC · original · approved these changes
Reviewed the main-updated head. The added timestamp calls are opt-in and preserve the normal logging routes and GetLastError. Built the exact-head
tests/startup_local_log_check.cppwithcl.exe /nologo /EHsc /std:c++17 /Isrcon Windows.X2W_LOG_TIME=1with--phase log-timepassed all 10 checks,X2W_LOG_TIME=0hit the expected first-anchor assertion, and the normal fixture passed 104 cases. Waiting for hosted checks on this head.