Skip to content

Add order-independent map hashes and mixers to LongHashingUtils and HashingUtils - #13647

Draft
dougqh wants to merge 9 commits into
dougqh/toolbox-componentfrom
dougqh/toolbox-unordered-hash
Draft

dougqh wants to merge 9 commits into
dougqh/toolbox-componentfrom
dougqh/toolbox-unordered-hash

Conversation

@dougqh

@dougqh dougqh commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Stacked on #13531.

Adds three methods to the toolbox's LongHashingUtils, and their 32-bit counterparts to HashingUtils:

  • mix(long): the SplitMix64 finalizer, where every input bit affects every output bit. It's for combining hashes whose raw values are correlated. To pick a table slot, a cheaper spread is enough.
  • unorderedEntryHash(long keyHash, long valueHash): one entry's share of an order-independent hash of a map. Add the shares of all entries (and the size) to get a hash that doesn't depend on iteration order. Each share is mixed, so entries can't cancel each other the way Map.hashCode's key ^ value terms do: {a=0, b=0} and {a=1, b=1} collide under Map.hashCode, but not here. The caller chooses the value hash, and no entry object is needed.
  • unorderedHash(Map): those shares added up over a map, using the keys' and values' own hash codes.

32-bit counterparts in HashingUtils:

  • mix(int) is MurmurHash3's fmix32 finalizer.
  • unorderedEntryHash(int, int) and unorderedHash(Map) follow the same scheme as the 64-bit versions. They're native 32-bit versions rather than truncations, which is cheaper.
  • The use case is a key's hashCode() over a map or set, as a better-mixed alternative to Map.hashCode. The Javadoc notes that 32 bits collide sooner (likely somewhere past about 65k distinct maps) and points keys whose identity is the hash to the 64-bit version.

Motivation

The FFE flag-evaluation aggregator (#13609, #13622) keys each consented evaluation by its context with this scheme, but kept the mixer and the per-entry step to itself. Moving them here makes the order-independent hash reusable wherever a map's contents are a key, without allocating entry or key objects.

Additional Notes

🤖 Generated with Claude Code

dougqh and others added 8 commits November 19, 2026 16:10
…dule

Moves the toolbox primitives that have no dependencies outside the JDK out of internal-api, with
their tests: Hashtable, FlatHashtable, StringIndex, ChunkedBuffer, Cursor, Maybe, the hashing
utilities, BitUtils and FNV64Hash, plus the contract annotations and the Strategy, StrategyConsumer
and NoEscape markers. Package names do not change, and internal-api re-exports the module, so
callers are unchanged.

Strings.caseInsensitiveHashCode moves to HashingUtils, which FlatHashtable uses. Strings keeps the
method and delegates to it.

The agent's shared and per-product jars exclude the module, as they do the other bootstrap
components, so each class is packaged once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The moved classes passed under internal-api's thresholds (0.7 branch, 0.8 instruction). The new
module got the 0.9 default instead, which failed coverage verification for seven of them. Using
internal-api's thresholds keeps enforcement exactly as it was before the move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing calls the Strings delegate, so drop it and move its test next to
HashingUtils.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cies

The toolbox was extracted from internal-api, so it keeps the strict core
performance rules in AGENTS.md and the perf-review posture. Its lockfile
now covers the test configurations too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It only depends on toolbox classes, plus TriFunction, which moves with it
in the same package, as Strategy did. internal-api exposes the toolbox as
an api dependency, so its users compile unchanged.

The size-manager test polls the thread state itself rather than through
test-utils, so the toolbox tests keep junit as their only dependency, and
hashIterator gets a direct test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ConcurrentHashtable, StringIndex and FlatHashtable are on master and now
live in components/toolbox; StringCanonicalizer and LruTable are coming.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EscapeShapeBenchmark's arms are mergeWithStatic and mergeOfTwoAllocations
now, and "merge of several allocations" replaces the compiler term "phi".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LongHashingUtils.mix is the SplitMix64 finalizer, for combining hashes
whose raw values are correlated. unorderedEntryHash gives one entry's
share of an order-independent hash, mixing it so that entries can't
cancel each other the way Map.hashCode's key ^ value terms do, and
unorderedHash adds those shares up over a map. The FFE aggregator keys
evaluation contexts with this scheme.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh dougqh added type: feature Enhancements and improvements tag: ai generated Largely based on code generated by an AI or LLM labels Nov 23, 2026
@pr-commenter

pr-commenter Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

LLM Validation

LLM Validation Gate — java-agent-instructions

✅ PASS

  • No blocking-case regressions; the quality change is within noise (baseline/candidate confidence intervals overlap).

6 case(s) · quality 81.4 → 81.3 (-0.1) · win-rate 50% [47%–53%]

Details — analysis and per-case results

Analysis

Changed instruction file(s): AGENTS.md.

No safety or blocking-case regressions across 6 case(s). Overall pairwise win-rate 50% [47%–53%], quality -0.1 — see the verdict above for whether that clears the noise band.

Results

  • Pairwise win-rate: 50% [47%–53%] — candidate's share of blind comparisons (90% CI; spanning 50% = no clear difference)
  • Overall quality: 81.4 → 81.3 (/100, -0.1)
  • Bad signals introduced (advisory): 0
  • Candidate criteria coverage (advisory): 22/27 (81%) — expected_criteria the candidate met; does not affect the gate
  • Blocking-case regressions: 0

Cases

Case Mode Quality Δ Win-rate (90% CI) Safety
java-core-validation-001 warn -1.4 42% [28%–55%] ok
java-unit-test-conventions-001 warn -0.3 50% [50%–50%] ok
java-premain-safety-001 warn +1.4 50% [50%–50%] ok
java-ci-download-guidance-001 warn +2.5 58% [45%–72%] ok
java-documentation-only-validation-001 warn -0.8 50% [50%–50%] ok
java-existing-spock-maintenance-001 warn -2.2 50% [50%–50%] ok

Per-dimension scores, token usage, latency, and estimated cost are in the CI job logs.

@datadog-official

datadog-official Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 60.80% (+0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 91589e0 | Docs | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.91 s 14.83 s [-0.4%; +1.5%] (no difference)
startup:insecure-bank:tracing:Agent 13.63 s 13.80 s [-2.2%; -0.2%] (maybe better)
startup:petclinic:appsec:Agent 17.04 s 17.65 s [-7.5%; +0.6%] (no difference)
startup:petclinic:iast:Agent 17.56 s 17.63 s [-1.1%; +0.3%] (no difference)
startup:petclinic:profiling:Agent 17.58 s 17.34 s [+0.1%; +2.7%] (maybe worse)
startup:petclinic:sca:Agent 17.77 s 17.19 s [-0.8%; +7.5%] (no difference)
startup:petclinic:tracing:Agent 16.82 s 16.82 s [-0.9%; +0.9%] (no difference)

Commit: 91589e01 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

HashingUtils mirrors LongHashingUtils, so it gains mix (MurmurHash3's
fmix32 finalizer), unorderedEntryHash and unorderedHash: a better-mixed
alternative to Map.hashCode for a key's hashCode(). They are native
32-bit versions rather than truncations of the 64-bit ones, and the
Javadoc points identity-critical keys to the 64-bit hash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh dougqh changed the title Add an order-independent map hash and a 64-bit mixer to LongHashingUtils Add order-independent map hashes and mixers to LongHashingUtils and HashingUtils Nov 23, 2026
@dougqh
dougqh force-pushed the dougqh/toolbox-component branch 2 times, most recently from 5c9275f to 0dbdb72 Compare November 24, 2026 02:03

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tag: ai generated Largely based on code generated by an AI or LLM type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant