Repository navigation
Conversation
A parsed configuration stays in the old generation until the next one replaces it, and every marking cycle walks it. The parser kept a separate String for each occurrence of a text, so attribute names, variation keys, allocation keys, salts and ONE_OF values were repeated thousands of times in a large configuration. A per-parse StringCanonicalizer now returns one instance for each distinct text. String values are canonicalized from Jackson's character buffer, so a repeated value never allocates a String, and field names go through the same table, so a map key and the value that repeats it (the flags key and Flag.key, a variations key, Variant.key and Split.variationKey) share one instance. Jackson's INTERN_FIELD_NAMES is turned off: it put flag keys, variation keys and the keys of JSON values, which are customer data, in the JVM-wide string table. Sharing stays within a parse. 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. |
dougqh
added a commit
that referenced
this pull request
Nov 20, 2026
Shares one String per distinct text within one parse, from a parser's char buffer or from strings, so long-lived parsed state keeps a single copy of each repeated key, id or value. Sharing is per instance, never JVM-wide, because parsed texts can be customer data. Generalized from dd-openfeature's version (#13553) with the review fixes built in: the hashSpread multiply instead of h ^ (h >>> 16), a bound on equal-hash comparisons so input built from colliding strings can't make each lookup compare against all the others, and a length limit above which texts are neither hashed nor shared. StringCanonicalizerBenchmark compares it with plain new String, a HashMap interner and the original version, over generated keys, random ids and colliding strings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dougqh
added a commit
that referenced
this pull request
Nov 20, 2026
Shares one String per distinct text within one parse, from a parser's char buffer or from strings, so long-lived parsed state keeps a single copy of each repeated key, id or value. Sharing is per instance, never JVM-wide, because parsed texts can be customer data. Generalized from dd-openfeature's version (#13553) with the review fixes built in: the hashSpread multiply instead of h ^ (h >>> 16), a bound on equal-hash comparisons so input built from colliding strings can't make each lookup compare against all the others, and a length limit above which texts are neither hashed nor shared. StringCanonicalizerBenchmark compares it with plain new String, a HashMap interner and the original version, over generated keys, random ids and colliding strings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dougqh
added a commit
that referenced
this pull request
Nov 20, 2026
Shares one String per distinct text within one parse, from a parser's char buffer or from strings, so long-lived parsed state keeps a single copy of each repeated key, id or value. Sharing is per instance, never JVM-wide, because parsed texts can be customer data. Generalized from dd-openfeature's version (#13553) with the review fixes built in: the hashSpread multiply instead of h ^ (h >>> 16), a bound on equal-hash comparisons so input built from colliding strings can't make each lookup compare against all the others, and a length limit above which texts are neither hashed nor shared. StringCanonicalizerBenchmark compares it with plain new String, a HashMap interner and the original version, over generated keys, random ids and colliding strings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dougqh
added a commit
that referenced
this pull request
Nov 21, 2026
Shares one String per distinct text within one parse, from a parser's char buffer or from strings, so long-lived parsed state keeps a single copy of each repeated key, id or value. Sharing is per instance, never JVM-wide, because parsed texts can be customer data. Generalized from dd-openfeature's version (#13553) with the review fixes built in: the hashSpread multiply instead of h ^ (h >>> 16), a bound on equal-hash comparisons so input built from colliding strings can't make each lookup compare against all the others, and a length limit above which texts are neither hashed nor shared. StringCanonicalizerBenchmark compares it with plain new String, a HashMap interner and the original version, over generated keys, random ids and colliding strings. 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
A parsed feature flag configuration now keeps one
Stringfor each distinct text, however many times the document repeats it: attribute names, variation keys, allocation keys, salts,ONE_OFvalues, and map keys together with the values that repeat them (theflagskey andFlag.key; avariationskey,Variant.keyandSplit.variationKey).StringCanonicalizer(package-private, not thread-safe, dropped when the parse returns) is an open-addressing table of strings and their hashes. String values are canonicalized from Jackson's character buffer, so a repeated value never allocates aString. Field names go through the same table.INTERN_FIELD_NAMESis turned off. By default it put flag keys, variation keys and the keys of JSON values, which are customer data, in the JVM-wide string table. Field names are still canonicalized in the parser factory's own symbol table (CANONICALIZE_FIELD_NAMESstays on), which outlives a parse but is bounded in size; theStringCanonicalizersharing of values stays within one parse.Motivation
A parsed configuration stays in the old generation until the next one replaces it. Remote Config only delivers changes, and the CDN source skips the parse on a 304, so in production the configuration is long-lived. Every concurrent marking cycle walks it again, so each duplicate costs memory and marking work for its whole life. Duplicate strings were about a quarter of the retained configuration.
Measured on its own by Bits: this PR's head (
d633d4a341) merged locally onto master62d4d1a14e(only a test-file conflict, resolved by keeping both tests), against master62d4d1a14e. The merge keeps #13486'sMembershipIndexout of the comparison. JDK 21, compressed oops.Footprint (JOL, everything reachable from the
ServerConfiguration), and allocation per parse:ufc-config.json(48 flags)scale(10,030 flags)scale-json(10 flags, large JSON values)regexsuitescalesaving (6,140,224 B) is exactly the duplicate-string total the footprint tool reports for master.scaleis 17,128,816 B and 437,384 objects (−37.6%, −45.8%), and canonical is 104,728 B and 3,256 objects (−42.6%, −44.6%).ScaleSuiteBenchmark(2 forks, alternating with master): bytes per evaluation are identical to master in every case, apart from cases where both sides flip between the same two JIT-dependent values. The sandbox had 6–21% hypervisor steal time, so time deltas under about 7% are unconfirmed.rules-sweep−22%,regex-many−17%,one-of-many−16%,variations−12%,numeric−12%,one-of-small-numbers−12%,json-sizes−11%,json-shapes−9.5%flags−6.7%,semver−5.4%,rules−4.7%,json-values+5.9%one-of,regex,splits,time-windows,wide-context,regex/literalsScaleSuiteLoadBenchmark(6 forks):scalescale-jsonscale-jsonis 23% slower (+13 ms per parse; fork ranges [55.7..57.7] vs [69.2..70.8]), probably from canonicalizing its ~155k strings, most of them inside large JSON variation values. It's a load-time cost, paid when the configuration changes, not per evaluation. Skipping canonicalization inside large JSON values is a possible follow-up.Additional Notes
With Store feature flag configuration lists and maps at their exact size (FFE optimization) #13556 (exact-size lists and maps), the two together take
scaleto 15.02 MB (−39%) and 435,064 objects (−46%), and canonical to 108,008 B (−40%) and 3,236 objects (−45%).Not
String.intern(): the texts include customer data, such asONE_OFuser ids, which shouldn't reach a JVM-wide table.Field names are still canonicalized by Jackson (
CANONICALIZE_FIELD_NAMESstays on); only the JVM-wide interning is off. Nothing indd-openfeaturecompares field names by identity.Tests:
StringCanonicalizerTest: sharing, the copy on a miss, equal hashes ("Aa"/"BB"), empty, non-ASCII and surrogate pairs, growth to 10,000 texts.UniversalFlagConfigParserTest:assertSamefor the keys listed above and for two conditions' attributes, plus escapes, non-ASCII and a 20,000-character value.dd-openfeaturetests pass, includingCanonicalFixtureTestandScaleSuiteTest; Spotless and SpotBugs pass.Independent of Return read-only JSON flag values with exact integers #13484 and Index ONE_OF and NOT_ONE_OF lists when the configuration loads #13486–Hash FFE shards without allocating #13490. Leo's parser PRs touch other parts of
UniversalFlagConfigParser, so expect at most a small rebase. A possible follow-up seeds the table with the strings of the configuration being replaced, so a new version shares unchanged strings with the old one during the swap.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 issueJira ticket: [PROJ-IDENT]
🤖 Generated with Claude Code