Repository navigation
Conversation
String.intern() and Jackson's INTERN_FIELD_NAMES, on by default, put text read from input in the JVM's string table, which outlives the parse: it grows with the input's cardinality and can retain customer data. J15 flags it and points to per-parse sharing instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
J16: returning a shared sentinel (an empty iterator, a cached result) on some paths makes the result a merged allocation C2 won't scalar-replace, and inheriting AbstractList's iterator, isEmpty or forEach for a hot traversal shares a profile that goes megamorphic in an application. Both keep short-lived objects escape analysis would otherwise remove. The check asks the reviewer to judge the returned object's lifetime: sharing a long-lived object is still a win. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EscapeShapeBenchmark measures the shared-sentinel, two-allocation and null merges across JDKs, including mergeWithNull, which allocates until JDK 21+ and so still matters on Java 8. Maybe is the worked example of the single-construction-site discipline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
What Does This Do
Adds two checks to the AI perf review:
String.intern(), and Jackson'sJsonFactory.Feature.INTERN_FIELD_NAMES(on by default), when they're applied to text read from input: a configuration, a payload, a header or a parsed document.AbstractList's orAbstractCollection's iterator,isEmpty()orforEach.Motivation
The JVM's string table outlives the parse, so interned input stays for the life of the process:
dd-openfeature hit this: Jackson's default interned flag keys, variation keys and the keys of JSON values from its configuration. #13553 turns it off and shares strings per parse instead.
Why J16: both look like wins and aren't.
size()/get()calls go megamorphic and the iterator escapes. A quiet benchmark JVM hides this.PrintInliningshowedAbstractList$Itr'ssize()andget()as virtual calls, and a class with its own iterator inlined everything. In evaluations it was up to +174% time and +66 KB per evaluation, and the fix matched master's bytes.Additional Notes
INTERN_FIELD_NAMESoff on theJsonFactory. It doesn't name a toolbox class yet; a per-parseStringCanonicalizeris proposed in Add a bounded, per-parse StringCanonicalizer to the toolbox (FFE optimization) #13588, and the remedies list can point to it once that merges.Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issue🤖 Generated with Claude Code