Skip to content

render: add a composite draw witness and attribute the gl query cost - #5183

Merged
jakildev merged 5 commits into
masterfrom
claude/4935-gl-overflowed-query-cost
Nov 19, 2026
Merged

jakildev merged 5 commits into
masterfrom
claude/4935-gl-overflowed-query-cost

Conversation

@jakildev

@jakildev jakildev commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

On Windows GL, the exact overflowed-tile query term in far-128 comes from 127 hidden caster canvases, not from the walk being slow. The 128 coincident caster canvases each shade the whole stack at bit-identical depth, and every one of those fragments runs the query. This adds an env-gated, GL-only composite draw witness (IR_COMPOSITE_DRAW_WITNESS), successor controller subcommands, and the retained phase-0 evidence (docs/perf/sun-overflowed-tile-query/windows-opengl-mechanism/, README § "GL mechanism: every coincident caster shades the stack"). The plan's correction-3 stop fires (the excess is cross-canvas), so phase 1 is not built and #4935 goes back to re-plan.

Screenshots

No visual change. The witness is disarmed unless the env var is set; post-binary diagnose gives production_matches_oracle: true in 5 of 5 cases.

Acceptance evidence

Criterion Check run Observed
1. Mechanism: pre ≥ 2 invocations per owned px on an exact-path canvas run_matrix.py witness --build debug (pre and post, 5 cases × 3 variants) Caster group 117.7 on pre and 128.0 on master; cross-canvas share of hidden 99.6–100%
1. Shipped-tree ratio ≤ 1.25 same Not shipped: phase 1 is stopped by correction 3. The early-tests control reaches 1.00
1. Controller tests python3 docs/perf/sun-overflowed-tile-query/test_controller.py 35 tests OK on Windows and on WSL2 Ubuntu (Linux)
2. GL cut ≤ −50% (upper bound), Debug run_matrix.py ab-timing --build debug (5 pairs, all CLEAN and guarded) far-128 65.65 → 48.01 ms, −26.9% (upper −25.9%): not met by #4936 alone
2. GL cut ≤ −50% (upper bound), Release run_matrix.py ab-timing --build release --cases far-128 66.05 → 48.05 ms, −27.2% (upper −26.6%): not met
3. Exact query still fires, pixels match oracle run_matrix.py diagnose --build debug (post) 371 entered / 234 hit on the 4 exact-path cases, 0 / 0 on the frozen filler-first case; production_matches_oracle true in all 5
4. Ties / render-verify — Not run: no rendering change ships
5. Metal — Cross-host follow-up; no Metal source changes
Mechanism control (extra) run_matrix.py ab-timing --name early-tests-timing --variants production ablation early-tests Forced early tests: 47.95 → 2.80 ms in Debug and 48.78 → 2.75 ms in Release (−94%, upper −93.7% / −92.9%)
Pre-tree provenance (extra) the live Debug and Release pre snapshots reopened through tree_provenance Before the fix, both were refused: the on-disk tree.diff hashes to 06efb088… (CRLF) against a recorded 4181baea…. Rewritten to the committed LF bytes, both are accepted with build type, binary, diff and shader-directory hashes all matching
Reviewer notes

Plan departures

  • Phase 0 (ii) per-query face-test count for the stack (correction 1): measured instead as the caster group's share of the summed per-draw query term (+58.0 of +58.0 ms) plus the early-tests control. Correction 3's stop makes the per-query count moot.
  • Crop-based reporting (corrections 1–2): replaced by canvas-group reporting. The stack crop is exactly the 128-caster group, and the floor is main-canvas GRID content that this composite never draws. "Invocations per frame-kept pixel" is the group sum over the group's owned samples.
  • Release A/B runs far-128 only, the case criterion 2 judges. Debug runs all five cases. The host had 8 other active panes, and quiet-window contention cost hours.
  • render: keep rigid face records intact through sorting #4936 had already merged, so "pre" is master with 84d6f7bc9 reverted, built in this tree and snapshotted (pre-tree/tree.json, tree.diff).

Notes for reviewer

  • fleet-pr-overlap: VERDICT overlap, all trial merges clean. render/metal: draw consecutive draws to one target in one render pass (#4994) #5100 and render: bound Metal frame overlap and pace input [WIP] #5161 touch render_device.hpp, render: bound Metal frame overlap and pace input [WIP] #5161 touches opengl_render_impl.cpp, and render: prototype event-cursor picks from completed images #5135 touches system_entity_canvas_to_framebuffer.hpp.
  • Engine sources are byte-identical to the measured commit 45a220089. run_matrix.py differs from the measured controller (2a3bd59a6f52…) in two ways. First, the OpenGL-only refusal of early-tests moved from early_tests_bytes() to main(), so an OpenGL run stages and dispatches exactly as measured. Second, snapshot now writes and hashes the exact tree.diff bytes, and reopening a pre tree checks the recorded build type, diff and shader-directory hashes as well as the binary.
  • The two retained pre-tree/tree.json records now carry f446b190…, the hash of their committed tree.diff. The tree.json copies inside the runs' provenance.json / summary.json / witness.json keep the 4181baea… they were recorded with (README § "Retained evidence").
  • clang-format is not installed on this Windows host, so format-changed could not run. The new C++ was kept within the LLVM 100-column style by hand.
  • Follow-ups not done here: the witness's CSV handle is never closed (it is flushed every frame), and no render CLAUDE.md mentions the witness yet.
  • GLAPI.h / GLAPITrace.h / funcs_list.txt gain glStencilFunc / glStencilOp by hand, in the same shape as the generated entries.

Refs #4935

🤖 Generated with Claude Code

jakildev and others added 3 commits November 17, 2026 14:18
The GL exact overflowed-tile query term is the query running in hidden
fragments of coincident caster canvases. In the far-128 fixture each of
the 128 casters shades the whole stack at bit-identical depth (128.0
invocations per owned sample on master, all cross-canvas), and every one
of those fragments walks the record hierarchy. Forcing early fragment
tests on the early source-face route, staged as a control, cuts the
composite by 94%.

IR_COMPOSITE_DRAW_WITNESS counts per-draw fragment-shader invocations
and the samples each draw owns at composite end (an in-order depth-EQUAL
stencil first-claim replay), with the counters outside the measured
shaders. The controller gains a binary snapshot, an interleaved pre/post
A/B, the witness and the early-tests control. Against a binary with the
four-word order records reverted, they cut far-128 by 27% in Debug and
Release, short of a half.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jakildev jakildev added fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-windows PR was opened from a Windows (MSYS2) host labels Nov 18, 2026

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review — render: add a composite draw witness and attribute the gl query cost

Verdict: needs-fix

The phase-0 diagnostic approach is sound, but the current head does not pass its controller suite or whitespace validation.

Needs-fix

  • docs/perf/sun-overflowed-tile-query/run_matrix.py:165 — early_tests_bytes() rejects every non-darwin host via the process-global BACKEND, so test_controller.py fails on the Linux CI/reviewer host before it can validate the OpenGL-only staging transform. Make this helper validate the supplied early-route shader independently of the host backend (keep command dispatch restricted to OpenGL), then run the controller suite cross-platform.
  • docs/perf/sun-overflowed-tile-query/windows-opengl-mechanism/debug/pre-tree/tree.diff:31 — retained tree.diff snapshots contain whitespace-only added lines (also lines 111 and 203, with the same three lines in the release snapshot), so git diff --check origin/master...HEAD and the required whitespace check fail. Preserve the evidence without trailing spaces or add the appropriate tracked-artifact handling so the repository check is green.

Praise

  • engine/prefabs/irreden/render/composite_draw_witness.hpp::Recorder keeps the counters outside the measured shaders and records the ownership replay separately, which matches the issue's diagnostic constraint.

Checked

  • Read the complete #4935 issue thread, PR metadata, commits, comments, inline comments, diff, and retained evidence summaries.
  • python3 docs/perf/sun-overflowed-tile-query/test_controller.py — failed: 31 tests ran; BinaryAB.test_early_tests_control_forces_early_tests_on_the_early_route_only raises StageError on this Linux host.
  • git diff --check origin/master...HEAD — failed on six retained tree.diff whitespace-only lines; this matches the failed whitespace GitHub check.
  • Remaining GitHub checks were in progress at review time.

Test plan the author should run before merge

  • python3 docs/perf/sun-overflowed-tile-query/test_controller.py
  • git diff --check origin/master...HEAD

Escalation: author-agent to address, then re-request review.

🤖 Reviewed by Codex (sonnet-reviewer role)
Opus recheck required: the diagnostic changes OpenGL draw-state and pipeline-statistics behavior in the render path.

@jakildev jakildev added fleet:needs-fix Fleet reviewer found issues — author must address and removed fleet:reviewing-mac-pool-4 labels Nov 18, 2026
@jakildev jakildev removed the fleet:needs-fix Fleet reviewer found issues — author must address label Nov 18, 2026
early_tests_bytes() refused every non-OpenGL host, so the controller
suite failed on macOS before it could check the OpenGL-only staging
transform. The transform is now host-independent and main() refuses the
early-tests variant off OpenGL, with a test for each half.

The retained pre-tree tree.diff snapshots carry whitespace-only added
lines from the reverted source. tree.json pins their sha256, so they
opt out of trailing-space checks the way docs/**/*.patch already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jakildev jakildev added fleet:changes-made Agent addressed human feedback — ready for human re-review and removed fleet:amending-windows-pool-1 labels Nov 18, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback:

  • run_matrix.py:165, early_tests_bytes() gated on the host backend: it is now a pure text transform that works on any host. main() refuses --variants early-tests when the backend isn't OpenGL (argparse exit 2, runner never called). One note on the review: Linux already resolved to opengl (only darwin maps to Metal), so the guard rejected macOS, not Linux. The suite is now cross-platform either way. New/extended tests:
    • test_early_tests_control_forces_early_tests_on_the_early_route_only now also checks that the transform's output is identical with BACKEND forced to opengl and to metal.
    • test_early_tests_variant_is_refused_off_opengl dispatches ab-timing and witness through main(): exit 2 and no run on Metal, exit 0 and one run on OpenGL.
    • Results: 32 tests OK on Windows and on WSL2 Ubuntu.
    • Mutation controls on both hosts: putting the guard back into the transform fails the first test (backend='metal'), and removing the dispatch gate fails the new test for both commands.
  • tree.diff whitespace-only added lines: the snapshots stay byte-for-byte, because each tree.json pins diff_sha256 to that exact content (both still match, checked). Instead, .gitattributes gains docs/**/*.diff whitespace=-trailing-space, the same opt-out docs/**/*.patch already uses. git diff --check origin/master...HEAD is now clean.
  • PR body: updated the controller-test row to 32 tests, and the provenance note no longer claims run_matrix.py is byte-identical to the measured controller (the only difference is where the OpenGL-only refusal lives).
    — worker

@github-actions

Copy link
Copy Markdown

Perf gate

Head host slug: linux-x86_64-epyc-9v45-96-unknown

perf comparison: 1600afd → 3d3918b-ci

baseline: /home/runner/work/_temp/perf-baseline/history/linux-x86_64-epyc-9v45-96-unknown/1600afdc75aed2694fc947eb4acc7f42e4b2406b
head: /home/runner/work/IrredenEngine/IrredenEngine/save_files/perf/3d3918b01-ci

host calibration

  • host: linux-x86_64-epyc-9v45-96-unknown (matches baseline)
  • ref_ms: head 59.77 vs baseline 58.62 (load_factor 1.02×)
  • calibration target: 50.00 ms (informational)
  • baseline capture: perf-baseline@1600afdc7 (branch tip); master a914699df, finished 2026-11-17T18:23:28Z, 0.5 d before the head run, ref_ms 58.62
  • weighting: raw (class-matched capture; load_factor 1.02×; no calibration-scaling entry)
  • attribution: no measured master improvement between capture master a914699df and merge base 18a91f694 (13 commits)

thresholds: regress ≥ 10%, improve ≥ 5%

voxel cull effectiveness

cell ratio (base→head) avg visible total avg feeder
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 1024 → 1024 0 → 0
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.598 → 0.598 (+0.0pp) 156630 → 156630 1024 → 1024 0 → 0
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 1024 → 1024 0 → 0
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.975 → 0.975 (+0.0pp) 255592 → 255592 1024 → 1024 0 → 0

frame timing (ms)

cell avg p99
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 334.67 → 346.79 (+3.6%) 1009.08 → 1046.19 (+3.7%)
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 729.45 → 761.58 (+4.4%) 1402.16 → 1479.30 (+5.5%)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 419.20 → 436.19 (+4.1%) 6041.55 → 6424.09 (+6.3%)
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 1038.93 → 1102.85 (+6.2%) 1750.45 → 1759.11 (+0.5%)

GPU frame timing (ms; separate from stage samples)

cell envelope (base→head) buffer spans (base→head) coverage (base→head)
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable

GPU stage timing (avg ms per sampled invocation)

cell canvasClear voxelCompact voxelStage1 voxelCardinalElect voxelStage2 voxelSunFaces textToTrixel buildLightOcclusionGrid computeVoxelAO bakeSunShadowMap computeSunShadow computeLightVolume lightingToTrixel fogToTrixel trixelToFb resolvePerAxisScreenDepth fbToScreen
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 12.94→13.56 38.31→40.04 34.21→36.17 0.60→0.67 ⚠ 33.78→35.26 57.75→59.73 — 0.00→0.00 2.26→2.28 17.55→18.39 12.59→12.86 11.85→12.47 2.49→2.78 ⚠ 0.88→0.94 0.15→0.13 ↓ — 5.09→5.38
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 13.45→13.79 174.93→181.23 146.62→153.02 2.26→2.46 134.13→139.05 92.68→98.92 — 0.00→0.00 1.90→1.91 29.40→31.50 11.32→12.36 10.19→11.04 5.20→5.91 ⚠ 0.91→1.12 ⚠ 0.11→0.12 ⚠ — 4.83→5.17
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 12.20→12.19 44.70→46.94 38.16→39.07 5.47→6.06 ⚠ 30.70→32.37 53.92→54.85 0.73→0.77 0.00→0.00 4.61→4.81 37.98→39.15 11.95→12.19 25.69→27.37 4.14→4.44 1.17→1.29 ⚠ 0.11→0.12 0.00→0.00 5.66→6.17
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 12.62→13.41 279.88→296.94 236.71→249.90 3.66→3.79 209.06→223.87 98.13→104.57 0.72→0.79 0.00→0.00 2.06→2.06 39.22→42.49 11.50→13.14 ⚠ 10.62→11.54 4.42→4.92 ⚠ 0.98→1.17 ⚠ 0.11→0.13 ⚠ 0.00→0.00 4.71→5.19 ⚠

top CPU systems by avg ms (head)

target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 180.112 → 187.967 (+4.4%)
RENDER ComputeLightVolume 24.096 → 25.002 (+3.8%)
RENDER ComputeSunShadow 12.907 → 13.808 (+7.0%)
RENDER CanvasToFramebuffer 11.391 → 11.971 (+5.1%)
RENDER BakeSunShadowMap 6.815 → 6.787 (-0.4%)
UPDATE FogRevealEval 3.825 → 3.996 (+4.5%)
RENDER LightingToTrixel 2.605 → 2.923 (+12.2%) ⚠
UPDATE PropagateTransform 2.917 → 2.781 (-4.7%)

target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 563.873 → 587.729 (+4.2%)
RENDER ComputeSunShadow 25.516 → 27.168 (+6.5%)
RENDER ComputeLightVolume 21.208 → 22.995 (+8.4%)
RENDER CanvasToFramebuffer 10.526 → 11.174 (+6.2%)
RENDER BakeSunShadowMap 5.858 → 6.294 (+7.4%)
RENDER LightingToTrixel 5.334 → 6.085 (+14.1%) ⚠
RENDER ComputeVoxelAO 5.546 → 5.961 (+7.5%)
UPDATE FogRevealEval 3.819 → 3.879 (+1.6%)

target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 199.623 → 205.012 (+2.7%)
RENDER ComputeSunShadow 33.508 → 34.436 (+2.8%)
RENDER ComputeLightVolume 23.367 → 24.056 (+2.9%)
RENDER LightingToTrixel 15.265 → 16.538 (+8.3%)
RENDER CanvasToFramebuffer 12.228 → 12.343 (+0.9%)
RENDER BakeSunShadowMap 8.484 → 8.886 (+4.7%)
RENDER FogToTrixel 3.592 → 3.804 (+5.9%)
UPDATE PropagateTransform 3.740 → 3.760 (+0.5%)

target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 840.096 → 892.418 (+6.2%)
RENDER ComputeSunShadow 34.897 → 37.833 (+8.4%)
RENDER ComputeLightVolume 21.870 → 24.325 (+11.2%) ⚠
RENDER CanvasToFramebuffer 10.803 → 11.291 (+4.5%)
RENDER BakeSunShadowMap 6.192 → 6.484 (+4.7%)
RENDER LightingToTrixel 4.541 → 5.061 (+11.5%) ⚠
RENDER ComputeVoxelAO 4.609 → 5.030 (+9.1%)
UPDATE PropagateTransform 3.772 → 3.961 (+5.0%)

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review — render: add a composite draw witness and attribute the gl query cost

Verdict: approve

The follow-up resolves both prior blockers; the phase-0 witness remains properly isolated from the measured shaders and correctly stops before the rejected phase-1 lever.

Praise

  • engine/prefabs/irreden/render/composite_draw_witness.hpp::Recorder brackets the measured draws externally, then uses a separate first-claim replay for ownership; that preserves the diagnostic premise while accounting for equal-depth ties.

Checked

  • Re-read the complete #4935 issue thread, current PR metadata, commits, PR discussion, inline comments, and the changed controller, evidence summaries, and render code.
  • python3 docs/perf/sun-overflowed-tile-query/test_controller.py — passed: 32 tests.
  • git diff --check origin/master...HEAD — passed.
  • fleet-build --detach --target IRCanvasStress, terminal fleet-jobs wait — succeeded, exit 0 (macOS Metal build).
  • linux-build and render-harness-tests GitHub checks are still in progress; they are unread, not treated as passing.

Test plan the author should run before merge

  • Let the in-progress Linux build and render-harness checks complete successfully.
  • Re-run the GL witness on its Windows target after any render-path change.

Escalation: please Opus-recheck before merge (touches: engine/render and composite draw-state diagnostics).
🤖 Reviewed by Codex (sonnet-reviewer role)
Opus recheck required: the GL-only pipeline-statistics and stencil replay changes need final review on their native render path.

@jakildev jakildev added fleet:needs-opus-recheck Sonnet flagged this PR for Opus recheck before merge and removed fleet:changes-made Agent addressed human feedback — ready for human re-review fleet:reviewing-mac-pool-7 labels Nov 18, 2026
@github-actions

Copy link
Copy Markdown

Perf gate

Head host slug: linux-x86_64-xeon-6975p-c-03-0-vga

perf comparison: b309c9f → 0e501ca-ci

baseline: /home/runner/work/_temp/perf-baseline/history/linux-x86_64-xeon-6975p-c-03-0-vga/b309c9f6048632dbfc29df976605a00b49aa3523
head: /home/runner/work/IrredenEngine/IrredenEngine/save_files/perf/0e501ca51-ci

host calibration

  • host: linux-x86_64-xeon-6975p-c-03-0-vga (matches baseline)
  • ref_ms: head 69.90 vs baseline 69.98 (load_factor 1.00×)
  • calibration target: 50.00 ms (informational)
  • baseline capture: perf-baseline@b309c9f60 (branch tip); master 40cb99890, finished 2026-11-18T00:35:20Z, 0.3 d before the head run, ref_ms 69.98
  • weighting: raw (class-matched capture; load_factor 1.00×; no calibration-scaling entry)
  • attribution: no measured master improvement between capture master 40cb99890 and merge base 18a91f694 (7 commits)

thresholds: regress ≥ 10%, improve ≥ 5%

voxel cull effectiveness

cell ratio (base→head) avg visible total avg feeder
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 1024 → 1024 0 → 0
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.598 → 0.598 (+0.0pp) 156630 → 156630 1024 → 1024 0 → 0
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 1024 → 1024 0 → 0
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.975 → 0.975 (+0.0pp) 255592 → 255592 1024 → 1024 0 → 0

frame timing (ms)

cell avg p99
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 451.04 → 427.61 (-5.2%) ↓ 1173.32 → 1264.32 (+7.8%)
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 959.09 → 948.61 (-1.1%) 1732.18 → 1686.44 (-2.6%)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 503.95 → 508.94 (+1.0%) 6730.35 → 6801.95 (+1.1%)
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 1357.59 → 1338.41 (-1.4%) 2036.00 → 2056.20 (+1.0%)

GPU frame timing (ms; separate from stage samples)

cell envelope (base→head) buffer spans (base→head) coverage (base→head)
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable

GPU stage timing (avg ms per sampled invocation)

cell canvasClear voxelCompact voxelStage1 voxelCardinalElect voxelStage2 voxelSunFaces textToTrixel buildLightOcclusionGrid computeVoxelAO bakeSunShadowMap computeSunShadow computeLightVolume lightingToTrixel fogToTrixel trixelToFb resolvePerAxisScreenDepth fbToScreen
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 16.87→16.17 48.76→46.31 ↓ 41.56→39.66 0.78→0.93 ⚠ 41.64→39.41 ↓ 70.15→68.39 — 0.00→0.00 1.53→1.42 ↓ 17.83→16.94 ↓ 14.46→13.44 ↓ 12.15→11.49 ↓ 2.90→2.60 ↓ 0.99→0.96 0.16→0.15 — 6.71→6.41
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 17.38→17.39 241.92→238.39 182.43→179.56 3.04→3.01 172.59→170.27 114.14→113.33 — 0.00→0.00 1.29→1.31 30.18→29.73 12.93→12.60 10.14→10.47 5.01→4.90 1.09→1.07 0.16→0.16 — 6.35→6.31
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 15.45→15.70 55.69→56.14 44.44→43.94 6.62→6.57 37.16→36.94 65.84→65.03 1.29→1.30 0.00→0.00 4.16→4.23 38.79→39.55 12.29→13.01 29.16→29.58 4.86→4.92 1.38→1.39 0.15→0.15 0.00→0.00 7.13→7.39
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 16.48→16.09 393.12→388.67 292.56→289.44 4.66→4.62 268.53→265.60 127.72→127.46 1.33→1.33 0.00→0.00 1.31→1.31 38.63→38.25 13.79→13.60 11.02→11.37 4.34→4.42 1.18→1.17 0.15→0.14 ↓ 0.00→0.00 6.24→6.16

top CPU systems by avg ms (head)

target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 221.593 → 212.951 (-3.9%)
RENDER ComputeLightVolume 26.250 → 24.577 (-6.4%) ↓
RENDER CanvasToFramebuffer 14.773 → 14.227 (-3.7%)
RENDER ComputeSunShadow 13.119 → 12.612 (-3.9%)
UPDATE FogRevealEval 8.618 → 7.712 (-10.5%) ↓
RENDER BakeSunShadowMap 6.145 → 5.635 (-8.3%) ↓
UPDATE PropagateTransform 3.668 → 3.691 (+0.6%)
UPDATE LuaWaveStateToOffset 3.274 → 2.947 (-10.0%) ↓

target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 729.250 → 719.996 (-1.3%)
RENDER ComputeSunShadow 26.492 → 25.800 (-2.6%)
RENDER ComputeLightVolume 22.641 → 22.706 (+0.3%)
RENDER CanvasToFramebuffer 14.167 → 13.687 (-3.4%)
UPDATE FogRevealEval 7.354 → 7.198 (-2.1%)
RENDER ComputeVoxelAO 6.886 → 6.843 (-0.6%)
RENDER BakeSunShadowMap 5.002 → 5.266 (+5.3%)
RENDER LightingToTrixel 5.192 → 5.025 (-3.2%)

target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 235.817 → 235.366 (-0.2%)
RENDER ComputeSunShadow 34.222 → 35.026 (+2.3%)
RENDER ComputeLightVolume 23.624 → 24.562 (+4.0%)
RENDER LightingToTrixel 18.734 → 19.024 (+1.5%)
RENDER CanvasToFramebuffer 14.799 → 14.648 (-1.0%)
RENDER BakeSunShadowMap 8.113 → 8.157 (+0.5%)
UPDATE FogRevealEval 7.265 → 7.078 (-2.6%)
UPDATE PropagateTransform 4.769 → 4.782 (+0.3%)

target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 1101.999 → 1091.112 (-1.0%)
RENDER ComputeSunShadow 34.622 → 34.191 (-1.2%)
RENDER ComputeLightVolume 24.498 → 24.559 (+0.2%)
RENDER CanvasToFramebuffer 13.496 → 13.528 (+0.2%)
UPDATE FogRevealEval 7.735 → 7.315 (-5.4%) ↓
RENDER ComputeVoxelAO 5.662 → 5.538 (-2.2%)
RENDER BakeSunShadowMap 5.175 → 5.208 (+0.6%)
UPDATE PropagateTransform 4.747 → 4.746 (-0.0%)

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review — render: add a composite draw witness and attribute the gl query cost

Verdict: needs-fix

Sonnet flagged the GL-only pipeline-statistics and stencil replay. On closer read, I confirm that the replay preserves the measured draws, reconstructs first-owner ties against final depth, and correctly stops before the refuted phase-1 lever; the retained pre-tree provenance is not self-consistent, however.

Needs-fix

  • docs/perf/sun-overflowed-tile-query/run_matrix.py::snapshot / tree_provenance — snapshot() writes a terminal newline to tree.diff but records diff_sha256 from the pre-newline string. Both committed pre-tree records therefore claim 4181baea…, while the exact committed Debug and Release tree.diff bytes hash to f446b190…. tree_provenance() then checks only the binary hash and never verifies the recorded diff or shader-directory hash, so the retained snapshot cannot enforce the reverted source/shader identity it says it pins. Hash the bytes actually written, verify the recorded diff, shader directory, and build type when reopening a pre tree, update both retained records, and add a mutation test that proves each mismatch is rejected.

Praise

  • engine/prefabs/irreden/render/composite_draw_witness.hpp::Recorder keeps statistics outside the measured shaders, and the depth-EQUAL/stencil first-claim replay correctly reproduces the first winner under the production LESS tie rule.

Checked

  • Read the complete #4935 issue thread, both Sonnet reviews, the author response, current PR discussion, inline-comment set, commits, relevant module/rule docs, implementation, controller, and retained summaries.
  • python3 docs/perf/sun-overflowed-tile-query/test_controller.py — passed: 32 tests.
  • git diff --check origin/master...HEAD — passed.
  • Independently SHA-256 checked both committed pre-tree diffs: recorded 4181baea…; exact bytes f446b190… in both Debug and Release.
  • Current head remains 76eb0556b4f41e563f974332c014494993d62f42; render-harness, perf, format, header, and whitespace checks pass. linux-build is still in progress and is unread, not treated as passing.

Test plan the author should run before merge

  • Add snapshot-provenance positive controls, then rerun python3 docs/perf/sun-overflowed-tile-query/test_controller.py.
  • Recompute and verify both committed tree.diff hashes from their exact bytes.
  • Let linux-build complete successfully.

🤖 Reviewed by Codex GPT-5 (opus-reviewer role; review-pr skill)

@jakildev jakildev added fleet:needs-fix Fleet reviewer found issues — author must address and removed fleet:needs-opus-recheck Sonnet flagged this PR for Opus recheck before merge fleet:reviewing-mac-pool-3 labels Nov 18, 2026
`snapshot` hashed the revert diff before appending the final newline it
wrote, and wrote it in text mode, so on Windows `tree.diff` carried CRLF
bytes that matched neither its record nor the committed copy. Write the
exact bytes and hash those. Reopening a pre tree now checks its recorded
build type, binary, diff and shader-directory hashes, not only the binary.

The two retained `tree.json` records now carry `f446b190…`, the hash of
their committed `tree.diff`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jakildev jakildev added fleet:changes-made Agent addressed human feedback — ready for human re-review and removed fleet:amending-windows-pool-1 labels Nov 18, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback:

  • run_matrix.py::snapshot / tree_provenance pre-tree provenance: confirmed. snapshot hashed the diff before appending the final newline, and wrote tree.diff in text mode, so on Windows the live snapshot held CRLF bytes (06efb088…). Those matched neither the record (4181baea…) nor the committed LF copy (f446b190…). My previous round claimed the hashes matched. That was wrong.
    • snapshot now writes the exact bytes with write_bytes and records the hash of those bytes.
    • tree_provenance now checks the pre tree's recorded build_type, binary_sha256, diff_sha256 (against the on-disk tree.diff) and shader_dir_sha256 (against the live digest, which is taken after the pristine-sampler check).
    • Both retained pre-tree/tree.json records now carry f446b190…. A new test checks that each retained record matches its committed tree.diff and its build type. The run-time tree.json copies inside provenance.json / summary.json / witness.json keep 4181baea… as recorded, and the README says so.
    • New PreTreeProvenance tests use a fake build to check that a snapshot taken over a non-empty diff reopens cleanly, and that a changed binary, diff, shader directory or build type is each refused.
    • Mutation controls, one at a time: going back to the old pre-newline hash breaks the reopen test, and removing each of the four checks breaks its own subtest.
    • Suite: 35 tests OK on Windows and on WSL2 Ubuntu.
    • Real-data control: the host's live Debug and Release snapshots were both refused by the new check (CRLF diff). I rewrote them to the committed bytes and record, and both now reopen with every field matching.
  • linux-build: CI's job for this push.
    — worker

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review — render: add a composite draw witness and attribute the gl query cost

Verdict: approve

The current delta resolves the retained-snapshot integrity defect and keeps the diagnostic isolated from the measured shader path.

Praise

  • docs/perf/sun-overflowed-tile-query/run_matrix.py::snapshot now records the exact tree.diff bytes it writes, while tree_provenance checks the binary, diff, shader set, and build type before a pre-tree is reused.
  • engine/prefabs/irreden/render/composite_draw_witness.hpp::Recorder continues to bracket production draws externally and replays ownership separately, preserving the measured path.

Checked

  • Read the complete #4935 issue thread; PR metadata, commits, discussion, reviews, and inline-comment set; the changed render/device code, controller, and retained evidence summaries.
  • python3 docs/perf/sun-overflowed-tile-query/test_controller.py — passed: 35 tests.
  • git diff --check origin/master...HEAD — passed.
  • fleet-build --detach --target IRCanvasStress, terminal fleet-jobs wait — succeeded, exit 0 (macOS Metal build).
  • linux-build, render-harness-tests, and perf-gate are in progress and unread, not treated as passing.
  • Acceptance: #5183 is a correctly scoped phase-0 prerequisite referenced by #4935, rather than completion of its superseding shipped-lever plan. The intentionally deferred GL-cut, render-verify, and Metal criteria are documented as such.

Test plan the author should run before merge

  • Let the in-progress Linux build, render-harness, and perf-gate checks complete successfully.
  • Re-run the GL witness on its Windows target after any composite draw-state change.

Escalation: please Opus-recheck before merge (touches: engine/render and GL pipeline-statistics / depth-stencil replay diagnostics).

🤖 Reviewed by Codex GPT-5 (sonnet-reviewer role; review-pr skill)
Opus recheck required: the GL-only pipeline-statistics and first-claim depth/stencil replay need final review on their native render path.

@jakildev jakildev added fleet:needs-opus-recheck Sonnet flagged this PR for Opus recheck before merge and removed fleet:changes-made Agent addressed human feedback — ready for human re-review fleet:reviewing-mac-pool-4 labels Nov 18, 2026
@github-actions

Copy link
Copy Markdown

Perf gate

Head host slug: linux-x86_64-epyc-9v45-96-unknown

perf comparison: 1600afd → 74e86c2-ci

baseline: /home/runner/work/_temp/perf-baseline/history/linux-x86_64-epyc-9v45-96-unknown/1600afdc75aed2694fc947eb4acc7f42e4b2406b
head: /home/runner/work/IrredenEngine/IrredenEngine/save_files/perf/74e86c20e-ci

host calibration

  • host: linux-x86_64-epyc-9v45-96-unknown (matches baseline)
  • ref_ms: head 59.98 vs baseline 58.62 (load_factor 1.02×)
  • calibration target: 50.00 ms (informational)
  • baseline capture: perf-baseline@1600afdc7 (branch tip); master a914699df, finished 2026-11-17T18:23:28Z, 0.6 d before the head run, ref_ms 58.62
  • weighting: raw (class-matched capture; load_factor 1.02×; no calibration-scaling entry)
  • attribution: no measured master improvement between capture master a914699df and merge base 18a91f694 (13 commits)

thresholds: regress ≥ 10%, improve ≥ 5%

voxel cull effectiveness

cell ratio (base→head) avg visible total avg feeder
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 1024 → 1024 0 → 0
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.598 → 0.598 (+0.0pp) 156630 → 156630 1024 → 1024 0 → 0
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 1024 → 1024 0 → 0
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.975 → 0.975 (+0.0pp) 255592 → 255592 1024 → 1024 0 → 0

frame timing (ms)

cell avg p99
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 334.67 → 339.32 (+1.4%) 1009.08 → 1014.21 (+0.5%)
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 729.45 → 750.93 (+2.9%) 1402.16 → 1440.67 (+2.7%)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 419.20 → 419.96 (+0.2%) 6041.55 → 6110.74 (+1.1%)
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 1038.93 → 1066.49 (+2.7%) 1750.45 → 1721.89 (-1.6%)

GPU frame timing (ms; separate from stage samples)

cell envelope (base→head) buffer spans (base→head) coverage (base→head)
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable

GPU stage timing (avg ms per sampled invocation)

cell canvasClear voxelCompact voxelStage1 voxelCardinalElect voxelStage2 voxelSunFaces textToTrixel buildLightOcclusionGrid computeVoxelAO bakeSunShadowMap computeSunShadow computeLightVolume lightingToTrixel fogToTrixel trixelToFb resolvePerAxisScreenDepth fbToScreen
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 12.94→13.21 38.31→39.24 34.21→35.39 0.60→0.64 33.78→34.67 57.75→58.10 — 0.00→0.00 2.26→2.26 17.55→18.19 12.59→12.85 11.85→12.26 2.49→2.54 0.88→0.86 0.15→0.11 ↓ — 5.09→5.10
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 13.45→13.73 174.93→179.04 146.62→152.49 2.26→2.43 134.13→138.14 92.68→97.24 — 0.00→0.00 1.90→2.00 29.40→30.29 11.32→11.15 10.19→10.83 5.20→5.55 0.91→0.92 0.11→0.12 — 4.83→4.94
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 12.20→11.97 44.70→44.76 38.16→38.30 5.47→5.53 30.70→31.78 53.92→54.19 0.73→0.73 0.00→0.00 4.61→4.48 37.98→34.68 ↓ 11.95→11.88 25.69→25.24 4.14→4.32 1.17→1.17 0.11→0.11 ↓ 0.00→0.00 5.66→5.74
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 12.62→12.86 279.88→298.75 236.71→240.90 3.66→3.68 209.06→211.57 98.13→98.39 0.72→0.75 0.00→0.00 2.06→1.96 39.22→39.97 11.50→12.30 10.62→10.59 4.42→4.24 0.98→0.97 0.11→0.10 ↓ 0.00→0.00 4.71→4.87

top CPU systems by avg ms (head)

target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 180.112 → 183.885 (+2.1%)
RENDER ComputeLightVolume 24.096 → 24.794 (+2.9%)
RENDER ComputeSunShadow 12.907 → 13.430 (+4.1%)
RENDER CanvasToFramebuffer 11.391 → 11.986 (+5.2%)
RENDER BakeSunShadowMap 6.815 → 6.913 (+1.4%)
UPDATE FogRevealEval 3.825 → 3.780 (-1.2%)
UPDATE PropagateTransform 2.917 → 2.793 (-4.3%)
RENDER LightingToTrixel 2.605 → 2.643 (+1.5%)

target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 563.873 → 582.095 (+3.2%)
RENDER ComputeSunShadow 25.516 → 26.346 (+3.3%)
RENDER ComputeLightVolume 21.208 → 21.652 (+2.1%)
RENDER CanvasToFramebuffer 10.526 → 10.789 (+2.5%)
RENDER BakeSunShadowMap 5.858 → 5.990 (+2.3%)
RENDER ComputeVoxelAO 5.546 → 5.925 (+6.8%)
RENDER LightingToTrixel 5.334 → 5.693 (+6.7%)
UPDATE FogRevealEval 3.819 → 3.784 (-0.9%)

target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 199.623 → 202.464 (+1.4%)
RENDER ComputeSunShadow 33.508 → 30.227 (-9.8%) ↓
RENDER ComputeLightVolume 23.367 → 23.353 (-0.1%)
RENDER LightingToTrixel 15.265 → 14.707 (-3.7%)
RENDER CanvasToFramebuffer 12.228 → 11.919 (-2.5%)
RENDER BakeSunShadowMap 8.484 → 8.407 (-0.9%)
UPDATE PropagateTransform 3.740 → 3.804 (+1.7%)
RENDER FogToTrixel 3.592 → 3.741 (+4.1%)

target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 840.096 → 866.299 (+3.1%)
RENDER ComputeSunShadow 34.897 → 35.764 (+2.5%)
RENDER ComputeLightVolume 21.870 → 22.583 (+3.3%)
RENDER CanvasToFramebuffer 10.803 → 10.618 (-1.7%)
RENDER BakeSunShadowMap 6.192 → 5.961 (-3.7%)
RENDER ComputeVoxelAO 4.609 → 4.646 (+0.8%)
RENDER LightingToTrixel 4.541 → 4.365 (-3.9%)
UPDATE PropagateTransform 3.772 → 3.819 (+1.2%)

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Opus reviewer recheck

Verdict: approve

Sonnet flagged the retained-evidence provenance mismatch and cross-host controller concerns; on closer read I confirm both are resolved at the current head. The prior Opus finding is fixed: the pre-tree snapshots are now written and hashed as exact bytes, their records pin the committed-byte hash, and the retained older run provenance is described without rewriting historical output.

Checked

  • Read the complete PR and #4935 threads, reviewed the current-head delta, and traced the witness through the canvas-to-framebuffer, render-device, OpenGL query, replay, and controller paths.
  • Verified both retained pre-tree tree.diff files hash to f446b1906f35e2a1c9ac655fe88fbf74824c9153f4c8eb48ef9b35f0e6aa94bd, matching their tree.json records.
  • Ran python3 docs/perf/sun-overflowed-tile-query/test_controller.py: 35 tests passed.
  • Ran git diff --check origin/master...HEAD: passed.
  • Current CI is green for changes, lint/reference checks, formatting, header/instruction checks, perf gate, render harness tests, and whitespace. linux-build and the aggregate all-checks were still pending at review time and are not claimed as passing evidence here.

Test plan

  • Let linux-build and all-checks complete before merge.
  • Re-run the GL witness after future render-state or composite-draw changes, preserving first-claim replay and exact-byte provenance checks.

Human merge authority remains with the maintainer.

🤖 Reviewed by Codex GPT-5 (opus-reviewer role; review-pr skill)

@jakildev jakildev added fleet:approved Fleet reviewer approved — ready for human merge fleet:needs-macos-smoke PR needs macos-debug build + smoke-run validation and removed fleet:needs-opus-recheck Sonnet flagged this PR for Opus recheck before merge fleet:reviewing-mac-pool-2 labels Nov 18, 2026
@jakildev jakildev added fleet:verified-macos Cross-host smoke passed on macos-debug and removed fleet:needs-macos-smoke PR needs macos-debug build + smoke-run validation labels Nov 18, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Cross-host smoke OK on macos (fresh checkout + IRShapeDebug --auto-screenshot 10 — build clean, exit 0, no shader/compiler log warnings; ir-run: RESULT=CLEAN). Runtime: Codex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fleet:approved Fleet reviewer approved — ready for human merge fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-windows PR was opened from a Windows (MSYS2) host fleet:verified-macos Cross-host smoke passed on macos-debug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant