[repository-quality] Repository Quality Improvement Report - Benchmark Infrastructure Completeness & Regression Prevention #44737
Closed
Replies: 1 comment
-
|
This discussion was automatically closed because it expired on 2026-07-11T13:40:44.688Z.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🎯 Repository Quality Improvement Report - Benchmark Infrastructure Completeness & Regression Prevention
Analysis Date: 2026-07-10
Focus Area: Benchmark Infrastructure Completeness & Regression Prevention
Strategy Type: Reuse
Custom Area: No — reuse of 2026-06-11/2026-06-16 runs (highest 3-high-priority count in last 10); random value 94 → ≥90 triggers reuse
Executive Summary
The benchmark suite has grown to 97 functions across 23 test files, but allocation instrumentation remains at 19% adoption (18/97 have
b.ReportAllocs()). The 79 functions missing this call produce structurally incomplete benchmark data:make benchwith-benchmemreports allocations only when the benchmark itself opts in viab.ReportAllocs(). The daily-cli-performance workflow's regression detection is therefore blind to allocation regressions in 81% of the codebase's benchmarks.Since the June 16 reuse run, the
compiler_performance_benchmark_test.gofile was correctly instrumented (all 7 functions haveb.ResetTimer()+b.ReportAllocs()), but the 16 remaining benchmark files show zero adoption. Four benchmarks still use the deprecatedfor i := 0; i < b.Norfor range b.Npattern instead of Go 1.24+b.Loop(), missing automatic warm-up iteration exclusion.The
daily-cli-performance.mdworkflow monitors only 5 named benchmarks (BenchmarkCompileSimpleWorkflow,BenchmarkCompileComplexWorkflow,BenchmarkCompileMCPWorkflow,BenchmarkCompileMemoryUsage,BenchmarkParseWorkflow), leaving 92 other benchmarks unmonitored for trend regression. Amake bench-regressionMakefile target that runsbenchstatover cached baselines is referenced in documentation but does not exist;benchstatis also not installed.Full Analysis Report
Focus Area: Benchmark Infrastructure Completeness & Regression Prevention
Current State Assessment
Metrics Collected:
b.ReportAllocs()b.ResetTimer()b.Nloopb.Loop()benchstatinstalledb.ReportAllocs()Files with most missing
b.ReportAllocs()(top 6 by gap):pkg/workflow/expressions_benchmark_test.gopkg/cli/logs_benchmark_test.gopkg/stringutil/sanitize_test.gopkg/workflow/processing_benchmark_test.gopkg/workflow/compiler_benchmark_test.gopkg/workflow/regex_benchmark_test.goFiles with old
b.Nloop pattern:pkg/stringutil/urls_test.gopkg/workflow/js_comments_test.gopkg/workflow/concurrency_validation_test.gopkg/workflow/template_injection_validation_benchmark_test.goFindings
Strengths
compiler_performance_benchmark_test.gois fully instrumented withb.ResetTimer()+b.ReportAllocs()on all 7 functions.compile_security_benchmark_test.gohasb.ReportAllocs()on all 7 functions.b.Loop()pattern.daily-cli-performance.mdprovides a regression baseline framework with repo-memory storage and Python trend analysis.make benchtarget uses-benchmemflag, which is a prerequisite for allocation measurement.Areas for Improvement
b.ReportAllocs():-benchmemat the CLI level does not override the absence ofb.ReportAllocs(); in the goccy/go-yaml-instrumented ecosystem, allocation counts are unreported without the in-benchmark call.b.Niteration pattern instead ofb.Loop(), missing the automatic warm-up exclusion thatb.Loop()provides in Go 1.24+.benchstatis documented in instructions and Makefile comments but not installed;make bench-compareoutputs an advisory to use it but cannot run it.Detailed Analysis
The
-benchmemflag passed togo testenables allocation reporting at the test binary level, but individual benchmarks must callb.ReportAllocs()for their own allocation metrics to appear in output. Without it,allocs/opandB/opcolumns are suppressed per-benchmark even when-benchmemis passed. This meansmake benchproduces meaningful allocation data only for the 18 instrumented benchmarks.The highest-impact gap is in
expressions_benchmark_test.go(11 benchmarks covering expression validation and parsing),logs_benchmark_test.go(10 benchmarks covering log parsing for all engines), andprocessing_benchmark_test.go(7 benchmarks covering tools/safe-outputs/permissions processing). These cover performance-critical paths where allocation regressions directly affect user-visible latency.Setup-heavy benchmarks in
compiler_benchmark_test.gocreate temporary directories and write files beforeb.Loop()but withoutb.ResetTimer(). Theb.Loop()method in Go 1.24 does record a setup phase separately, butb.ResetTimer()before the loop is still the idiomatic way to exclude one-time setup allocation from the per-iteration reports.🤖 Tasks for Copilot Agent
NOTE TO PLANNER AGENT: Split the following tasks into individual work items.
Improvement Tasks
Task 1: Add
b.ReportAllocs()to All Benchmark Functions inexpressions_benchmark_test.goandprocessing_benchmark_test.goPriority: High
Estimated Effort: Small
Focus Area: Benchmark Infrastructure
Description: 18 benchmark functions in
pkg/workflow/expressions_benchmark_test.go(11) andpkg/workflow/processing_benchmark_test.go(7) have nob.ReportAllocs()call. Add it as the first statement in each benchmark function body, before any setup code and beforeb.Loop(). This makes allocation data visible inmake benchoutput and enables regression detection.Acceptance Criteria:
expressions_benchmark_test.gohaveb.ReportAllocs()as the first call.processing_benchmark_test.gohaveb.ReportAllocs()as the first call.go test -bench=. -benchmem -run=^$ ./pkg/workflow/showsallocs/opandB/opcolumns for all affected benchmarks.Code Region:
pkg/workflow/expressions_benchmark_test.go,pkg/workflow/processing_benchmark_test.goTask 2: Add
b.ReportAllocs()to All Benchmark Functions inlogs_benchmark_test.go,compiler_benchmark_test.go, andregex_benchmark_test.goPriority: High
Estimated Effort: Small
Focus Area: Benchmark Infrastructure
Description: 23 additional benchmark functions across
pkg/cli/logs_benchmark_test.go(10),pkg/workflow/compiler_benchmark_test.go(7), andpkg/workflow/regex_benchmark_test.go(6) lackb.ReportAllocs(). For the compiler benchmarks that also have expensive setup (temp dir creation + file writes), addb.ResetTimer()immediately beforeb.Loop()to exclude setup time from the reported ns/op.Acceptance Criteria:
logs_benchmark_test.gohaveb.ReportAllocs().compiler_benchmark_test.gohaveb.ReportAllocs()andb.ResetTimer()beforeb.Loop().regex_benchmark_test.gohaveb.ReportAllocs().go test -bench=. -benchmem -run=^$ ./pkg/cli/ ./pkg/workflow/confirms allocation data for all affected functions.Code Region:
pkg/cli/logs_benchmark_test.go,pkg/workflow/compiler_benchmark_test.go,pkg/workflow/regex_benchmark_test.goTask 3: Migrate Four
b.NLoop Benchmarks tob.Loop()PatternPriority: Medium
Estimated Effort: Small
Focus Area: Benchmark Infrastructure
Description: Four benchmarks use the deprecated
b.Niteration pattern instead of the Go 1.24b.Loop()method.b.Loop()automatically excludes JIT warm-up iterations from timing and produces more stable results. Migrate all four.File locations:
pkg/stringutil/urls_test.go:130—for range b.N {pkg/workflow/js_comments_test.go:713—for range b.N {pkg/workflow/concurrency_validation_test.go:644—for range b.N {pkg/workflow/template_injection_validation_benchmark_test.go:28—for i := 0; i < b.N; i++ {Acceptance Criteria:
for b.Loop() {with no loop variable.iremains (restructure if needed).go test -bench=. -benchmem -run=^$ ./pkg/stringutil/ ./pkg/workflow/passes without errors.Code Region:
pkg/stringutil/urls_test.go,pkg/workflow/js_comments_test.go,pkg/workflow/concurrency_validation_test.go,pkg/workflow/template_injection_validation_benchmark_test.goTask 4: Add
b.ReportAllocs()to Remaining Benchmark Files (sanitize_test.go,stringutil_test.go,identifiers_test.go,envutil_test.go,frontmatter_benchmark_test.go, and others)Priority: Medium
Estimated Effort: Small
Focus Area: Benchmark Infrastructure
Description: Complete the
b.ReportAllocs()sweep for the remaining benchmark files:pkg/stringutil/sanitize_test.go(8),pkg/stringutil/stringutil_test.go(6),pkg/stringutil/identifiers_test.go(2),pkg/stringutil/urls_test.go(1),pkg/envutil/envutil_test.go(4),pkg/parser/frontmatter_benchmark_test.go(4),pkg/repoutil/repoutil_test.go(2),pkg/cli/commands_utils_test.go(2),pkg/workflow/mcp_benchmark_test.go(1),pkg/workflow/js_test.go(2),pkg/workflow/expression_parser_comprehensive_test.go(2),pkg/workflow/concurrency_validation_test.go(3),pkg/workflow/yaml_test.go(benchmarks if any).Acceptance Criteria:
grep -rn "func Benchmark" pkg/ --include="*_test.go" | wc -lequalsgrep -rn "b.ReportAllocs()" pkg/ --include="*_test.go" | wc -l(100% coverage).go test -bench=. -benchmem -run=^$ ./pkg/...showsallocs/opfor all benchmarks.Code Region:
pkg/stringutil/,pkg/envutil/,pkg/parser/,pkg/repoutil/,pkg/cli/commands_utils_test.go,pkg/workflow/mcp_benchmark_test.go,pkg/workflow/js_test.go,pkg/workflow/expression_parser_comprehensive_test.go,pkg/workflow/concurrency_validation_test.go📊 Historical Context
Previous Focus Areas
🎯 Recommendations
Immediate Actions (This Week)
b.ReportAllocs()toexpressions_benchmark_test.go(11) andprocessing_benchmark_test.go(7) — Priority: Highb.Nloops tob.Loop()— Priority: MediumShort-term Actions (This Month)
b.ReportAllocs()sweep across all 23 benchmark files — Priority: Mediumb.ResetTimer()to setup-heavy benchmarks incompiler_benchmark_test.go— Priority: MediumLong-term Actions (This Quarter)
benchstatin CI and wire amake bench-regressiontarget that compares current run against cached baseline — Priority: Low📈 Success Metrics
Next Steps
References:
Generated by Repository Quality Improvement Agent
Beta Was this translation helpful? Give feedback.
All reactions