Repository navigation
Conversation
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. |
A parsed configuration stays in the old generation until the next one replaces it, and every marking cycle walks it. Most of its lists hold zero or one element, the JSON reader's lists keep their growth slack, and every flag carried a HashMap of variations with its table and nodes. The parser now stores: - every list, including ONE_OF and other list operands, as a CompactList: one shared empty list, a single object for one element, and the object plus one exact-size array for more - the flags, variations and extraLogging maps as Map.copyOf maps, unless they hold a null key or value (a JSON null variant), which Map.copyOf rejects Every parsed list is the same class on purpose. The evaluator iterates model lists with for-each loops: with one receiver class the JIT inlines iterator() and escape analysis removes the iterator. Mixing emptyList, singletonList and ArrayList brought the iterators back, about 1.5 KB per evaluation on the scale splits suite. Map.copyOf maps reject null lookups, so FlagEvaluator checks for a null flag key or variation key before looking it up. A null flag key still reads FLAG_NOT_FOUND, and a split without a variation key still reads "Variant not found". Nothing iterates these maps in order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without the int field, a list is 24 bytes instead of 32 with compressed oops (AbstractList already carries modCount). Map.copyOf already returns the shared empty map, so compactMap needs no empty case of its own. Add a test that idles the flag-evaluation worker past its poll timeout, so the empty-poll branch is covered regardless of test timing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AbstractList's iterator is shared by every AbstractList subclass, so its size(), get() and modCount calls see every list class in the application. Once that profile is polluted they aren't inlined, escape analysis keeps the iterator, and every for-each over a configuration list allocates: +160 B to +66 KB per evaluation and up to 3.3x slower in Bits' runs. CompactList now has its own iterator, a plain index with no modCount since the list is immutable, and overrides forEach and isEmpty. iterator() returns a new iterator on every path, the empty list included, since a shared one on any path would be a merged allocation escape analysis can't remove. get() reads the array once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dougqh
force-pushed
the
dougqh/ffe-config-compact-collections
branch
from
November 21, 2026 01:43
5f3003e to
9ebbc1f
Compare
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 stores its lists and maps at their exact size:
ONE_OFand other list operands, is aCompactList: one shared empty list, a single object for one element, and that object plus one exact-size array for more. Elements may benull; the list is immutable.flags,variationsandextraLoggingmaps areMap.copyOfmaps, unless they hold anullkey or value (a JSONnullvariant), whichMap.copyOfrejects.Map.copyOfmaps rejectnulllookups, soFlagEvaluatornow checks for anullflag key or variation key before looking it up. Anullflag key still readsFLAG_NOT_FOUND, and a split without a variation key still reads "Variant not found". Without the checks, both would have become aGENERALerror; two new tests fail without them.Motivation
A parsed configuration stays in the old generation until the next one replaces it, and every marking cycle walks it. In the 10,030-flag scale configuration, 33,557 of its 106,659 lists were empty and 61,409 held one element, each an
ArrayListplus its array. Every flag also carried aHashMapof variations with its table and nodes.Measured on its own by Bits: this PR's head (
a375fcccb3) merged locally onto master62d4d1a14e, as for #13553, against master62d4d1a14e. 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-jsonregexsuiteCompactList(no size field) saves another 584,824 B onscalecompared with the previous head.scale-jsondoesn't move: all of it sits underVariant.value, in JSON maps and lists that aren't compacted. Compacting JSON values is a separate follow-up.scaleto 17,128,816 B and 437,384 objects (−37.6%, −45.8%), and canonical to 104,728 B and 3,256 objects (−42.6%, −44.6%).scale125 → 120 ms,scale-json56.7 → 57.6 ms, 4 forks). Parsing only happens when the configuration changes.ScaleSuiteBenchmark(3 forks, 7 where a case moved; base and PR alternating; the sandbox had 6–21% hypervisor steal time, so small time deltas are unconfirmed):variationsone-of-small-numbersrules-sweepflags,numeric,one-of,one-of-many,regex,regex-many,rules,semver,splits,wide-context,json-*,regex/literalstime-windowsregression in this run came fromCompactListinheritingAbstractList's iterator; it's fixed below.Additional Notes
iterator()and escape analysis removes the iterator. A first version mixedemptyList,singletonListandArrayList: same footprint, but the loops became megamorphic and allocated iterators again, about +1.5 KB per evaluation onscale/splitsand +450 B onscale/rules.List.copyOf's two classes still left the splits regression.Arrays.asListfixed allocation but costs two objects per list.CompactListgives both: one class and one object for 0–1 elements.Map.copyOf's order changes from one JVM run to the next. Nothing iterates these maps in order. The only iteration,validateNumericVariants, gives the same error whichever variant comes first.CompactListTestcovers sizes 0–5,nullelements, bounds, equality withArrayList, immutability and the shared empty list.UniversalFlagConfigParserTestchecks the shapes (one list class, immutable maps), a JSONnullvariant, andnullelements inONE_OFlists.FlagEvaluatorTestcovers the twonulllookups on parsed maps.dd-openfeaturetests pass; Spotless and SpotBugs pass.FlagEvaluatorlines are away from the code they change.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]
Review follow-ups
The
time-windowsregression is fixed (5f3003e).CompactListhas its own iterator instead of inheritingAbstractList's, and overridesforEachandisEmpty.AbstractList's iterator is shared by everyAbstractListsubclass, so in an application itssize()andget()calls are megamorphic (PrintInliningshows them as virtual calls) and escape analysis keeps the iterator.iterator()returns a new iterator on every path, the empty list included, because a shared one would be a merged allocation that escape analysis can't remove.Re-measured by Bits with the shared list internals' profile polluted first, as in an application (
ScaleSuiteBenchmark, each variant merged onto master62d4d1a14e, 5 forks per variant rotated, 4 threads, JDK 21):time-windowsrulesone-of-small-numbersvariationsBytes per evaluation match master's in every case (
rulesis bimodal from fork to fork in every variant, 1,622 or 2,406 B, a JIT outcome unrelated to the list).variationsis 20% faster than master, with no fork overlap.CompactListderives its size from its array instead of storing it: a list is 24 bytes instead of 32 with compressed oops. Footprint numbers above predate this, so the real saving is slightly larger.The new idle-poll test in
FlagEvaluationPipelineTestfixes a timing-dependent coverage gap:runDutyCycle's empty-poll branch was only reached when a test happened to sit idle for 100 ms, and this branch's timing tipped it under the 0.9 threshold.🤖 Generated with Claude Code