Skip to content

runtime, d3d12: both runtimes write an import call trace, and a tool compares two (RT-CALL-TRACE, D3D12-CALL-TRACE) - #2807

Open
ubiquitarianism wants to merge 9 commits into
mainfrom
rt-call-trace
Open

ubiquitarianism wants to merge 9 commits into
mainfrom
rt-call-trace

Conversation

@ubiquitarianism

Copy link
Copy Markdown
Collaborator

Claimed in the coordination issue as: RT-CALL-TRACE and D3D12-CALL-TRACE (#2570 (comment))

What and why

When gta6rt and leonida.exe stop at different places in the boot, there is no record of which import call they first handled differently. With LEONIDA_CALL_TRACE=<new file> set, both runtimes now record every call through the import tables of the title's image and its DLLs (normal and delay-load) in one shared v1 text format. Unset, nothing changes: wrap returns the import's address and no thunk block is allocated.

  • tools/call_trace_rules.def: the rules both runtimes read (gta6rt includes it, leonida-loader parses it), so the two traces are comparable. Stack walks and RtlCaptureContext2 are entry-only (a wrap frame would end the title's stack walk at the stub), and __vdecl vector math is skipped (its YMM arguments are not kept by the stubs).
  • Each import slot gets a 24-byte thunk to one of two common stubs: entry-only (E line, real return address) or wrapped (C and R lines with the return class). The stubs are registered for unwinding; the entry stub's unwind range ends before its final jump.
  • The file is written through 4 MiB mapped views, capped by LEONIDA_CALL_TRACE_MAX_MB (default 4096). The writer lock is taken with a bound of about 10 ms; a record that cannot get it is dropped and the next one writes # dropped N.
  • gta6rt shims read their caller through RT_CALLER(), which sees through the wrap frame.
  • tools/call_trace_diff.py pairs the two traces' threads (main first, then by start address and common call prefix), aligns each pair's calls and reports the first divergences: calls one side never makes, different return classes, different call counts, threads on one side only and calls still open at the end. It streams its input (two synthetic 1M-call traces: 14.0 s, 336 MB peak).

Not run in game.

Tested

Windows 11 (26200), Visual Studio 18 (2026) MSVC, AMD Radeon RX 6800 (driver 32.0.21030.2001), rebased on main at 66b5d0433:

  • cargo test --profile diag -p leonida-loader --lib -- call_trace: 29 passed
  • runtime RelWithDebInfo build; ctest: 205 of 205 passed, 2 disabled (gameinput, gameinput_script, no SDL3 here)
  • python -I tests/test_call_trace_diff.py, tests/test_call_trace_rules.py: OK; python -m compileall -q tools tests: OK
  • scripts/check_no_game_data.py on the changed files: OK

One full ctest -j 8 run failed call_trace (and the unrelated windows_crash_monitor); both passed alone and in the next full -j 8 run. case_dropped_record checks that a dropped call takes under 100 ms of wall time, which a machine running eight test jobs can exceed. The failing run's output was not kept, so that cause is likely, not confirmed.

Rules both runtimes read (gta6rt includes it, leonida-loader parses it) so their
LEONIDA_CALL_TRACE traces are comparable. Not run in game.
Reads the LEONIDA_CALL_TRACE v1 traces of gta6rt and leonida.exe, pairs threads
(main; then by start address and common call prefix), aligns each pair's calls
and reports the first divergences: calls one side never makes, different return
classes, different call counts, threads on one side only, and the calls still
open at the end of each thread. Streams the input (about 150 bytes per call).

Tested: python -I tests/test_call_trace_diff.py (Ran 76 tests, OK);
tests/test_text_write_line_endings.py OK; two synthetic 1M-call traces:
14.0 s / 336 MB peak. Not run in game.
…ALL_TRACE)

Every IAT slot of the title image and its DLLs (normal and delay) is traced by
import identity when LEONIDA_CALL_TRACE=<new file> is set (size cap
LEONIDA_CALL_TRACE_MAX_MB, default 4096); unset, wrap returns the address
unchanged and no thunk block is allocated. Per-import 24-byte thunk into the
common stub (entry-only E / wrapped C+R), writer and rules as in
tools/call_trace_rules.def (hash in the header). New leonida-loader call_trace
module with 23 tests (stub bytes against their assembler source, 20 integer
args, floats, struct return, last error, panic through the stubs, nesting,
classes, 4 threads across a view boundary, killed child, size cap).

Tested: cargo test -p leonida-loader: 96 + 2 + 1 passed; cargo test -p leonida-hle:
211 passed, 2 ignored; build -p leonida --profile diag --features diagnostics,mimalloc
ok. Not run in game.
LEONIDA_CALL_TRACE=<path> (cap LEONIDA_CALL_TRACE_MAX_MB, default 4096) records every call through the import
tables of the main image and the title DLLs in the shared v1 format, with the rules of tools/call_trace_rules.def.
Each import slot gets a 24-byte thunk to one of two common stubs (entry-only: jump, real return address; wrap: frame,
C and R lines), registered with RtlAddFunctionTable. The file is created new, written through 4 MiB mapped views.
Shims read their caller through RT_CALLER(), which sees through the wrap frame; unset, wrap() returns its target.
runtime/test/call_trace_test.cpp (ctest call_trace) and tests/test_call_trace_rules.py cover it.

Tested: full runtime build (RelWithDebInfo) passes; ctest on the 149 non-GPU tests that cannot open a Vulkan device or window: 100% tests passed, 0 tests failed out of 149; python tests of the rules, line endings, docs env vars pass. Not run in game.
…s, unset-switch no-ops)

Tested: cargo test -p leonida-loader: 99 + 2 + 1 passed; cargo test -p leonida-hle:
211 passed, 2 ignored; build -p leonida --profile diag --features diagnostics,mimalloc
ok. Not run in game.
…skip __vdecl math

From the second review: a wrap frame would end the title's stack walks at the stub
and SVML vector math passes arguments in YMM registers the stubs do not keep.
Not run in game.
Tested: Ran 79 tests in 22.512s ... OK (test_call_trace_diff.py); Ran 3 tests in 15.268s ... OK (test_text_write_line_endings.py). Not run in game.
…ed writer lock)

Tested: cargo test -p leonida-loader: 102 + 2 + 1 passed; cargo test -p leonida-hle:
211 passed, 2 ignored; build -p leonida --profile diag --features diagnostics,mimalloc
ok. Not run in game.
…lock, caller in helpers)

The entry stub's RUNTIME_FUNCTION now ends before its final jmp [r10], so a stack walk there finds the return
address. The writer lock is taken with a 10 ms bound: a dropped record is counted and the next one writes
`# dropped <count>`. The next view is mapped ahead so a failed remap still ends the file in `# truncated`.
title_free_impl and create_file_w take the caller from the exported shim; a failed VirtualProtect deletes the
function table; pe_loader builds the module name only when tracing. Rules: 205, hash 873cd3bb78a70bc5.

Tested: full runtime build passes; ctest on the 149 non-GPU tests: 100% tests passed, 0 tests failed out of 149; xmem alone: 1/1 passed; xs_proxy_mock|xmem_: 100% tests passed, 0 tests failed out of 13; python -I tests/test_call_trace_rules.py OK. Not run in game.
@OreoFR

OreoFR commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Verified by OreoFR on macOS 27.2.1, Apple M5, head e2572082c, main b7a1be296. Partial check: the Python tools, plus a Windows type-check of the D3D12 side. leonida-loader does not build natively on macOS (it uses windows_sys and core::arch::x86_64, on main as well), and the runtime side (gta6rt, runtime/shims/call_trace*.h, call_trace_test.cpp) was not built here.

MEASURED

  • git merge-tree onto main gives no conflicts.
  • Python, red (main + only this PR's tests): test_call_trace_diff.py errors at import (tools/call_trace_diff.py doesn't exist on main), and test_call_trace_rules.py fails. Green (main + this PR): test_call_trace_diff.py 79 passed, 42 subtests passed (10.9 s); test_call_trace_rules.py 9 passed.
  • cargo check --target x86_64-pc-windows-msvc (no MSVC; the cc build steps are replaced with stand-ins), main vs main + this PR, exit 0 on both sides. The sorted warning lists are identical: -p leonida-loader --tests 0 / 0 (this compiles call_trace.rs and its 1,474-line test module), -p leonida 19 / 19 (run.rs).

READ IN CODE

  • The switch exists and is opt-in. In d3d12/apps/leonida/src/run.rs, call_trace::open_from_env()? runs only when LEONIDA_CALL_TRACE is set, and add_module is called for the image, the title DLLs and the late-loaded DLLs. With the switch unset, add_module is called but (per the description) wrap returns the import's address unchanged and no thunk block is allocated. I didn't run that path, so "no change when unset" is from the code and your description, not measured here.
  • open_from_env()? propagates an error, so a LEONIDA_CALL_TRACE path that already exists stops the title from starting, as the comment says ("the file must be new").

ASSUMED

  • The Rust unit tests (29), ctest 205/205, and the case_dropped_record flake you describe are from your Windows run. Not reproduced. Not run in game, as you say.

AI-assisted: Claude Code

@fiestorra

Copy link
Copy Markdown
Contributor

Verified in all three layers it touches, on Windows, and none of them fails.

main d920d850d plus this head:

Python (the two suites it adds):

python -m pytest tests/test_call_trace_diff.py tests/test_call_trace_rules.py -q
  88 passed, 42 subtests passed   (25.45 s)

C++:

cmake --build runtime/build --target call_trace_test     exit 0
runtime\build\call_trace_test.exe                        exit 0
  error: LEONIDA_CALL_TRACE: the file already exists; the call trace only creates a new file
  error: LEONIDA_CALL_TRACE_MAX_MB: expected a whole number of MiB from 1 to 1048576
  error: LEONIDA_CALL_TRACE: cannot create the file (error 3)
  call_trace_test: ok

Those three error lines are the test doing its job - it drives the refusal paths and prints them - and call_trace_test: ok is the verdict.

Rust (six files under d3d12/):

cargo test --workspace       exit 101
  ... the workspace's own suites all `ok` (403 passed / 5 ignored in the largest)
  FAILED: xtask policy::tests::repository_passes_policy

That failure is not this pull request's: it is main failing its own asset policy on two files over 640 KiB (leonida-gpu/src/host.rs, leonida-shader/src/emit/lower.rs), which #2815 fixes, and it fails identically on main alone. Everything else in the workspace is green with this change, including the crates it touches.

What I could not test: a real import call trace from a title - that needs the game and the two runtimes the note describes, and this is a 24 GB desktop, not the 8 GB laptop the trace was written for. The diff tool and its rules are what the 88 Python tests cover, and they are green.

One thing worth saying about the size: +6,558 across 23 files is a lot to review, and the shape helps - 795 lines of C++ test, 1,189 of Python tests, 731 of tool, 236 of rules, and the rest is the runtime hooks the notes describe. The tests are two thirds of it, which is the right ratio for a diagnostic that has to be trusted.

AI-assisted: yes - DeepSeek v4.1 (flash), which ran all three layers on the machine above.

Written with an AI assistant.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tracer is sound. Off costs nothing — wrap returns the target and allocates no thunk (call_trace.h:700) — and on is one atomic per call plus a bounded writer lock, with the line formatted and sequenced inside the lock (:442-520), so lines cannot interleave. The stream is capped (:361, call_trace.rs:796) and goes through 4 MiB mapped views, so RAM does not grow with the trace. Every test I ran passes: call_trace ctest, 79 test_call_trace_diff tests, 9 test_call_trace_rules, 29 Rust call_trace tests. Mutation: removing the return comparison in compare_thread (tools/call_trace_diff.py:519) fails 12 tests, so the diff's core is genuinely pinned.

One unbounded path, and it is a real inconsistency between the two runtimes:

  • call_trace.rs:865 treats an unparsable or 0 LEONIDA_CALL_TRACE_MAX_MB as 4096 silently, and mb.saturating_mul(1 << 20) turns a parseable but huge value into no cap at all. gta6rt refuses both cases with a message and exit 2, and its test asserts that (call_trace.h:577-590). Make the Rust parser match the C++ one, and never let a value saturate to "unbounded".

Two more, in the tool:

  • rules differ, truncated=yes and a missing header only warn and can still exit 0 (test_differing_rules_print_a_warning asserts exactly that). A script reads 0 as "identical", so give those a distinct exit code — a rules mismatch means the traces are not comparable at all. A warning when both sides report the same stack= would also help.
  • case_dropped_record's wall-clock < 100 ms is load-dependent (the body already saw it fail under -j8); assert the drop count and the # dropped ordering, keep the timing as a print.

Documentation worth one line in the README: the trace records identity and the return class, no arguments and no strings — so a divergence that lives only in an argument is invisible to the diff (a hash of the first argument qwords would be safe, unlike strings). And RT_CALLER's 0x140 duplicates the stub's 0x138 frame by hand — a static_assert against the blob would keep them tied.

@Neutron-0

Copy link
Copy Markdown

A heads-up for this pull request: the page of D3D12 switches (d3d12/docs/switches.md) is written by tools/d3d12_switches.py from the sources of d3d12/, and 3 names this pull request reads are not on the page yet: LEONIDA_CALL_TRACE, LEONIDA_CALL_TRACE_MAX_MB, LEONIDA_CT_CHILD.

Nothing checks that today, so the page has drifted before (it was a name behind when this was measured). A test that checks it is waiting to be opened (DOCS-SWITCHES-PAGE-CHECK), and it would make this pull request's CI red until the page is written again. One command does that:

python -I tools/d3d12_switches.py --out d3d12/docs/switches.md

It writes the page with the names in it and nothing else; the diff is the new rows.

@merzleckeier

Copy link
Copy Markdown
Contributor

Confirmed the Rust/C++ trace-cap mismatch under Wine on e2572082c + 6c7f6b60c. The stock C++ call_trace_test passed, as did the 79 diff tests and 9 rule tests. In a separate synthetic Rust child-process regression, a cap of 0 returned Ok(true) instead of refusing the setting before creating the trace. A local change to validate the configured range and format before opening the file made the new test pass for 0, 12x, 1048577 and whitespace-prefixed 1. All 31 Rust call_trace::tests passed in that build, including the existing 1 MiB truncation check. I used temporary trace files only.

AI-assisted with OpenAI Codex.

@MoonEyes

MoonEyes commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).

Could you, or anyone with a working setup, post a run report on the current head merged onto current main:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone for comparison, if you can.

Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.

AI-assisted (Claude Code).

@Kal0s-design

Copy link
Copy Markdown
Contributor

Ran natively on Windows 11, head e2572082c merged into current main (83046a713, clean merge). This adds what the thread does not have yet: the two writers side by side on the same synthetic calls, cost per call, contention, a kill under load, and malformed input to the tool. The cap parsing and the exit codes for missing headers or differing rules are already covered above, so I left them out.

Stock tests (measured)

Suite Result
cargo test -p leonida-loader (whole crate, dev profile) 119 passed, plus 2 + 1 in the other targets
call_trace filter (dev profile) 29 passed
call_trace_test.cpp, built on its own with MSVC (the CMake target's warning and define flags, plus /std:c++20 /O2) call_trace_test: ok, 3 of 3 runs
python -I tests/test_call_trace_diff.py / test_call_trace_rules.py (unittest) 79 OK / 9 OK
cargo clippy -p leonida-loader -p leonida --all-targets --features leonida/diagnostics no warning in call_trace.rs, windows.rs or run.rs

1. The two runtimes write different names for the same import (reading, then measured)

call_trace.rs caps module!function at 160 bytes and a module name in caller/start at 47. call_trace.h caps them at 172 (Site::name) and 31 (ModEntry::name). Also, for an import bound to an unimplemented stub, Rust skips classify (wrap: bind == Unimpl goes straight to entry-only), while C++ calls decide() first and returns the target untraced on a skip rule.

I ran the same calls through both writers with throwaway children: a 200-character import name, a title module with a 40-character name, and an unimplemented import in api-ms-win-crt-math-l1-1-0.dll (a CT_SKIP_MODULE prefix).

Case leonida-hle writes gta6rt writes
200-char import name 160 bytes in all (module, ! and the name cut short) 172 bytes
40-char module in caller all 40 characters first 31 characters
unimplemented import, skip-rule module E ... unimpl line nothing (wrap returns the target)

To see what the tool makes of each one, I built three pairs of synthetic traces. In each pair, everything is the same except that one field, written the way each runtime writes it:

Pair Exit Report
name 172 vs 160 1 1 only-left + 1 only-right, 2 count differences
caller module 31 vs 40 chars 1 1 only-left + 1 only-right
unimplemented import in a skip-rule module 1 1 only-right, 1 count difference

So each mismatch shows up as a divergence on every call it touches. As an illustration of how long decorated names get (this is not a claim about what the title imports): the system msvcp140.dll has 1,515 exports. 193 of them are longer than 160 bytes as msvcp140.dll!<name> (133 are longer than 172, max 196). Cut to 160 bytes, only 1,407 names are still distinct (1,469 at 172), so truncation also merges different imports into one name on each side. Possible fixes: give both writers one limit, or write a hash suffix when a name is cut. Then apply the skip rules to unimplemented imports in both, or in neither.

2. Cost per call (measured, release build, one thread, 10^6 calls each, a trivial target)

direct wrap stub (C+R) entry stub (E) wrap / entry after the cap
Rust (3 runs) 0.9-1.2 ns 185-196 ns 99-119 ns 10-13 ns / 5 ns
C++ (3 runs) 1.3 ns 108-111 ns 59-68 ns 9-11 ns / 4 ns

With these short names, a wrapped call writes about 72 bytes (115.1 MB for 1.6 M calls) and an entry-only call about 51. At that rate the default 4096 MiB cap holds roughly 60 million wrapped calls.

3. Contention (measured, Rust, production 10 ms lock bound)

There were 1.6 million wrapped calls in total, split over 1 to 64 threads that do nothing but call:

Threads 1 4 8 16 32 64
ns/call (aggregate) 236 374 497 629 644 630
slowest single call 0.7 ms 1.2 ms 1.2 ms 1.6 ms 1.5 ms 1.5 ms
dropped 0 0 0 0 0 0

In every run there were no open C records, and the file had exactly two records per call plus one T line per thread. Throughput levels off at about 1.6 M calls/s for the whole process, and no record was dropped at any thread count.

4. Kill under load (measured, Rust)

A child ran 4 threads calling a wrapped import in a loop, then called TerminateProcess on itself after 300 ms. Over 5 runs, the file held 60-81 MB of lines (15-20 views). Each file had 1-3 open C records, one per thread caught inside a call. I looked at the tail of one of the five: it ended on a complete line, with no NUL inside the content. The tool parsed every file, and a self-diff exited 0.

5. Size on disk (measured, both writers)

The file grows in whole 4 MiB views and is never cut back to its content:

Cap / content Size on disk
MAX_MB=1 (Rust 1,048,507 B, C++ 1,048,558 B) 4,194,304 B on both
MAX_MB=5 (Rust 5,242,792 B) 8,388,608 B
126 KB trace, no cap reached 4,194,304 B

This is harmless for the tool, which strips the NULs. But a 1 MiB cap gives a 4 MiB file, so the README could say the cap counts content, not size on disk.

6. The tool on malformed input (measured, python -I, 16 hand-made cases + 1,000 random mutations of a real 4-thread Rust trace)

Input Exit
random truncation at any byte (200) 1, never a parse error (the partial last line is ignored as documented)
byte flipped (200) 2 in 173, 1 in 25, 0 in 2
line deleted / duplicated / swapped (600) 1 or 2, never a traceback
CRLF line ends 0 (accepted)
UTF-8 BOM 2 (got 1 TAB-separated fields on line 1)
NUL run in the middle 2
second header later in the file, other rules hash 0, ignored silently
two empty files, or two all-NUL files 0
a seq of 5,000 digits uncaught ValueError (Python's 4,300-digit int limit), process exit 1

The last row is the only crash I found. It is artificial, but it exits with 1, the code the tool documents for "divergences". A try/except ValueError around the int() calls in parse_trace, or a digit-length check, would turn it into a 2.

Not checked: whether the title's real module or import names reach these limits, the full CMake build and ctest (I built only call_trace_test on its own), cargo test -p leonida, the gta6rt shims that use RT_CALLER(), and any run in game. The contention numbers come from threads that only call, not from a title's mix.

GPUs tested: n/a (CPU-only tests).

AI-assisted: yes (Claude Code).

MoonEyes commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Checked the Python side on Linux against current main. Merged with today's main, it now fails the switches-page test, and the Rust/C++ name-cap mismatch reported twice is still in the head. The Rust and C++ were not built here (Windows-only).

head      e2572082c (2026-11-30; nothing pushed since)
base      origin/main 45dc41f95, merge base 66b5d0433 (783 commits behind), merges cleanly (c4b532ebc)
CI        `check` and `linux-python-and-viewer` red on this head (2026-12-01 00:3x). Those failures are in tests the PR does not touch (`test_f.T.test_a`, `EveryToolGuardsStdout`), i.e. old `main`.
Command (on the merge) Result
python -I tests/test_call_trace_diff.py 79 tests, OK
python -I tests/test_call_trace_rules.py 9 tests, OK
python -I tests/test_docs_env_vars.py 5 tests, OK
python -I tests/test_d3d12_switches.py FAILED: test_the_tracked_switches_page_matches_the_sources
python -I scripts/check_no_game_data.py on the 23 changed files exit 0
python -m compileall -q on the changed .py files OK

Defects

  1. The switches page is stale, and main now tests that. d3d12/docs/switches.md is generated from the sources. The PR reads LEONIDA_CALL_TRACE, LEONIDA_CALL_TRACE_MAX_MB and LEONIDA_CT_CHILD, which the page lacks (Neutron-0 pointed this out on 2026-12-01). Since then main gained the check, so CI will go red once it runs on a merge. Fix: merge main, then python -I tools/d3d12_switches.py --out d3d12/docs/switches.md.
  2. The two runtimes still write different names for the same import. d3d12/crates/leonida-loader/src/call_trace.rs caps module!function at 160 bytes and a module name at 47. runtime/shims/call_trace.h caps them at 172 (Site::name) and 31 (ModEntry::name). An import bound to an unimplemented stub also skips classify in Rust (straight to entry-only), while C++ runs decide() first. Both were measured on this head (merzleckeier under Wine on 2026-12-01; Kal0s-design natively today, point 1). Since the whole purpose is a diff of the two traces, a long name or a long module name gives a false divergence at the very first such call. Use one cap and one order, ideally taken from tools/call_trace_rules.def, which both already read.
  3. PR text: no AI-assistance statement and no GPUs tested: line in the template's form (CONTRIBUTING.md, "Disclosure and verification"). The body does give the GPU in prose.

Not checked here: the C++ call_trace_test and cargo test -p leonida-loader (both Windows-only). fiestorra and Kal0s-design ran them green on Windows on this head.

Verdict: defects. Regenerate the switches page on current main and make the two writers' caps and skip order agree. Then it needs a CI run and the requested render-path run.

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

@MoonEyes

MoonEyes commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

RUN (independent run on Windows, head e2572082c02cd261c64b8275447d900a81f9eca8, merged into main b41763227aeed2d23c98af84bcbc1bddc7acdc90 with git merge --no-ff)

The merge is clean (no conflict). Windows 11, release profile, one shared target directory. No game files, no GPU run, no leonida.exe running during the builds.

What the PR is. An opt-in import call trace (LEONIDA_CALL_TRACE) for both runtimes plus a diff tool. It touches leonida-loader, run.rs, the C++ runtime shims and tools/. It does not touch leonida-gpu or any diagnostics-gated code in it, so the GPU lib run below is a regression check on the merge, not a test of the change.

Green

Command (on the merge) Result
cargo test -p leonida-gpu --release --locked --lib first run 702 passed, 1 failed (pool::tests::a_texture_gives_its_piece_back_when_it_goes); the test alone passed twice; the next full run 703 passed, 0 failed
cargo test -p leonida-loader --release --locked --lib call_trace 29 passed
python -I tests/test_call_trace_diff.py 79 OK
python -I tests/test_call_trace_rules.py 9 OK
python -I tests/test_docs_env_vars.py 5 OK
python -I tests/test_d3d12_switches.py 20 run, 1 FAILED: test_the_tracked_switches_page_matches_the_sources

The leonida-gpu failure is a flake in a pool test in code this PR does not touch. I did not run main alone, so I cannot say whether it also flakes there. --features diagnostics was not run: no leonida-gpu file is changed.

Red

  • Rust: with main's lib.rs (no pub mod call_trace), leonida-loader no longer builds, because windows.rs uses the module. Trivially red.
  • Python: with tools/call_trace_diff.py and call_trace_rules.def absent (they do not exist on main), test_call_trace_diff.py fails at import and test_call_trace_rules.py has 4 errors.
  • Mutations of the new code (each restored afterwards), all killed:
    1. call_trace.rs: size-cap check in Writer::line disabled: 2 tests fail (the_size_cap_writes_truncated_once_and_stops, a_cap_between_wrap_and_seal_leaves_callable_thunks), plus the child-process cases.
    2. call_trace.rs: the dropped-record counter not incremented in lock_bounded: 2 fail (a_held_writer_lock_costs_a_record_not_a_hang, child_drop).
    3. call_trace.rs: Bind::Unimpl no longer entry-only: 1 fails (an_unimplemented_import_is_traced_at_entry_with_bind_unimpl).
    4. call_trace_diff.py: return values never compared: 15 failures and 1 error.
    5. call_trace_diff.py: the ignore list for return values dropped: 1 failure.

Review

  1. Default off: OK by reading. open_from_env returns Ok(false) when the variable is unset or empty. wrap returns the target when no common stub is installed, so no thunk block is allocated. I did not measure this in game.
  2. docs/switches.md is stale (defect). LEONIDA_CALL_TRACE, LEONIDA_CALL_TRACE_MAX_MB and LEONIDA_CT_CHILD are missing from the page, and test_d3d12_switches.py now fails on the merge with main. Fix: python -I tools/d3d12_switches.py --out d3d12/docs/switches.md. runtime/README.md does list the two public switches.
  3. The two writers disagree (defect, matches earlier reports).
    • Rust call_trace.rs: NAME_MAX 160, MODULE_NAME_MAX 47. C++ call_trace.h: Site::name[172], module name [31].
    • LEONIDA_CALL_TRACE_MAX_MB: Rust (open_from_env) silently falls back to 4096 on 0 or a non-number (.filter(|&mb| mb > 0).unwrap_or(DEFAULT)); C++ refuses it with an error. The PR text describes the C++ behaviour as the contract.
    • Since the purpose is a diff of the two traces, a long name gives a false divergence. I read these on this head; I did not re-measure them.
  4. Ordering and lifetimes: the writer lock is bounded (about 10 ms) and a drop is counted and reported as # dropped N; a mutation of that counter is caught. Thunks are made after the cap so a bind in progress stays callable; a test covers it. Stub unwinding and fences were not reviewed beyond the tests.
  5. Claim: the body links the claim in issue 2570 (RT-CALL-TRACE and D3D12-CALL-TRACE). No item ID from the coordination issue was checked by me.
  6. Template: the body has no AI-assistance statement and no GPUs tested: line (a prior review also said so).
  7. Open reviewer questions: the switches page and the two mismatches above are still open on this head (nothing pushed since 2026-11-30). One comment noted a possible flake of case_dropped_record (a 100 ms wall-time check) under ctest -j 8.
  8. Overlap with other open PRs: not checked.
  9. In-game run on this exact head: none posted. The maintainer asked for one on 2026-12-02; the author says "Not run in game". Other runs were unit and tool runs only.

Not covered

  • The C++ side (call_trace_test, ctest): not built in this run.
  • Any run of leonida.exe or gta6rt with the switch set, and with it unset, in game.
  • leonida-gpu with diagnostics, and main alone for the pool flake.
  • Overlap check with other open PRs, and the item ID in the coordination issue.
  • d3d12_vulkan.md and findings.md were only searched for call-trace and trace mentions, not read in full.

Verdict

PARTIAL. The new tests and the diff tool pass and the mutations are caught, and the switch is off by default. But the merge with current main fails test_d3d12_switches.py, and the Rust and C++ writers disagree on name caps and on the MAX_MB parsing, which defeats the comparison the PR exists for. In-game run still required (none posted on this head).

AI-assisted (Claude Code), models: Claude Opus 5.5 (checker), separate Claude Opus 5.5 judge.

@MoonEyes

MoonEyes commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

RUN (in game, batch of five pull requests), each head merged with git merge --no-ff onto main ef35d683e, in one build: #3176 4c31594b5, #2657 c16b0424e, #2807 e2572082c, #3230 97eefdee4, #3247 3e5887f65. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, -Resolution 1080, frame generation 2x, -PrecompileUsed, the same walking route as the other runs on this machine, 330 s after reaching the world.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (47 samples) median 15.8, mean 16.2
Rendered fps, last 120 s median 15.0
Time under 5 fps in the world 1 %

For reference, the same machine and route rendered 13.3 to 17.2 fps on other batches today. These fps are a check that nothing fell over, not a measurement of a gain.

Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. #3247 has since moved to 3dc6c58b3, which only merges main (81efe4566) into the head above: git diff 3e5887f65 3dc6c58b3 leaves d3d12/scripts/play-nvidia.ps1 and tests/test_win_launchers.py unchanged. If another of these pull requests changes its head, this run no longer covers it.

Limits: one run; arrival in the world was driven by keys and not checked on pictures; -PrecompileUsed was used because main now precompiles every known pipeline by default (88,631 for a new executable, over an hour on this card). The default start was therefore not exercised, and the F1 SAVE AND RESTART path of #3247 was not exercised in game. An earlier attempt of this batch is not counted: the run script gave up waiting while that full precompile ran.

AI-assisted (Claude Code).

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.

8 participants