-
Type:
Enhancement
-
Resolution: Unresolved
-
Priority:
P4
-
None
-
Affects Version/s: 17, 21, 25, 26
-
Component/s: core-libs
Issue JDK-8368292 describes a widespread performance penalty in the bulk insertion methods HashMap.putAll(Map) and HashMap.<init>(Map). Optimizations are possible for a critical subset of the affected cases, specifically when the input Map is a HashMap or a Collections$UnmodifiableMap (returned by Collections.unmodifiableMap()).
Benchmarks will be on the PR, but the short version is:
1. 50% faster to add the contents of a HashMap
2. 40% faster to add the contents of an UnmodifiableMap
3. 80% faster to add the contents of a HashMap wrapped in an UnmodifiableMap.
4. No detectable regression for other types.
These changes offer no benefit to other Map implementations (TreeMap, ConcurrentHashMap, LinkedHashMap, application code, Guava, etc.) so they do not solve the JIT profiling issues described in JDK-8368292... however they provide immediate benefit and can be easily backported.
Benchmarks will be on the PR, but the short version is:
1. 50% faster to add the contents of a HashMap
2. 40% faster to add the contents of an UnmodifiableMap
3. 80% faster to add the contents of a HashMap wrapped in an UnmodifiableMap.
4. No detectable regression for other types.
These changes offer no benefit to other Map implementations (TreeMap, ConcurrentHashMap, LinkedHashMap, application code, Guava, etc.) so they do not solve the JIT profiling issues described in JDK-8368292... however they provide immediate benefit and can be easily backported.
- relates to
-
JDK-8368292 Severe performance penalty in bulk Collections methods (putAll, addAll, .<init>(Collection))
-
- Open
-
- links to
-
Review(master)
openjdk/jdk/28243