xcl run: a profile-tracy build records a Tracy timeline of the run #2490

Open
KOLESNiii wants to merge 1 commit from upstream-pr/2500 into main
KOLESNiii commented 2026-11-25 20:50:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-25T20:50:46Z.


XCL has no profiler. XCL_ACTIVITY counts presents, draws and DirectStorage requests every 2 s and the PSO trace times single compiles, so a slow frame or a loading stall shows up as a low number, never as what the time went on or which thread it was on. This adds an opt-in Tracy build: cargo build --release -p xcl --features profile-tracy records a timeline of the whole run – every thread's zones, a frame mark per PresentX and plots – that Tracy 0.14.1 shows live or saves with tracy-capture. Without the feature nothing changes: the macros expand to nothing.

On a retail title this gave what the counters cannot (RTX 2070 SUPER, 9 min 40 s, 9,117 frames, 328,501 zones):

  • menus hold the title's 30 fps cap (33.3 ms frames, ~21 ms of each in WaitFrameEventX);
  • in the world, ~5 fps: ExecuteCommandLists costs ~85 ms per frame on the presenting thread (11 ms in the menus) and PresentX ~29 ms; the longest frames (up to 17.7 s) are spent in title code while DirectStorage streams;
  • a 190 s freeze with no present at all, in which two title threads are 95–100 % busy building huge pipelines one after another: 11 compute pipelines of 16–24 s each (build compute (split), ~18 s of it in the driver) and 23 graphics pipelines.

No open or merged PR or issue adds a profiler; the nearest are log-based (#1766 XCL_GPU_PROFILE, #2220 precompile phase logs, #2111 frame-gap percentiles, #943 log comparison).

What is in it

  • crates/xcl/src/prof.rs: prof::start() and the prof_zone! / prof_frame! / prof_plot! macros (no-ops without the feature, and without a started client), with a unit test
  • zones in hle/d3d12x/real.rs (driver PSO compiles with the record hash, compute / graphics / mesh / GS PSO translation, split compute builds, ExecuteCommandLists), present.rs (PresentX + frame mark), frame.rs (WaitFrameEventX), list_x.rs (Wait32/64BitValueX), bind.rs (translated dispatches), pso_async.rs (async PSO builds), dstorage.rs (DirectStorage entries), gpu/recomp/mod.rs (RDNA2 → HLSL), gpu/recomp/dxc.rs (DXC, caller and worker); host.rs starts the client in the host process and plots commit, video memory and the activity counters
  • crates/xcl/Cargo.toml: optional tracy-client 0.19 (MIT / Apache-2.0; Tracy itself BSD-3-Clause) behind profile-tracy, without its crash handler (XCL's own exception handlers must see the title's faults) and with manual lifetime (only the host runs it, not the launcher). The Cargo.lock additions are that crate's tree, mostly loom (a cfg(loom) dependency of tracy-client that is never built)
  • crates/xcl/src/resolver.rs, feature builds only: the title's _register_thread_local_exe_atexit_callback import resolves to a no-op. Tracy's C++ thread_locals make xcl.exe's CRT startup register its destructor callback with the UCRT, which accepts one per process, so the title's CRT startup registering its own ended the run in terminate() (0xC0000409, 0.2 s after the entry point; found under a debugger). Cost: the title's main-thread thread_local destructors are not run at exit in profiling builds
  • README.md: how to build, connect and what is recorded

Tested

  • NVIDIA GeForce RTX 2070 SUPER, Windows 11 Home 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5
  • Rebased onto main 336fddda on 2026-11-28. cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 on 429e44da: 2123 passed, 9 failed, 48 ignored; 25 SKIPPED (21 no wave64, 3 refused #1426 forms, 1 no heap windows). The 9 failures are #3093's, the same 9 tests that fail on main 336fddda (2122 passed, 9 failed, 48 ignored, same skips). The results below are from before the rebase.
  • on b17262c: cargo build --workspace && cargo test --workspace -- --test-threads=4: 1424 passed, 0 failed, 46 ignored
  • SKIPPED on this adapter: 25 SKIPPED lines in 15 tests – 21 no wave64 (the RTX 2070 SUPER has 32-lane waves only), 3 wave32 per-lane forms refused by the recompiler (f16 arithmetic, f16 packed, f32 conversions: #1426 semantics), 1 no heap windows
  • with the feature: cargo test -p xcl --lib --features profile-tracy prof::: 1 passed, 0 failed; release build with the feature: retail title 25 s, exit 0x0, 414 frames and 134,520 zones captured; then the 9 min 40 s playtest above (before the rebase onto 6d12f58)

Regression run
After the rebase onto main 336fddda: RTX 2070 SUPER, the retail game, 60 s, XCL_PRESS_AT=25:A, XCL_PREPARE=0 (no startup shader preparation), release builds. One queue job of seven runs (main, then #2416, #2437, #2533, #2478, #2500, #3035, one after the other); the DXIL cache carries over from run to run.

xcl-smoke v1
commit: 336fdddafbcb3c3db753629f5f79a9f44b6c4b9d
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1253 (PresentX 1253)
presents per 2 s (last 3): 54 58 59
device removals: 0
crashes: 0
peak commit: 16597 MB
xcl-smoke v1
commit: 429e44daacbd134a28f8fd7761e4ad4b5c8ca3d5
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1449 (PresentX 1449)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15325 MB

Not tested

  • The regression runs skip startup shader preparation (XCL_PREPARE=0): shaders are built when the title first uses them, on main and on this PR alike.
  • AMD and Intel GPUs; only one retail title
  • Tracy's CPU sampling and context switches (they need an elevated process; the captures above ran unelevated, zones only)
  • CI builds the default features only, so the feature build is not checked by CI
  • Tracy GUI versions other than 0.14.1 (the client's protocol must match)

AI use

  • Claude Code with Claude Opus 5.5: wrote the code, the test, the README section and this description, found the UCRT abort with a small debugger script, ran the tests, the profiling capture and the regression runs above
  • Claude Code (Claude Opus 5.5) rebased it onto main 336fddda, ran the suite and the regression runs and updated this description.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5498962421 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2500). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-25T20:50:46Z. --- XCL has no profiler. `XCL_ACTIVITY` counts presents, draws and DirectStorage requests every 2 s and the PSO trace times single compiles, so a slow frame or a loading stall shows up as a low number, never as what the time went on or which thread it was on. This adds an opt-in [Tracy](https://github.com/wolfpld/tracy) build: `cargo build --release -p xcl --features profile-tracy` records a timeline of the whole run – every thread's zones, a frame mark per `PresentX` and plots – that Tracy 0.14.1 shows live or saves with `tracy-capture`. Without the feature nothing changes: the macros expand to nothing. On a retail title this gave what the counters cannot (RTX 2070 SUPER, 9 min 40 s, 9,117 frames, 328,501 zones): - menus hold the title's 30 fps cap (33.3 ms frames, ~21 ms of each in `WaitFrameEventX`); - in the world, ~5 fps: `ExecuteCommandLists` costs ~85 ms per frame on the presenting thread (11 ms in the menus) and `PresentX` ~29 ms; the longest frames (up to 17.7 s) are spent in title code while DirectStorage streams; - a 190 s freeze with no present at all, in which two title threads are 95–100 % busy building huge pipelines one after another: 11 compute pipelines of 16–24 s each (`build compute (split)`, ~18 s of it in the driver) and 23 graphics pipelines. No open or merged PR or issue adds a profiler; the nearest are log-based (#1766 `XCL_GPU_PROFILE`, #2220 precompile phase logs, #2111 frame-gap percentiles, #943 log comparison). **What is in it** - `crates/xcl/src/prof.rs`: `prof::start()` and the `prof_zone!` / `prof_frame!` / `prof_plot!` macros (no-ops without the feature, and without a started client), with a unit test - zones in `hle/d3d12x/real.rs` (driver PSO compiles with the record hash, compute / graphics / mesh / GS PSO translation, split compute builds, `ExecuteCommandLists`), `present.rs` (`PresentX` + frame mark), `frame.rs` (`WaitFrameEventX`), `list_x.rs` (`Wait32/64BitValueX`), `bind.rs` (translated dispatches), `pso_async.rs` (async PSO builds), `dstorage.rs` (DirectStorage entries), `gpu/recomp/mod.rs` (RDNA2 → HLSL), `gpu/recomp/dxc.rs` (DXC, caller and worker); `host.rs` starts the client in the host process and plots commit, video memory and the activity counters - `crates/xcl/Cargo.toml`: optional `tracy-client` 0.19 (MIT / Apache-2.0; Tracy itself BSD-3-Clause) behind `profile-tracy`, without its crash handler (XCL's own exception handlers must see the title's faults) and with manual lifetime (only the host runs it, not the launcher). The `Cargo.lock` additions are that crate's tree, mostly `loom` (a `cfg(loom)` dependency of `tracy-client` that is never built) - `crates/xcl/src/resolver.rs`, feature builds only: the title's `_register_thread_local_exe_atexit_callback` import resolves to a no-op. Tracy's C++ `thread_local`s make xcl.exe's CRT startup register its destructor callback with the UCRT, which accepts one per process, so the title's CRT startup registering its own ended the run in `terminate()` (0xC0000409, 0.2 s after the entry point; found under a debugger). Cost: the title's main-thread `thread_local` destructors are not run at exit in profiling builds - `README.md`: how to build, connect and what is recorded **Tested** - NVIDIA GeForce RTX 2070 SUPER, Windows 11 Home 10.0.26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2609.5 - Rebased onto `main` `336fddda` on 2026-11-28. `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4` on `429e44da`: 2123 passed, 9 failed, 48 ignored; 25 SKIPPED (21 `no wave64`, 3 refused #1426 forms, 1 `no heap windows`). The 9 failures are #3093's, the same 9 tests that fail on `main` `336fddda` (2122 passed, 9 failed, 48 ignored, same skips). The results below are from before the rebase. - on b17262c: `cargo build --workspace && cargo test --workspace -- --test-threads=4`: 1424 passed, 0 failed, 46 ignored - SKIPPED on this adapter: 25 SKIPPED lines in 15 tests – 21 `no wave64` (the RTX 2070 SUPER has 32-lane waves only), 3 wave32 per-lane forms refused by the recompiler (f16 arithmetic, f16 packed, f32 conversions: #1426 semantics), 1 `no heap windows` - with the feature: `cargo test -p xcl --lib --features profile-tracy prof::`: 1 passed, 0 failed; release build with the feature: retail title 25 s, exit 0x0, 414 frames and 134,520 zones captured; then the 9 min 40 s playtest above (before the rebase onto 6d12f58) **Regression run** After the rebase onto `main` `336fddda`: RTX 2070 SUPER, the retail game, 60 s, `XCL_PRESS_AT=25:A`, `XCL_PREPARE=0` (no startup shader preparation), release builds. One queue job of seven runs (`main`, then #2416, #2437, #2533, #2478, #2500, #3035, one after the other); the DXIL cache carries over from run to run. ``` xcl-smoke v1 commit: 336fdddafbcb3c3db753629f5f79a9f44b6c4b9d gpu: NVIDIA GeForce RTX 2070 SUPER title: retail game seconds: 60 exit: 0x0 frames shown: 1253 (PresentX 1253) presents per 2 s (last 3): 54 58 59 device removals: 0 crashes: 0 peak commit: 16597 MB ``` ``` xcl-smoke v1 commit: 429e44daacbd134a28f8fd7761e4ad4b5c8ca3d5 gpu: NVIDIA GeForce RTX 2070 SUPER title: retail game seconds: 60 exit: 0x0 frames shown: 1449 (PresentX 1449) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15325 MB ``` **Not tested** - The regression runs skip startup shader preparation (`XCL_PREPARE=0`): shaders are built when the title first uses them, on `main` and on this PR alike. - AMD and Intel GPUs; only one retail title - Tracy's CPU sampling and context switches (they need an elevated process; the captures above ran unelevated, zones only) - CI builds the default features only, so the feature build is not checked by CI - Tracy GUI versions other than 0.14.1 (the client's protocol must match) **AI use** - Claude Code with Claude Opus 5.5: wrote the code, the test, the README section and this description, found the UCRT abort with a small debugger script, ran the tests, the profiling capture and the regression runs above - Claude Code (Claude Opus 5.5) rebased it onto `main` `336fddda`, ran the suite and the regression runs and updated this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DavidM1911 commented 2026-11-25 21:05:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T21:03:27Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7174550736 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2500#issuecomment-7174550736). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T21:03:27Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Foniass commented 2026-12-01 08:12:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:12:25Z.


Triage (#1607) – head 273107b

No open or merged PR adds Tracy profiling (#2564, the only other one, is closed). The 67 Cargo.lock lines shared with #3457 are common crates, not the same change.
The new tracy-client comment in crates/xcl/Cargo.toml says "local profiling only (not for a PR)", which contradicts opening it as a PR. Remove or reword it. Everything else stays behind the profile-tracy feature, including the _register_thread_local_exe_atexit_callback override in resolver.rs.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7305012826 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2500#issuecomment-7305012826). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:12:25Z. --- **Triage (#1607)** – head 273107b No open or merged PR adds Tracy profiling (#2564, the only other one, is closed). The 67 Cargo.lock lines shared with #3457 are common crates, not the same change. The new `tracy-client` comment in `crates/xcl/Cargo.toml` says "local profiling only (not for a PR)", which contradicts opening it as a PR. Remove or reword it. Everything else stays behind the `profile-tracy` feature, including the `_register_thread_local_exe_atexit_callback` override in `resolver.rs`. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
KOLESNiii commented 2026-12-02 15:33:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-12-02T15:33:58Z.


@Foniass reworded the tracy-client comment in crates/xcl/Cargo.toml to "Tracy profiling for local builds, off by default: --features profile-tracy" (the rest of it, about the crash handler, is unchanged). Also rebased onto main df0cfef6: lib.rs has main's new ram_budget module next to prof. New head 5a403675; suite and smoke are queued again.

— Claude Code (Claude Opus 5.5), on behalf of the PR author

<!-- greyfinch-sync:ivall/xcl:comment:7350542082 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2500#issuecomment-7350542082). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-12-02T15:33:58Z. --- @Foniass reworded the `tracy-client` comment in `crates/xcl/Cargo.toml` to "Tracy profiling for local builds, off by default: `--features profile-tracy`" (the rest of it, about the crash handler, is unchanged). Also rebased onto `main` df0cfef6: `lib.rs` has `main`'s new `ram_budget` module next to `prof`. New head `5a403675`; suite and smoke are queued again. — Claude Code (Claude Opus 5.5), on behalf of the PR author
Foniass commented 2026-12-02 15:34:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T15:34:55Z.


Follow-up review (head 5a403675, since 273107b, diff read, not a merge-check; checks red):

  • Earlier points: unchanged; this push is a rebase. Cargo.lock now names windows-core 0.62.2 explicitly because the optional Tracy dependencies (through generator) bring in windows-core 0.100.0 as a second version; it is only built with --features profile-tracy.

New: none.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7350569157 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2500#issuecomment-7350569157). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T15:34:55Z. --- Follow-up review (head 5a403675, since 273107b, diff read, not a merge-check; checks red): - **Earlier points:** unchanged; this push is a rebase. `Cargo.lock` now names `windows-core 0.62.2` explicitly because the optional Tracy dependencies (through `generator`) bring in `windows-core 0.100.0` as a second version; it is only built with `--features profile-tracy`. New: none. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2500:upstream-pr/2500'
git switch 'upstream-pr/2500'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2500'
git switch 'upstream-pr/2500'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2500'
git switch 'upstream-pr/2500'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2500'
git switch 'main'
git merge --squash 'upstream-pr/2500'
git switch 'main'
git merge --ff-only 'upstream-pr/2500'
git switch 'main'
git merge 'upstream-pr/2500'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
xcl-dev/xcl!2490
No description provided.