[ https://issues.apache.org/jira/browse/IGNITE-7931?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16422978#comment-16422978 ]
Nikolay Izhikov commented on IGNITE-7931: ----------------------------------------- TeamCity - https://ci.ignite.apache.org/viewLog.html?buildId=1172948&tab=buildResultsDiv&buildTypeId=IgniteTests24Java8_RunAll > Wrong arguments for ConcurrentHashMap > -------------------------------------- > > Key: IGNITE-7931 > URL: https://issues.apache.org/jira/browse/IGNITE-7931 > Project: Ignite > Issue Type: Improvement > Reporter: Ivan Fedotov > Assignee: Ivan Fedotov > Priority: Trivial > Fix For: 2.5 > > > When creating ConcurrentHashMap: > {code:java|title=BinaryUtils.java} > new ConcurrentHashMap<>(U.capacity((map).size()));{code} > [1], [2] `U.capacity` returns capacity that is sufficient to keep the map > from being resized. In ConcurrentHashMap this is unnecessary because > recalculation already performs in the constructor. > Similar problem in GridConcurrentHashSet because inside it implements > ConcurrentHashMap: > {code:java|title=DataStreamerImpl.java} > keys = new GridConcurrentHashSet<>(entries.size(), > U.capacity(entries.size()), 1);{code} > [3],[4] result of `U.capacity` is passed as `loadFactor` value. When > loadFactor == U.capacity, initial size of table is 1. > This leads to performance penalty due to rehashing of internal map. > > [1][https://github.com/1vanan/ignite/blob/master/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java#L670] > [2][https://github.com/1vanan/ignite/blob/master/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java#L688|https://github.com/1vanan/ignite/blob/master/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java#L670] > [3][https://github.com/apache/ignite/blob/master/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java#L633] > [4][https://github.com/apache/ignite/blob/master/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java#L574] -- This message was sent by Atlassian JIRA (v7.6.3#76005)