-
Notifications
You must be signed in to change notification settings - Fork 352
perf: fix BenchmarkCompileMemoryUsage regression (+81.9%) — faster YAML parser + benchmark warm-up #22464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pelikhan
merged 4 commits into
main
from
copilot/fix-regression-in-compile-memory-usage
Mar 23, 2026
Merged
perf: fix BenchmarkCompileMemoryUsage regression (+81.9%) — faster YAML parser + benchmark warm-up #22464
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0629011
Initial plan
Copilot f48649b
perf: fix BenchmarkCompileMemoryUsage regression - faster YAML parser…
Copilot 5d6250a
Merge branch 'main' into copilot/fix-regression-in-compile-memory-usage
pelikhan d0e8d74
Merge branch 'main' into copilot/fix-regression-in-compile-memory-usage
pelikhan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -40,6 +40,10 @@ Analyze the issue: ${{ steps.sanitized.outputs.text }} | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| compiler := NewCompiler() | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Warm up: run once before timing to prime one-time caches (schema compilation, etc.) | ||||||||||||||||||||||||||||||||||
| _ = compiler.CompileWorkflow(testFile) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| b.ResetTimer() | ||||||||||||||||||||||||||||||||||
| b.ReportAllocs() | ||||||||||||||||||||||||||||||||||
| for b.Loop() { | ||||||||||||||||||||||||||||||||||
| _ = compiler.CompileWorkflow(testFile) | ||||||||||||||||||||||||||||||||||
|
|
@@ -98,6 +102,10 @@ Review the pull request: ${{ github.event.pull_request.number }} | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| compiler := NewCompiler(WithNoEmit(true)) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Warm up: run once before timing to prime one-time caches (schema compilation, etc.) | ||||||||||||||||||||||||||||||||||
| _ = compiler.CompileWorkflow(testFile) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| b.ResetTimer() | ||||||||||||||||||||||||||||||||||
| b.ReportAllocs() | ||||||||||||||||||||||||||||||||||
| for b.Loop() { | ||||||||||||||||||||||||||||||||||
| _ = compiler.CompileWorkflow(testFile) | ||||||||||||||||||||||||||||||||||
|
|
@@ -145,6 +153,10 @@ Review and test the pull request with multiple tools. | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| compiler := NewCompiler(WithNoEmit(true)) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Warm up: run once before timing to prime one-time caches (schema compilation, etc.) | ||||||||||||||||||||||||||||||||||
| _ = compiler.CompileWorkflow(testFile) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| b.ResetTimer() | ||||||||||||||||||||||||||||||||||
| b.ReportAllocs() | ||||||||||||||||||||||||||||||||||
| for b.Loop() { | ||||||||||||||||||||||||||||||||||
| _ = compiler.CompileWorkflow(testFile) | ||||||||||||||||||||||||||||||||||
|
|
@@ -194,6 +206,11 @@ Standard workflow for memory profiling. | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| compiler := NewCompiler(WithNoEmit(true)) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Warm up: run once before timing to initialize one-time caches | ||||||||||||||||||||||||||||||||||
| // (schema compilation, regex caches) so they don't skew per-op metrics. | ||||||||||||||||||||||||||||||||||
| _ = compiler.CompileWorkflow(testFile) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| b.ResetTimer() | ||||||||||||||||||||||||||||||||||
| b.ReportAllocs() | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Track memory allocations | ||||||||||||||||||||||||||||||||||
|
|
@@ -232,6 +249,10 @@ Test parsing performance. | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| compiler := NewCompiler() | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Warm up: prime the schema compilation cache before timed measurement. | ||||||||||||||||||||||||||||||||||
| _, _ = compiler.ParseWorkflowFile(testFile) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| b.ResetTimer() | ||||||||||||||||||||||||||||||||||
| b.ReportAllocs() | ||||||||||||||||||||||||||||||||||
| for b.Loop() { | ||||||||||||||||||||||||||||||||||
| _, _ = compiler.ParseWorkflowFile(testFile) | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+253
to
258
|
||||||||||||||||||||||||||||||||||
| _, _ = compiler.ParseWorkflowFile(testFile) | |
| b.ResetTimer() | |
| b.ReportAllocs() | |
| for b.Loop() { | |
| _, _ = compiler.ParseWorkflowFile(testFile) | |
| if _, err := compiler.ParseWorkflowFile(testFile); err != nil { | |
| b.Fatalf("warm-up ParseWorkflowFile failed: %v", err) | |
| } | |
| b.ResetTimer() | |
| b.ReportAllocs() | |
| for b.Loop() { | |
| if _, err := compiler.ParseWorkflowFile(testFile); err != nil { | |
| b.Fatalf("ParseWorkflowFile 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warm-up compile call ignores the returned error. If the test input becomes invalid (or CompileWorkflow starts returning errors for a regression), the benchmark will silently measure an error path. Consider checking the warm-up error and failing the benchmark (e.g., b.Fatal/b.Fatalf) before resetting the timer.
This issue also appears in the following locations of the same file: