Repository navigation
perf: stop the flaky perf gate false-failing on noisy TUI render allocs - #84
Merged
Merged
Conversation
The github-action-benchmark "scenarios (smaller-is-better)" gate compared one PR run's allocs/op against the single previous-main value at a flat 2% threshold with fail-on-alert. Two TUI render metrics were never actually deterministic: gh-pages history showed tui_scrollback_view swinging ~4.6% and tui_scrollback_view_steady ~30% across commits that touched zero TUI code. PR #83 (docs+CI only, no Go) false-failed because the previous-main commit happened to be a low outlier. perf.yml's own comment anticipated this and prescribed the escalation taken here. Two independent root causes, both fixed: A. Benchmark determinism. AllocsPerOp = total_allocs / b.N, and b.N is chosen from timing (runner-speed-dependent). BenchmarkScrollbackView called appendAssistant(".") every op, growing the live block unboundedly -> total allocs superlinear in b.N -> allocs/op rose with runner speed. New reviseAssistant() reducer replaces the live block with a fixed-SIZE, byte-different body each op through the currentAssistant() rev-bump gateway: the render+join caches still MISS every op (worst-case streaming floor preserved) but the block does not grow, so allocs/op is now b.N-independent. Guarded by TestScrollbackReviseAllocsIndependentOfN (mutation-verified: the old growth bug fails it at delta=456970 vs +/-1 tolerance) and TestScrollbackReviseBustsCacheEveryOp (asserts the join still all-misses so the bench keeps measuring the hotspot). B. Gate restructure. perfconvert now emits a THIRD dedicated advisory suite (-render) carrying only the two noisy render-alloc points; perf.yml runs it with fail-on-alert:false in both jobs. Every deterministic gate stays hard: the render benches' tokens_total and goroutine_delta remain in the smaller suite, non-TUI scenario allocs stay hard, the bigger cache-hit suite is unchanged, and the allocsgate-over-task-bench gate is untouched. SHA-pins preserved; gh-pages fetch ordering across the now-three steps preserved (smaller fetches first; bigger and render use skip-fetch-gh-pages in perf-pr). Reviewed via the panel (spec/standards/devops/QA): clean, no must-fix. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
The
perf-pr"scenarios (smaller-is-better)" gate was false-failing on noise. It compared one PR run's allocs/op against the single previous-main value on gh-pages at a flatalert-threshold: '102%'withfail-on-alert: true. Two TUI render metrics —tui_scrollback_view/allocs_per_opandtui_scrollback_view_steady/allocs_per_op— were never actually deterministic: gh-pages history showsviewswinging ~4.6% andsteady~30% across recent main commits that touched zero TUI code. PR #83 (docs + CI only, no Go) tripped it because the previous-main commit happened to be a low outlier.perf.yml's own comment anticipated exactly this and prescribed the escalation taken here.Two independent root causes, both fixed
A — Benchmark determinism
AllocsPerOp = total_allocs / b.N, andb.Nis chosen from timing (runner-speed-dependent).BenchmarkScrollbackViewcalledappendAssistant(".")every op, growing the live block unboundedly → total allocs superlinear inb.N→ allocs/op rose with runner speed.New
reviseAssistant()reducer replaces the live block with a fixed-size, byte-different body each op, through thecurrentAssistant()rev-bump gateway: the render + join caches still miss every op (the worst-case streaming floor the bench targets is preserved) but the block no longer grows, so allocs/op isb.N-independent.Guards (both mutation-verified):
TestScrollbackReviseAllocsIndependentOfN— fails at Δ=456970 vs ±1 tolerance if reverted to the growth bug.TestScrollbackReviseBustsCacheEveryOp— asserts the join still all-misses, so the bench keeps measuring the hotspot.B — Gate restructure (the prescribed escalation)
perfconvertnow emits a third dedicated advisory suite (-render) carrying only the two noisy render-alloc points;perf.ymlruns it withfail-on-alert: falsein both jobs. Every deterministic gate stays hard: the render benches'tokens_total+goroutine_deltaremain in the smaller suite, non-TUI scenario allocs stay hard, the bigger cache-hit suite is unchanged, and the separate allocsgate-over-task benchgate is untouched. SHA-pins preserved; gh-pages fetch ordering across the now-three github-action-benchmark steps preserved (smaller fetches first; bigger and render useskip-fetch-gh-pagesinperf-pr).C — Docs
perf.ymlcomments,docs/adr/0019-perf-tracking.md, and the perfconvert + bench doc-comments updated; the "if a 2% false positive ever fires, split…" note flipped to "shipped."Review & verification
Run through the dev pipeline: architect plan → separate implementer → 4-axis panel (spec / standards / devops-expert / QA test-adequacy) → 1 iteration → commit. Panel verdict: clean, no must-fix.
task test(full, -race) green; scopedgolangci-lint+actionlintclean; manualperfconvert -renderempty-suite round-trip emits a valid[].Follow-up (optional, not in this PR)
Both render-alloc points went advisory. Once the dashboard shows
view's post-fix variance (A should make it near-deterministic),viewcould be re-tightened to a hard gate — a cheap follow-up.🤖 Generated with Claude Code