Conversation
…-up to BenchmarkYAMLGeneration - Unify all 7 warm-up comments to the same phrasing: "Warm up: run once before timing to prime one-time caches (schema compilation, etc.)" - Remove redundant '// Track memory allocations' comment in BenchmarkCompileMemoryUsage - Add missing warm-up + b.ResetTimer() to BenchmarkYAMLGeneration, consistent with all other benchmarks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Follow-up cleanup to standardize benchmark warm-up comments and ensure BenchmarkYAMLGeneration includes a warm-up + b.ResetTimer() for more accurate measurements.
Changes:
- Standardized warm-up comment phrasing across benchmarks in
compiler_performance_benchmark_test.go. - Added a warm-up compile +
b.ResetTimer()toBenchmarkYAMLGeneration. - Removed a redundant “Track memory allocations” inline comment (since
b.ReportAllocs()already conveys this).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+336
to
341
| _ = compiler.CompileWorkflow(testFile) | ||
|
|
||
| b.ResetTimer() | ||
| b.ReportAllocs() | ||
| for b.Loop() { | ||
| _ = compiler.CompileWorkflow(testFile) |
There was a problem hiding this comment.
The warm-up compile ignores the returned error. If compilation starts failing, the benchmark will silently measure the error path (and still report results), which can be misleading. Consider checking the error in the warm-up call (and/or the timed loop) and calling b.Fatal on failure so the benchmark fails fast.
Suggested change
| _ = compiler.CompileWorkflow(testFile) | |
| b.ResetTimer() | |
| b.ReportAllocs() | |
| for b.Loop() { | |
| _ = compiler.CompileWorkflow(testFile) | |
| if err := compiler.CompileWorkflow(testFile); err != nil { | |
| b.Fatalf("warm-up compilation failed: %v", err) | |
| } | |
| b.ResetTimer() | |
| b.ReportAllocs() | |
| for b.Loop() { | |
| if err := compiler.CompileWorkflow(testFile); err != nil { | |
| b.Fatalf("benchmark compilation failed: %v", err) | |
| } |
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.
Follow-up cleanup to #22464, which added warm-up phases to benchmarks.
Files Simplified
pkg/workflow/compiler_performance_benchmark_test.go— consistent warm-up patterns across all 7 benchmarksImprovements Made
1. Unified warm-up comment phrasing
Three different comment styles existed after #22464:
"Warm up: run once before timing to prime one-time caches (schema compilation, etc.)"(×3)"Warm up: run once before timing to initialize one-time caches\n// (schema compilation, regex caches) so they don't skew per-op metrics."(×1)"Warm up: prime the schema compilation cache before timed measurement."(×2)All 7 benchmarks now use the same phrasing.
2. Added missing warm-up to
BenchmarkYAMLGenerationBenchmarkYAMLGenerationwas the only benchmark without a warm-up phase orb.ResetTimer()call, even though it runscompiler.CompileWorkflow(which involves schema compilation). Added warm-up +b.ResetTimer()for measurement accuracy consistent with all other benchmarks.3. Removed redundant inline comment
// Track memory allocationsbefore the benchmark loop inBenchmarkCompileMemoryUsagewas redundant —b.ReportAllocs()already conveys this intent.Changes Based On
Testing
go test -bench BenchmarkCompileSimpleWorkflow|BenchmarkYAMLGeneration -benchtime=1x)go test -run TestCompile ./pkg/workflow/)go build ./pkg/workflow/)