Skip to content

Scripts: reproducible XCL-cold and XCL-warm performance runs - #2887

Draft
KOLESNiii wants to merge 5 commits into
xcl-dev:mainfrom
KOLESNiii:scripts-perf-run
Draft

KOLESNiii wants to merge 5 commits into
xcl-dev:mainfrom
KOLESNiii:scripts-perf-run

Conversation

@KOLESNiii

@KOLESNiii KOLESNiii commented Nov 26, 2026 •

Copy link
Copy Markdown

Adds scripts/perf-run.ps1: from a clean commit, build xcl in release and run one title twice, first with fresh ephemeral XCL caches (XCL-cold), then with those same caches (XCL-warm). The output folder keeps only the two xcl.log / report.json files and a versioned manifest.json (commit, run order, hardware and toolchain, selected XCL_* environment, workload fingerprint, durations, exit codes). GPU driver caches are not controlled and the manifest says so. Existing user caches are never read or touched.

Part of #2787 (item 8): 5bdaa54e and dfcd4bbb from #2778 by @bmjask, cherry-picked with -x with their authorship kept, plus three fixes found running it on a retail game. The comparator (fd237b1b) will be a separate PR stacked on this one.

Help wanted: a full run on a retail game. I could not finish one (see Tested). If you have a title and a stable machine, please run this on this PR's head and post the manifest.json here, without the logs, which name your paths:

.\scripts\perf-run.ps1 -Game '<your game folder>' -OutDir '<empty folder>' -Seconds 90 -StartupTimeoutSeconds 21600

The cold run prepares every shader of the title before the guest starts, and the last shaders are the slowest. Here it reached 22,800 of 26,503 shaders after 6,722 s, so give it a large -StartupTimeoutSeconds.

What is in it

  • Scripts: add reproducible cold and warm performance runs (bmjask, 5bdaa54e): scripts/perf-run.ps1, scripts/perf-run.tests.ps1, README. Ported without XCL_STALL_TRACE, which comes from the stall module on Bmjask/ultra performance redesign #2778 and is not on main.
  • Scripts: fingerprint performance workloads (bmjask, dfcd4bbb): the workload is identified by a SHA-256 over the sorted relative paths, lengths and modification times of its files, not by its folder name. Only the perf-run part is here. The matching comparator checks go with the comparator.
  • Scripts: perf-run keeps going when cargo writes to stderr: under Windows PowerShell with redirected output (a queued or logged run), cargo's first Compiling line on stderr became a terminating error and the run ended before the title started. git, cargo and rustc now run with Continue and their exit codes are checked, as scripts/test.ps1 does.
  • Scripts: perf-run gives an XCL-cold run time to prepare its shaders: -StartupTimeoutSeconds, with the same range and default as smoke.ps1. The fixed 120 s allowance killed the cold run during shader preparation. When XCL prints no log path, the error now shows its exit code and output.
  • Scripts: perf-run keeps the log of a run that crashes before its report: a crashed XCL prints No report – see the log: instead of Log:. The script stopped and deleted the ephemeral data root, and the crash log with it. Now the log is kept and the exit code recorded.

Each fix comes with a fixture case that fails without it.

Tested

  • Windows 11 build 26300, AMD Ryzen 5 3600XT, NVIDIA RTX 2070 SUPER (driver 32.0.16.2140), Rust 1.100.0 MSVC, Windows PowerShell 5.1.
  • powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\scripts\perf-run.tests.ps1: all assertions passed on 128ee21f (mock cargo and mock XCL, no game is run).
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 on 128ee21f: 1446 passed, 0 failed, 47 ignored. SKIPPED on this adapter: 21 × no wave64, 3 f16/f32 per-lane forms refused per gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426, 1 × no heap windows.
  • Retail game (release build of c94cdbce, -Seconds 90 -StartupTimeoutSeconds 7200, XCL_PRESS_AT=25:A): the runner built, created the ephemeral caches and started the cold run. XCL then died with 0xc0000005 after 1,497 s of shader preparation (12,600 of 26,503 shaders). It looks like xcl shaders --precompile --only cs --pipelines: access violation in dxcompiler.dll with parallel DXC compiles, not with XCL_DXC_THREADS=1 #2751, a crash in dxcompiler.dll during parallel compiles that is tied to this machine's RAM, not to this script. That run found the last fix: its log was lost.
  • Retail game again after the RAM was fixed (release build of 128ee21f, same settings): no crash this time, but 7,200 s was not enough. Shader preparation reached 22,800 of 26,503 after 6,722 s, then the script killed XCL at the time limit. A rerun with -StartupTimeoutSeconds 21600 is queued.

Not tested

  • A complete XCL-cold → XCL-warm pair on a retail game, so there are no real cold/warm numbers yet. That is the help asked for above.
  • PowerShell 7, AMD and Intel GPUs.

AI use

  • Claude Code (Claude Opus 5.5) cherry-picked and ported the two source commits, wrote the three fixes and their fixture cases, ran the tests and the retail run, and drafted this description. The source commits were written with Codex (GPT-5.6-sol), per their trailers.

🤖 Generated with Claude Code

bmjask and others added 5 commits November 26, 2026 19:55
Build a clean locked release and run one workload against fresh ephemeral XCL caches, then the exact same workload against those caches warm. Preserve only logs, reports, and a versioned environment manifest while explicitly leaving the driver cache uncontrolled.

Assisted-by: Codex (GPT-5.6-sol)
(cherry picked from commit 5bdaa54)

Ported without XCL_STALL_TRACE, which comes from the stall module on xcl-dev#2778
and is not on main.
Identify a workload from a deterministic metadata inventory instead of only its folder name, verify the inventory around each paired run, and require matching identity algorithms in comparisons. Persist no paths or file names and document that the fingerprint is not a content hash.

Assisted-by: Codex (GPT-5.6-sol)
(cherry picked from commit dfcd4bb)

Only the perf-run.ps1 part is taken here: the matching checks in
perf-compare.ps1 belong to the comparator, which is not part of this change.
Under Windows PowerShell, when the script's output is redirected (a queued
or logged run), every stderr line of a native command becomes an error
record, and with $ErrorActionPreference = 'Stop' cargo's first
"Compiling" line ended the run before the title started. git and rustc
are called the same way. Run them with 'Continue' and check their exit
codes, as scripts/test.ps1 does. The fixture's mock cargo now writes to
stderr and the first run is redirected, which failed before this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With a fresh DXIL cache, `xcl run` prepares every shader of the title
before the guest starts, and XCL_RUN_SECONDS counts only from there. On
a retail title with 26503 shaders, about 1400 were ready after 181 s on
an RTX 2070 SUPER, so the fixed 120 s allowance killed the cold run
during preparation. A killed XCL prints no `Log:` line, so the script
stopped with neither run recorded.

Take -StartupTimeoutSeconds as smoke.ps1 does (same range and default)
and record it in each run record. When XCL prints no log path, show its
exit code, the timeout state and its output, as smoke.ps1 does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the title crashes before XCL writes report.json, `xcl run` prints
"No report - see the log: <path>" instead of "Log: <path>". perf-run
found no log path, stopped, and then deleted the ephemeral data root,
so the only record of the crash went with it. This happened on a
retail title: an access violation (0xc0000005) during the XCL-cold
run's shader preparation, about 25 minutes in.

Accept either line, so the crashed run's log is kept and its exit code
recorded, as the manifest already allows. The fixture's mock XCL can now
crash this way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ettehn

ettehn commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

I reproduced a build-to-run mismatch in scripts/perf-run.ps1 at 128ee21f on Windows. The script builds with Cargo, then launches the hard-coded target\release\xcl.exe. With CARGO_TARGET_DIR redirected and an older executable still at the default path, both arms ran the old executable even though manifest.json recorded the current clean commit. I verified this using a tiny clean Rust repository: both captured logs contained the stale binary’s marker while the redirected release build contained the new marker.

A local candidate requests --bin xcl --message-format=json-render-diagnostics and launches the executable reported by the matching compiler-artifact message. With both executables present, cold and warm ran the newly built one in Windows PowerShell 5.1 and PowerShell 7. The existing perf-run.tests.ps1 assertions also passed on both. This is real Cargo and the PR’s runner with a synthetic executable and input folder. No retail title was launched.

OpenAI Codex (6.2sol) assisted with verification.

@andrewDoing

Copy link
Copy Markdown

On Windows at head 128ee21fcafdec1ecfd3e3f8bc496e6174aff617, both benchmark arms marked a two-second timeout, yet both captured a log message written by a child process five seconds after launch.

I ran the unchanged perf-run.ps1 with -Seconds 1 -StartupTimeoutSeconds 1 in a clean synthetic Rust workspace containing a package named xcl and a one-file workload. The script built the release executable itself. The synthetic launcher printed its log path, started a child inheriting stdout and stderr, and waited. The child slept five seconds, wrote a known marker to the log, and exited on its own.

The manifest recorded 2,056 ms cold and 2,010 ms warm, with timed_out=true in both arms. Both captured logs contained the five-second marker. The full invocation took 11,025 ms, including build and manifest work. A separate paired run also captured both post-timeout markers. No game or GPU was used.

The elapsed fields measure the launcher through its termination. The script calls Kill() on that process, stops its stopwatch, then waits for the redirected streams to finish. A surviving descendant with an inherited pipe can hold that read open and continue writing the workload log. XCL's production launcher also creates its host with Windows handle inheritance enabled. A benchmark timeout should contain the launched process tree and bound output draining before collecting that arm’s artifacts. Benchmark timeout handling

AI use: OpenAI Codex with GPT-6.2 Astra prepared the synthetic launcher and child, ran the paired checks, and wrote this report.

@andrewDoing

Copy link
Copy Markdown

I tested a local Windows process-tree cleanup candidate against the two-second timeout reproduction on 128ee21fcafdec1ecfd3e3f8bc496e6174aff617. Each benchmark arm owns an unnamed kill-on-close job. A gate process waits for assignment and a start message before launching the workload. The driver closes the job on timeout, normal exit, and errors. It bounds launcher exit and redirected-output completion separately and records elapsed time through cleanup. A readiness handshake excludes gate startup from the requested run deadline.

I ran three synthetic scenarios twice in Windows PowerShell 5.1 and twice in PowerShell 7, once per cold/warm arm in each shell. Four timeout arms finished in 2,010–2,034 ms. Four normal exits with a lingering child preserved exit code 0, and four normal exits without a child preserved exit code 7. The eight expected child-start markers appeared. After every child's five-second write deadline, none had written its delayed marker, and a separately launched sentinel remained alive.

The original script captured the child's five-second write in both two-second timeout arms. The candidate adds a helper process and some launch/cleanup overhead even after the readiness handshake. These were synthetic process-lifetime tests. Retail timing, restrictive Windows job policies, and a deliberately stuck external pipe holder were not exercised.

AI use: OpenAI Codex with GPT-6.2 Astra implemented and tested the candidate. A separate coding agent reviewed its process ownership, gate synchronization and error paths.

@andrewDoing

Copy link
Copy Markdown

On 128ee21f, the paired-run manifest omits XCL_PREPARE_ALL. When a title has a used-shader list, setting this switch to 1 requests preparation of every record. Two benchmark manifests can therefore describe the same workload and recorded environment while the launcher receives different preparation settings.

I ran the unchanged scripts/perf-run.ps1 twice on Windows with its test-workload hook. The workload wrote the value it received into its log. The game folder, build, durations and other configured environment settings were the same for both invocations.

Inherited setting Cold log Warm log Manifest environment
XCL_PREPARE_ALL=0 0 0 Setting absent
XCL_PREPARE_ALL=1 1 1 Setting absent

The two environment objects and workload_id values matched exactly. Recording XCL_PREPARE_ALL alongside the other selected runtime switches would make this difference visible when comparing runs. This check measured manifest coverage with a synthetic workload. It did not measure startup time or use a retail title.

AI use: OpenAI Codex with GPT-6.2 Astra prepared the synthetic workload and compared the manifests; Codex coordinated and prepared this report.

@luckyteagirl luckyteagirl 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.

perf-run.ps1 accepts a game directory ending in a backslash, but the native launch puts that backslash immediately before the closing quote. The Windows argument parser turns it into a literal quote in the filename. I ran the exact script from 128ee21f against a minimal Rust executable built by the script. With an existing Test Game\ folder, the executable received a path ending in a literal quote and the cold arm failed. Removing the trailing separator let both cold and warm arms finish. Could the native launch quote arguments correctly on Windows PowerShell 5.1 as well as PowerShell 7, with a regression for a folder containing spaces and a trailing separator? Native launch · Windows argument parsing

AI use: OpenAI Codex (GPT-6.2 Sol) reviewed the source, ran the synthetic Windows fixture, and drafted this comment. No retail title or GPU was used.

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.

4 participants