RFR: 8322149: ConcurrentHashMap smarter presizing for copy constructor and putAll [v3]

Joshua Cao duke at openjdk.org
Mon Jan 22 22:13:52 UTC 2024


On Mon, 22 Jan 2024 17:45:45 GMT, Volker Simonis <simonis at openjdk.org> wrote:

>> Joshua Cao has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   putAll presize based on sum on both map sizes
>
> test/micro/org/openjdk/bench/java/util/concurrent/Maps.java line 122:
> 
>> 120:     @Benchmark
>> 121:     public ConcurrentHashMap<Integer, Integer> testConcurrentHashMapPutAll() {
>> 122:         ConcurrentHashMap<Integer, Integer> map = new ConcurrentHashMap<>();
> 
> I think this benchmark could be made more accurate by creating the new, temporary map with the right initial size (i.e. `ConcurrentHashMap<>(nkeys)`) to avoid calls to `tryPresize()` in this setup step.

I updated. The numbers are surprisingly the same. I guess the benchmark compute time is dominated by putAll().

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17116#discussion_r1462481286


More information about the core-libs-dev mailing list