Repository navigation
Conversation
LLM ValidationLLM Validation Gate — java-agent-instructions✅ PASS
6 case(s) · quality 80.3 → 80.6 (+0.2) · win-rate 50% [50%–50%] Details — analysis and per-case resultsAnalysisChanged instruction file(s): No safety or blocking-case regressions across 6 case(s). Overall pairwise win-rate 50% [50%–50%], quality +0.2 — see the verdict above for whether that clears the noise band. Results
Cases
Per-dimension scores, token usage, latency, and estimated cost are in the CI job logs. |
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. |
ImmutableListBenchmark compares how small lists held in long-lived parsed state iterate (enhanced for, forEach, indexed) across ArrayList, the JDK's immutable lists, a mix of emptyList/singletonList/ArrayList, and a compact list with and without its own iterator, each structure holding lists of sizes 0, 1, 1, 2 and 8. BenchmarkUtils.warmUpListDispatch broadens the profiles of the JDK's shared list internals (AbstractList's iterator, AbstractCollection.isEmpty, Iterable.forEach) first when profile=polluted, since a quiet benchmark JVM lets escape analysis remove iterators it wouldn't in an application. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An immutable list at its exact size for small lists held in long-lived state: one shared empty list, one object for a single element, and one exact-size array beyond. Walking it allocates nothing: its own iterator, forEach and isEmpty keep their calls monomorphic where AbstractList's shared ones go megamorphic, and iterator() and cursor() return a new object on every path, the empty list included, so escape analysis can remove them. The iterator and the cursor share one index walk. ImmutableListBenchmark's compact arm now uses it, with a cursor arm. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dougqh
force-pushed
the
dougqh/toolbox-compact-list
branch
from
November 21, 2026 03:53
1b82c60 to
89db448
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
datadog.trace.util.CompactListtocomponents/toolbox: an immutable list stored at its exact size. It's one shared empty list, a single object for one element, and the object plus one exact-size array beyond. Elements may benull.copyOf(Collection)returns aCompactList(aCompactListargument is returned as is), andempty()returns the shared empty list.iterator(),forEachandisEmpty, plus acursor()for walks that stop early or carry state in locals. The cursor requires a list withoutnullelements, sincenullmarks the end.ImmutableListBenchmark(internal-api JMH), in the style ofImmutableMapBenchmark. It compares how small immutable lists iterate, and whether they allocate.BenchmarkUtils.warmUpListDispatch, which broadens the profile of the JDK's shared list internals before a trial.Motivation
Long-lived parsed state, such as a configuration, holds many small lists, mostly with zero or one element. As exact-size
ArrayLists, each costs a list object plus an array. Mixing list classes to save that (emptyList,singletonList,ArrayList) makes every loop over them megamorphic, and escape analysis then keeps their iterators.CompactListis one class at its exact size, and walking it allocates nothing:forEachandisEmpty.AbstractList's are shared by every subclass, so in an application theirsize()/get()calls go megamorphic and the iterator escapes.ImmutableListBenchmark(Bits, JDK 21, 3 forks, 4 threads, steal median 0.14%). Five lists of sizes 0, 1, 1, 2 and 8, walked per op. Median fork in ns/op, then B/op.compacthere is the same design, measured before it moved into the toolbox.pollutedfirst makes the JDK's shared list internals see many list classes, as in an application:arrayListjdkImmutable(List.of)jdkMixedcompactInheritedcompactcompactallocates nothing in any case. AgainstArrayListit's −13% on enhanced-for and −29% to −35% onforEach, but +5–7% on the indexed loop (small, though the forks don't overlap). It beatsList.ofcopies everywhere.compactInherited, the same list inheritingAbstractList's iterator, is fine in a quiet JVM. Polluted, it allocates 160 B and runs about 5× slower.PrintInliningshowsAbstractList$Itr'ssize()andget()as virtual calls; with its own iterator, everything inlines from a monomorphic profile.jdkMixedallocates even unpolluted: three classes make the caller's own call sites megamorphic.List.ofcopies allocate 160 B per enhanced-for walk in both profiles, because theList12andListNiterators escape.In dd-openfeature's configuration (#13556), the inherited iterator cost up to +174% time and +66 KB per evaluation with a polluted profile. This design matched master's bytes, and
variationscame out 20% faster.Additional Notes
nulls:cursor()usesnullas its end marker, like every toolboxCursor, so it's only for lists withoutnullelements. UseforEachor the iterator for lists that can holdnull, such as raw JSON arrays.CompactListmatches the embedded copy above: enhanced-for 31.7 ns andforEach22.1 ns, 0 B, clean and polluted. The indexed loop came out 8–9% slower (37.0 vs 34.0 ns, no fork overlap). Itsget()/size()source is identical and thecompactInheritedcontrol didn't move, so this is probably a JIT or code-layout effect, not yet investigated.cursor_compact): 0 B in both profiles, but the slowest way to walk these small lists, at 40.6 ns (+28% vs enhanced-for, +84% vsforEach). UseforEachto visit everything; the cursor is for walks that stop early or carry state in locals, as its docs say.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