leonida-gpu: a census of the argument clamp passes, one line every 300 frames (LEONIDA_INDIRECT_CENSUS=1) #3481

Merged
leonida/mandy
MoonEyes merged 2 commits from diag/indirect-clamp-census into main 2026-12-04 16:08:51 +00:00

Pull request successfully merged and closed

Member

A census of the argument clamp passes in front of ExecuteIndirect, only with LEONIDA_INDIRECT_CENSUS=1 (off by default). Every 300 frames one line indirect-clamp: gives the passes per frame, batched against single, with or without a count buffer, by kind (draw, indexed, dispatch, mesh), and for each single pass the code path that kept it out of a batch (in_place, off, records, count, no_batch, no_room). The goal is to know where the ~948 clamp passes a frame measured in game (about 3.9 ms of card time) come from, before touching that safety net.

No clamp, batch or budget decision changes: batched() now returns why it refused (Err(Why) instead of None), with the same calls in the same order; its only caller maps it back. Off, each hook loads a OnceLock and returns.

Tested: cargo test -p leonida-gpu --locked: 782 passed, 0 failed (five census tests: each reason, the exact line, the 299/300/301 cadence, the switch, the off path); cargo clippy -D warnings: clean; check_no_game_data.py and d3d12_switches.py --check: clean. A separate reviewer (Claude Opus 5.5) ACCEPTED; minor follow-ups noted (an .expect that would panic if the batch gate gains a condition why() lacks, one stale comment).

AI-assisted: written by Freebuff (ultra), reviewed by a separate Claude Opus 5.5 judge. Merged by Moon's agent on Moon's written authorization (two maintainers).

🤖 Generated with Claude Code

A census of the argument clamp passes in front of ExecuteIndirect, only with `LEONIDA_INDIRECT_CENSUS=1` (off by default). Every 300 frames one line `indirect-clamp:` gives the passes per frame, batched against single, with or without a count buffer, by kind (draw, indexed, dispatch, mesh), and for each single pass the code path that kept it out of a batch (`in_place`, `off`, `records`, `count`, `no_batch`, `no_room`). The goal is to know where the ~948 clamp passes a frame measured in game (about 3.9 ms of card time) come from, before touching that safety net. No clamp, batch or budget decision changes: `batched()` now returns why it refused (`Err(Why)` instead of `None`), with the same calls in the same order; its only caller maps it back. Off, each hook loads a `OnceLock` and returns. Tested: `cargo test -p leonida-gpu --locked`: 782 passed, 0 failed (five census tests: each reason, the exact line, the 299/300/301 cadence, the switch, the off path); `cargo clippy -D warnings`: clean; `check_no_game_data.py` and `d3d12_switches.py --check`: clean. A separate reviewer (Claude Opus 5.5) ACCEPTED; minor follow-ups noted (an `.expect` that would panic if the batch gate gains a condition `why()` lacks, one stale comment). AI-assisted: written by Freebuff (ultra), reviewed by a separate Claude Opus 5.5 judge. Merged by Moon's agent on Moon's written authorization (two maintainers). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The title's indirect executions are clamped by a pass of ours before they run:
one pass clamps many records when they are batched (indirect/batch.rs), and an
execution that cannot be batched gets a pass of its own. A frame was counted at
about 948 passes, 3.9 ms of its 55.7 ms, and which passes remain and why they
are not batched was not known.

With LEONIDA_INDIRECT_CENSUS=1 the passes are counted by batch or single, by
kind, by count buffer, and by the condition that kept an execution out of a
batch, and one line "indirect-clamp: ..." is written to the log every 300
presented frames. Off, each hook is one OnceLock load and nothing else runs; no
clamp, batch or budget decision changes.

`cargo test -p leonida-gpu --locked`: 757 passed, 0 failed, 60 ignored.
`cargo clippy -p leonida-gpu --locked --all-targets -- -D warnings`: exit 0.
`python -I scripts/check_no_game_data.py` on the touched files: exit 0.
`python -I tools/d3d12_switches.py --check d3d12/docs/switches.md`: exit 0.

AI-assisted (Freebuff, Buffy)
Author
Member

Merged by Moon's agent on Moon's written authorization. Separate reviewer: ACCEPT; 782 tests re-run green; after the update merge with main, d3d12_switches.py --check and tests/test_d3d12_switches.py pass on f62b17366f. Off by default (diagnostics only).

Merged by Moon's agent on Moon's written authorization. Separate reviewer: ACCEPT; 782 tests re-run green; after the update merge with main, `d3d12_switches.py --check` and `tests/test_d3d12_switches.py` pass on f62b17366f. Off by default (diagnostics only).
Sign in to join this conversation.
No description provided.