Scripts: generate flamegraphs for Criterion benchmarks #1144

Open
bmjask wants to merge 3 commits from upstream-pr/1153 into main
bmjask commented 2026-11-24 12:35:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-24T12:35:04Z.


Adds a Windows flamegraph wrapper for the benchmark targets, stacked on #1152. It validates the selected target, forwards an optional Criterion filter, and writes SVG output under target/flamegraphs by default.

What is in it

  • scripts/flamegraph.ps1: validated cargo-flamegraph wrapper and output handling
  • Cargo.toml and README.md: profiling configuration and usage
  • Includes the benchmark foundation and runtime targets from #1148 and #1152 because the branch is stacked

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB, driver 616.64; Ryzen 7 9800X3D; Windows 11 Home 26300; Rust 1.100.0 MSVC; debug
  • External report on exact head c09b78f: cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 741 passed, 0 failed, 41 ignored; skipped gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64)
  • cargo bench -p xcl --benches -- --test: all four targets built and all 68 benchmarks succeeded

Regression run

  • The diff adds Criterion as a dev-dependency, benchmark targets, documentation and generated lockfile entries. It also adds a bench-only debug-symbol profile and a profiling script. No production source files change. Requesting maintainer review for the documented test-only approval on this revision. No paired retail smoke results are available.

Not tested

  • scripts/flamegraph.ps1 end to end (requires cargo-flamegraph and an elevated shell), AMD, release, or a retail title; no benchmark timings were taken

AI use

  • OpenAI Codex with GPT-5 wrote the implementation. Claude Code with Claude Opus 5.5 ran the external validation and wrote the test report; the contributor checked it before posting.

  • OpenAI Codex (GPT-6.2 Astra) checked the changed files and CI logs and revised the title and regression-run explanation.

<!-- greyfinch-sync:ivall/xcl:issue:5472250212 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1153). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-24T12:35:04Z. --- Adds a Windows flamegraph wrapper for the benchmark targets, stacked on #1152. It validates the selected target, forwards an optional Criterion filter, and writes SVG output under `target/flamegraphs` by default. **What is in it** - `scripts/flamegraph.ps1`: validated `cargo-flamegraph` wrapper and output handling - `Cargo.toml` and `README.md`: profiling configuration and usage - Includes the benchmark foundation and runtime targets from #1148 and #1152 because the branch is stacked **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB, driver 616.64; Ryzen 7 9800X3D; Windows 11 Home 26300; Rust 1.100.0 MSVC; debug - External report on exact head `c09b78f`: `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: 741 passed, 0 failed, 41 ignored; skipped `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware` (no wave64) - `cargo bench -p xcl --benches -- --test`: all four targets built and all 68 benchmarks succeeded **Regression run** - The diff adds Criterion as a dev-dependency, benchmark targets, documentation and generated lockfile entries. It also adds a bench-only debug-symbol profile and a profiling script. No production source files change. Requesting maintainer review for the documented `test-only` approval on this revision. No paired retail smoke results are available. **Not tested** - `scripts/flamegraph.ps1` end to end (requires `cargo-flamegraph` and an elevated shell), AMD, release, or a retail title; no benchmark timings were taken **AI use** - OpenAI Codex with GPT-5 wrote the implementation. Claude Code with Claude Opus 5.5 ran the external validation and wrote the test report; the contributor checked it before posting. - OpenAI Codex (GPT-6.2 Astra) checked the changed files and CI logs and revised the title and regression-run explanation.
futurepro62 commented 2026-11-24 15:05:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T14:30:13Z.


Full-suite run, since this PR has no test report yet. Tested exact head c09b78f (on its base 47efa2e).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 741 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • cargo bench -p xcl --benches -- --test (each benchmark run once): all four bench targets (core, formats, gpu_cpu, runtime) build in the bench profile, and all 68 benchmarks report Success. No timings taken.

Not tested

  • scripts/flamegraph.ps1 (needs cargo-flamegraph and an elevated shell), AMD, a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7134481028 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1153#issuecomment-7134481028). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T14:30:13Z. --- Full-suite run, since this PR has no test report yet. Tested exact head `c09b78f` (on its base `47efa2e`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **741 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - `cargo bench -p xcl --benches -- --test` (each benchmark run once): all four bench targets (`core`, `formats`, `gpu_cpu`, `runtime`) build in the bench profile, and all 68 benchmarks report `Success`. No timings taken. **Not tested** - `scripts/flamegraph.ps1` (needs `cargo-flamegraph` and an elevated shell), AMD, a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
DavidM1911 commented 2026-11-25 08:08:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T08:02:12Z.


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:7156531899 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1153#issuecomment-7156531899). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T08:02:12Z. --- 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!
upstream-sync changed title from [PR #1153] Perf/benchmark flamegraphs to [PR #1153] Scripts: generate flamegraphs for Criterion benchmarks 2026-11-25 14:08:24 +00:00
ivall commented 2026-11-25 14:10:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-25T13:51:49Z.


Review of head c09b78f (stacked on #1152 and #1148). I read the whole diff before building. The new parts beyond the benchmarks are scripts/flamegraph.ps1 and a [profile.bench] debug = 1 in the root Cargo.toml. The script runs cargo flamegraph --package xcl --bench <one of four validated names> --output <path> -- [filter] --bench; the bench name comes from a ValidateSet, arguments are passed as an array (no string evaluation), it installs nothing and does not elevate (it only checks). No network, no build.rs, no workflow changes, no binaries. The script itself has not been run end to end (needs cargo-flamegraph and an elevated shell; I did not run it) and has no test.

Tested on this tree (#1148 + #1152 + #1153 merged onto current main): AMD RDNA4, Windows, DXC 1.8.2502.11, debug.

  • cargo build --workspace: ok
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1263 passed, 2 failed, 46 ignored; the two failures are the known fuzz_validate_and_gpu_1 and _3 (#2115), also failing on main. The kernelx tests that failed once in #1152's CI passed here.
  • cargo bench -p xcl --bench core|formats|gpu_cpu|runtime -- --test: 2 + 19 + 18 + 29 = 68 benchmarks succeeded. No timings taken.

Dependencies: criterion 0.7 is dev-only, no existing crate bumped, but its transitive ciborium, ciborium-io, ciborium-ll are Apache-2.0 only, which CONTRIBUTING.md excludes. cargo-flamegraph is an external tool, not a dependency. Not merging until the licence question in #1148 is decided; leaving this PR open.

AI use: Claude Code (Claude Sonnet 5.5) read the diff, ran the tests and wrote this on the maintainer's behalf.

<!-- greyfinch-sync:ivall/xcl:comment:7164399821 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1153#issuecomment-7164399821). Originally posted by [ivall](https://github.com/ivall) on 2026-11-25T13:51:49Z. --- Review of head c09b78f (stacked on #1152 and #1148). I read the whole diff before building. The new parts beyond the benchmarks are `scripts/flamegraph.ps1` and a `[profile.bench] debug = 1` in the root Cargo.toml. The script runs `cargo flamegraph --package xcl --bench <one of four validated names> --output <path> -- [filter] --bench`; the bench name comes from a ValidateSet, arguments are passed as an array (no string evaluation), it installs nothing and does not elevate (it only checks). No network, no build.rs, no workflow changes, no binaries. The script itself has not been run end to end (needs cargo-flamegraph and an elevated shell; I did not run it) and has no test. Tested on this tree (#1148 + #1152 + #1153 merged onto current main): AMD RDNA4, Windows, DXC 1.8.2502.11, debug. - `cargo build --workspace`: ok - `cargo test --workspace --no-fail-fast -- --test-threads=4`: 1263 passed, 2 failed, 46 ignored; the two failures are the known `fuzz_validate_and_gpu_1` and `_3` (#2115), also failing on main. The kernelx tests that failed once in #1152's CI passed here. - `cargo bench -p xcl --bench core|formats|gpu_cpu|runtime -- --test`: 2 + 19 + 18 + 29 = 68 benchmarks succeeded. No timings taken. Dependencies: criterion 0.7 is dev-only, no existing crate bumped, but its transitive `ciborium`, `ciborium-io`, `ciborium-ll` are Apache-2.0 only, which CONTRIBUTING.md excludes. cargo-flamegraph is an external tool, not a dependency. Not merging until the licence question in #1148 is decided; leaving this PR open. AI use: Claude Code (Claude Sonnet 5.5) read the diff, ran the tests and wrote this on the maintainer's behalf.
RavenCurseBurg commented 2026-11-26 01:05:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-26T00:06:29Z.


I tested the Windows preflight on c09b78fe74856039e15bcbaf99993a2ba091e1f7 from an ordinary (non-administrator) account. With PATH limited to temporary native stand-ins, the real wrapper rejected an invalid benchmark name, a valid benchmark with no profiler installed, and a valid benchmark with the profiler visible but no administrator rights. In each case the diagnostic identified the corresponding cause, the caller remained in the original directory, no command stand-in ran, and no SVG appeared.

Test-only fixture. I ran -NoProfile -NonInteractive -ExecutionPolicy Bypass -File scripts/flamegraph-preflight.tests.ps1 under Windows PowerShell 5.1 and PowerShell 7.6.9; all three cases passed in each shell. Windows 11, Core i7-13700. No elevated profiling session, benchmark build, or flamegraph generation was run. OpenAI Codex (GPT-6) wrote the fixture and ran it.

<!-- greyfinch-sync:ivall/xcl:comment:7178402867 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1153#issuecomment-7178402867). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-26T00:06:29Z. --- I tested the Windows preflight on `c09b78fe74856039e15bcbaf99993a2ba091e1f7` from an ordinary (non-administrator) account. With PATH limited to temporary native stand-ins, the real wrapper rejected an invalid benchmark name, a valid benchmark with no profiler installed, and a valid benchmark with the profiler visible but no administrator rights. In each case the diagnostic identified the corresponding cause, the caller remained in the original directory, no command stand-in ran, and no SVG appeared. [Test-only fixture](https://github.com/RavenCurseBurg/xcl/commit/61ecbb56517bf95ff65365977d80865fc0a83e33). I ran `-NoProfile -NonInteractive -ExecutionPolicy Bypass -File scripts/flamegraph-preflight.tests.ps1` under Windows PowerShell 5.1 and PowerShell 7.6.9; all three cases passed in each shell. Windows 11, Core i7-13700. No elevated profiling session, benchmark build, or flamegraph generation was run. OpenAI Codex (GPT-6) wrote the fixture and ran it.
github-actions[bot] commented 2026-11-29 20:44:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:44:54Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262326127 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1153#issuecomment-7262326127). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:44:54Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 06:37:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:37:54Z.


Review of c09b78fe (code reading only, not a merge-check; it conflicts with main, so not built or run; stacked on #1152 / #1148) · 3 medium

In short: Adds scripts/flamegraph.ps1, which runs a bench target under cargo-flamegraph. The script itself should work with main's harness. To land it: rebase with only the flamegraph commit, drop [profile.bench], rewrite the README lines for the in-tree harness, and run the script end to end once.

Medium

  1. Its first two commits are already on main. f73d165e and f84d8501 landed as c35d24a8 and 1120fdc9 via #2959, so a rebase should keep only c09b78fe (about 90 lines). No other PR does flamegraphs.
  2. [profile.bench] debug = 1 isn't needed. In the root Cargo.toml it lowers the symbols: the bench profile already inherits [profile.release] debug = 2. Drop it.
  3. The README describes a harness main doesn't have. The README text conflicts with main and describes Criterion, target/criterion and --save-baseline, which main's in-tree harness doesn't have; it also says twice that the wrapper never requests elevation. Rewrite those lines for the in-tree harness, and drop "Criterion" from the title.
Checked and fine
  • From reading, not run: scripts/flamegraph.ps1 should work with main's harness (it ignores --bench and takes the first plain argument as a substring filter, benches/support/mod.rs ~244-256).
  • The bench names in the ValidateSet match main's four targets.
  • The script installs nothing and doesn't elevate.
  • cargo-flamegraph is an external tool, not a dependency.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7303093223 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1153#issuecomment-7303093223). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:37:54Z. --- **Review** of `c09b78fe` (code reading only, not a merge-check; it conflicts with main, so not built or run; stacked on #1152 / #1148) · 3 medium **In short:** Adds `scripts/flamegraph.ps1`, which runs a bench target under cargo-flamegraph. The script itself should work with main's harness. To land it: rebase with only the flamegraph commit, drop `[profile.bench]`, rewrite the README lines for the in-tree harness, and run the script end to end once. #### Medium 1. **Its first two commits are already on main.** f73d165e and f84d8501 landed as c35d24a8 and 1120fdc9 via #2959, so a rebase should keep only c09b78fe (about 90 lines). No other PR does flamegraphs. 2. **`[profile.bench] debug = 1` isn't needed.** In the root `Cargo.toml` it lowers the symbols: the bench profile already inherits `[profile.release] debug = 2`. Drop it. 3. **The README describes a harness main doesn't have.** The README text conflicts with main and describes Criterion, `target/criterion` and `--save-baseline`, which main's in-tree harness doesn't have; it also says twice that the wrapper never requests elevation. Rewrite those lines for the in-tree harness, and drop "Criterion" from the title. <details><summary>Checked and fine</summary> - From reading, not run: `scripts/flamegraph.ps1` should work with main's harness (it ignores `--bench` and takes the first plain argument as a substring filter, `benches/support/mod.rs` ~244-256). - The bench names in the `ValidateSet` match main's four targets. - The script installs nothing and doesn't elevate. - cargo-flamegraph is an external tool, not a dependency. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
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/1153:upstream-pr/1153'
git switch 'upstream-pr/1153'

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/1153'
git switch 'upstream-pr/1153'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1153'
git switch 'upstream-pr/1153'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1153'
git switch 'main'
git merge --squash 'upstream-pr/1153'
git switch 'main'
git merge --ff-only 'upstream-pr/1153'
git switch 'main'
git merge 'upstream-pr/1153'
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!1144
No description provided.