On Wed, 11 Feb 2026 19:24:34 GMT, jengebr <[email protected]> wrote:

>> Your PR proposes two optimizations,
>> - HashMap.putAll(HashMap) 
>> - HashMap.putAll(UnmodifiableMap(HashMap))
>>  
>> The former have been done numerous time for other collections, the latter is 
>> as far as as know new.
>> 
>> There are several reasons to not wanting to do the latter , on top of my 
>> head:
>> - this is not a symmetrical transformation,
>> - why only have this optimization on HashMap and not ArrayList and/or 
>> ArrayDeque ? 
>> 
>> So It's a separate issue that should be discussed on on the mailist list 
>> first.
>
> Hmm, I disagree, since they are both aspects of improving performance of the 
> target method, HashMap.putMapEntries().  They also both directly attack the 
> underlying JDK JIT limitations described in 
> https://bugs.openjdk.org/browse/JDK-8368292 .  It's a two-piece fix to one 
> problem, and they're covered simultaneously by a single unit test and JMH 
> benchmark.
> 
> Open to opinions from others.

I do agree with Remi that the UnmodifiableMap special path provides little 
value. The unmodifiable map itself is megamorphic and its own iteration would 
suffer from the same profiling issue if we eliminate the "bottleneck" here.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28243#discussion_r3010915578

Reply via email to