[SPARK-58678][CORE][TESTS] Add OpenHashMapBenchmark - #57881
Closed
dongjoon-hyun wants to merge 4 commits into
Closed
[SPARK-58678][CORE][TESTS] Add OpenHashMapBenchmark#57881dongjoon-hyun wants to merge 4 commits into
OpenHashMapBenchmark#57881dongjoon-hyun wants to merge 4 commits into
Conversation
Member
Author
|
Could you review this PR, @uros-b ? |
uros-b
approved these changes
Aug 9, 2026
Member
|
Changes look good @dongjoon-hyun, but it seems that CI didn't run properly? |
Member
Author
|
Thank you, @uros-b . CI is running here. So far, there is no issue because this is a new benchmark addition.
|
Member
Author
|
Let me merge this because the running CI is irrelevant to this PR and the benchmark generation itself is verified when generating the benchmark result already. |
dongjoon-hyun
added a commit
that referenced
this pull request
Aug 9, 2026
### What changes were proposed in this pull request? This PR aims to add `OpenHashMapBenchmark` to measure the performance of `org.apache.spark.util.collection.OpenHashMap` against `java.util.HashMap` in three scenarios modeled on Spark's real usage: - **Insert**: inserting 1M distinct String keys via `update`/`put` - **Aggregate**: 5M `changeValue`/`merge` operations over 1M String keys (the typical aggregation pattern, e.g. `Mode`, `countByValue`) - **Lookup**: looking up 1M String keys in random order ### Why are the changes needed? `OpenHashMap` claims that it is "about 5X faster than java.util.HashMap". https://github.com/apache/spark/blob/8645e2c08929bbc1ef2ef66b442f525814f92220/core/src/main/scala/org/apache/spark/util/collection/OpenHashMap.scala#L24 However, This claim dates from 2013 (pre-JDK 8), and there has been no benchmark in the repository to verify it. On modern JDKs, `java.util.HashMap` has improved significantly. According to this benchmark, Java is much faster for **Insert** and **Lookup**. - In case of `Insert`, `java.util.HashMap` is 4.6X, 5.5X, 6.5X faster in Java 17, 21, and 25, respectively. - Note that `OpenHashMap` still uses about 2.2x less memory than `java.util.HashMap` for `String -> Long` entries thanks to its specialized primitive value storage. This benchmark provides a consistent way to track the trade-off across JDK versions and future improvements. ### Does this PR introduce _any_ user-facing change? No. This is a test-only change. ### How was this patch tested? Manually ran the benchmark: ``` build/sbt "core/Test/runMain org.apache.spark.util.collection.OpenHashMapBenchmark" ``` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Fable 5 Closes #57881 from dongjoon-hyun/SPARK-58678-2. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit 9a20f8b) Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
dongjoon-hyun
added a commit
that referenced
this pull request
Aug 9, 2026
### What changes were proposed in this pull request? This PR aims to add `OpenHashMapBenchmark` to measure the performance of `org.apache.spark.util.collection.OpenHashMap` against `java.util.HashMap` in three scenarios modeled on Spark's real usage: - **Insert**: inserting 1M distinct String keys via `update`/`put` - **Aggregate**: 5M `changeValue`/`merge` operations over 1M String keys (the typical aggregation pattern, e.g. `Mode`, `countByValue`) - **Lookup**: looking up 1M String keys in random order ### Why are the changes needed? `OpenHashMap` claims that it is "about 5X faster than java.util.HashMap". https://github.com/apache/spark/blob/8645e2c08929bbc1ef2ef66b442f525814f92220/core/src/main/scala/org/apache/spark/util/collection/OpenHashMap.scala#L24 However, This claim dates from 2013 (pre-JDK 8), and there has been no benchmark in the repository to verify it. On modern JDKs, `java.util.HashMap` has improved significantly. According to this benchmark, Java is much faster for **Insert** and **Lookup**. - In case of `Insert`, `java.util.HashMap` is 4.6X, 5.5X, 6.5X faster in Java 17, 21, and 25, respectively. - Note that `OpenHashMap` still uses about 2.2x less memory than `java.util.HashMap` for `String -> Long` entries thanks to its specialized primitive value storage. This benchmark provides a consistent way to track the trade-off across JDK versions and future improvements. ### Does this PR introduce _any_ user-facing change? No. This is a test-only change. ### How was this patch tested? Manually ran the benchmark: ``` build/sbt "core/Test/runMain org.apache.spark.util.collection.OpenHashMapBenchmark" ``` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Fable 5 Closes #57881 from dongjoon-hyun/SPARK-58678-2. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit 9a20f8b) Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
dongjoon-hyun
added a commit
that referenced
this pull request
Aug 9, 2026
### What changes were proposed in this pull request? This PR aims to add `OpenHashMapBenchmark` to measure the performance of `org.apache.spark.util.collection.OpenHashMap` against `java.util.HashMap` in three scenarios modeled on Spark's real usage: - **Insert**: inserting 1M distinct String keys via `update`/`put` - **Aggregate**: 5M `changeValue`/`merge` operations over 1M String keys (the typical aggregation pattern, e.g. `Mode`, `countByValue`) - **Lookup**: looking up 1M String keys in random order ### Why are the changes needed? `OpenHashMap` claims that it is "about 5X faster than java.util.HashMap". https://github.com/apache/spark/blob/8645e2c08929bbc1ef2ef66b442f525814f92220/core/src/main/scala/org/apache/spark/util/collection/OpenHashMap.scala#L24 However, This claim dates from 2013 (pre-JDK 8), and there has been no benchmark in the repository to verify it. On modern JDKs, `java.util.HashMap` has improved significantly. According to this benchmark, Java is much faster for **Insert** and **Lookup**. - In case of `Insert`, `java.util.HashMap` is 4.6X, 5.5X, 6.5X faster in Java 17, 21, and 25, respectively. - Note that `OpenHashMap` still uses about 2.2x less memory than `java.util.HashMap` for `String -> Long` entries thanks to its specialized primitive value storage. This benchmark provides a consistent way to track the trade-off across JDK versions and future improvements. ### Does this PR introduce _any_ user-facing change? No. This is a test-only change. ### How was this patch tested? Manually ran the benchmark: ``` build/sbt "core/Test/runMain org.apache.spark.util.collection.OpenHashMapBenchmark" ``` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Fable 5 Closes #57881 from dongjoon-hyun/SPARK-58678-2. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit 9a20f8b) Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Member
Author
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 changes were proposed in this pull request?
This PR aims to add
OpenHashMapBenchmarkto measure the performance oforg.apache.spark.util.collection.OpenHashMapagainstjava.util.HashMapin three scenariosmodeled on Spark's real usage:
update/putchangeValue/mergeoperations over 1M String keys (the typicalaggregation pattern, e.g.
Mode,countByValue)Why are the changes needed?
OpenHashMapclaims that it is "about 5X faster than java.util.HashMap".spark/core/src/main/scala/org/apache/spark/util/collection/OpenHashMap.scala
Line 24 in 8645e2c
However, This claim dates from 2013 (pre-JDK 8), and there has been no benchmark in the repository to
verify it. On modern JDKs,
java.util.HashMaphas improved significantly. According to this benchmark, Java is much faster for Insert and Lookup.In case of
Insert,java.util.HashMapis 4.6X, 5.5X, 6.5X faster in Java 17, 21, and 25, respectively.Note that
OpenHashMapstill uses about 2.2x less memory thanjava.util.HashMapforString -> Longentries thanks to its specialized primitive value storage. This benchmarkprovides a consistent way to track the trade-off across JDK versions and future improvements.
Does this PR introduce any user-facing change?
No. This is a test-only change.
How was this patch tested?
Manually ran the benchmark:
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Fable 5