perf(gotemplate-helm): skip the quote-normalize regex on quoteless lines#509
Merged
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! |
Contributor
|
alexmond
added a commit
that referenced
this pull request
Jun 29, 2026
Adds docs/performance.adoc documenting jhelm's profile-driven performance work, modelled on the gotmpl4j performance page but adapted to jhelm's layer (chart rendering, not engine-vs-engine throughput). Covers: the jhelm-vs-gotmpl4j layer split (and a link to gotmpl4j's own perf page), the 540-chart parity corpus as the render benchmark, the jvmlens live-attach methodology (incl. the surefire dumponexit gotcha and scoping to org.alexmond.jhelm), where render time actually goes (parse/lex vs inherent chart crypto vs jhelm orchestration), how to read share- inversion in a profile diff, and an optimization-history table with the measured jvmlens deltas for #573 (double-parse elimination) and #509 (toYaml quote-normalize fast-path). Linked into the nav after Core Engine. Claude-Session: https://claude.ai/code/session_01U5yvjG89AqMHPAGJawSmg9 Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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