Closed
perf: fix CompileMemoryUsage regression — switch compiled-YAML parsing to yaml.v3#44353
Conversation
Switch compiled-YAML parsing from goccy/go-yaml to gopkg.in/yaml.v3 in compiler.go and schema_validation.go. The goccy library allocates ~82,631 objects parsing a 100KB compiled YAML; yaml.v3 only allocates ~15,607 (5x fewer). Both libraries return map[string]any for YAML mappings, making yaml.v3 a drop-in replacement for this path. Also extend allowedRunScriptExpressionRegex to include toJSON(...) patterns, preventing false-positive hasDisallowed flags for compiler-generated toJSON() wrapper expressions in run blocks (e.g. sink-visibility runtime expressions in mcp_renderer_guard.go), which would otherwise trigger an unnecessary yaml.Unmarshal in the text-scan path. Result: BenchmarkCompileMemoryUsage goes from 94,323 allocs/op back to ~9,421 allocs/op, matching the historical baseline of 9,441 allocs/op. Timing improves from 17.4ms to ~4.9ms (better than the 7.78ms baseline). Fixes #44345 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix performance regression in CompileMemoryUsage
perf: fix CompileMemoryUsage regression — switch compiled-YAML parsing to yaml.v3
Jul 8, 2026
Contributor
🤖 PR Triage
Status: DRAFT — needs undraft + CI before review. Fixes 124% alloc regression in Run §28966928999
|
Contributor
🤖 PR Triage
Score breakdown: Impact 18 + Urgency 14 + Quality 10 Rationale: DRAFT. Fixes CompileMemoryUsage regression by switching to yaml.v3 parsing. Performance improvement, not critical path. Defer until undraft + CI. Run §28986426320
|
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.
BenchmarkCompileMemoryUsageregressed 124% (~9,441 → ~94,323 allocs/op) due togoccy/go-yamlallocating ~82,631 objects parsing a 100KB compiled workflow YAML.gopkg.in/yaml.v3does the same parse in ~15,607 allocs (5×fewer), and is already a dependency.Changes
compiler.go,schema_validation.go— switch allyaml.Unmarshalcall sites fromgoccy/go-yamltogopkg.in/yaml.v3. Both libraries returnmap[string]anyfor YAML mappings, making this a drop-in replacement.template_injection_validation.go— extendallowedRunScriptExpressionRegexto includetoJSON(...)patterns. The compiler emits${{ toJSON(steps.determine-automatic-lockdown.outputs.visibility) }}inside heredoc run blocks; without this, the text scanner setshasDisallowed=trueand triggers a redundantyaml.Unmarshalon the skip-validation path.Result