Skip to content

Improves IonContainer hashCode performance by ~30%.#1156

Merged
NovemberZulu merged 2 commits into
masterfrom
hashcode-perf
Jun 24, 2026
Merged

Improves IonContainer hashCode performance by ~30%.#1156
NovemberZulu merged 2 commits into
masterfrom
hashcode-perf

Conversation

@tgregg

@tgregg tgregg commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Description of changes:

  • IonValueLite.java — refactored containerHashCode() to use parallel arrays (valueHashes, parents, iterators) instead of per-frame HashHolder objects, and converted HashHolder's instance methods into static helpers (hashStructField, updateHash). The hashes produced are the same.
  • New IonContainerHashCodeBenchmark.java — JMH benchmark exercising monomorphic vs. megamorphic container hashing.

Results:

Benchmark                        poison    Before (ns/op)    After (ns/op)    Improvement
  containerHashCode_megamorphic    true      1943 ± 212        1542 ± 30        -21%
  containerHashCode_megamorphic    false     1944 ± 240        1510 ± 6         -22%
  containerHashCode_monomorphic    true      1738 ± 10         949 ± 9          -45%
  containerHashCode_monomorphic    false     1401 ± 57         939 ± 15         -33%

Container: IonList with 120 elements (monomorphic = all IonString; megamorphic = 6 types × 20)
JVM: Corretto 21, aarch64, -Xms3g -Xmx3g -XX:+UseParallelGC
poison=true pre-invokes hashCode() 40,000 times on the megamorphic container to simulate
real-world call-site pollution (JDK-8368292).

Credit: John Engebretson

Related: https://bugs.openjdk.org/browse/JDK-8368292

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@NovemberZulu NovemberZulu merged commit 12aac5d into master Jun 24, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants