perf(gotemplate-helm): skip the quote-normalize regex on quoteless lines#509
Open
alexmond wants to merge 1 commit into
Open
perf(gotemplate-helm): skip the quote-normalize regex on quoteless lines#509alexmond wants to merge 1 commit into
alexmond wants to merge 1 commit into
Conversation
Profiling a gitlab render loop (jvmlens over a JFR) showed
ConversionFunctions.removeUnnecessaryQuotes at 6% CPU and 1.2 GB allocation —
it ran the QUOTED_VALUE regex (plus a Matcher) on every line of every toYaml /
toJson output. QUOTED_VALUE requires a double-quoted scalar, so a line with no
'"' can never match; the large majority of rendered-manifest lines are unquoted.
Add an `indexOf('"') < 0` fast path that appends such lines verbatim and skips
the regex entirely. Behaviour-identical (a quoteless line takes the old
no-match branch). Also size the StringBuilder to the input length.
Measured (jvmlens diff, 120x gitlab render): removeUnnecessaryQuotes GONE from
both hot paths (was 6% CPU) and allocation sites (was 1.2 GB); total allocation
23.4 GB -> 22.2 GB (-1.1 GB, -5%). Verified byte-identical: 88
jhelm-gotemplate-helm tests green (ConversionFunctionsTest, HelmConformanceTest).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U5yvjG89AqMHPAGJawSmg9
Contributor
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Profiling a gitlab render loop (JFR → jvmlens) surfaced
ConversionFunctions.removeUnnecessaryQuotesas 6% CPU and 1.2 GB allocation — it ran theQUOTED_VALUEregex + aMatcheron every line of everytoYaml/toJsonoutput. ButQUOTED_VALUErequires a double-quoted scalar, and the large majority of rendered-manifest lines are unquoted.Fix
An
indexOf('"') < 0fast-path appends quoteless lines verbatim and skips the regex entirely (+ size theStringBuilderto the input). Behaviour-identical — a quoteless line takes the old no-match branch.Measured (jvmlens diff, 120× gitlab render)
removeUnnecessaryQuotes— GONE from both hot paths (was 6% CPU) and allocation sites (was 1.2 GB)Correctness
88
jhelm-gotemplate-helmtests green (ConversionFunctionsTestcovers toYaml byte-output,HelmConformanceTest); 346-chart byte-parity running as a safety net.Profiling also surfaced an engine-side allocator (
gotmpl4j CharUtils.isAnyOfdoing anIntStreamper call in the lexer, ~2 GB) — filed as alexmond/gotmpl4j#64.🤖 Generated with Claude Code