Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-7931

Wrong arguments for ConcurrentHashMap

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • None
    • 2.5
    • None
    • None

    Description

      When creating ConcurrentHashMap:

      BinaryUtils.java
      new ConcurrentHashMap<>(U.capacity((map).size()));

      [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:

      DataStreamerImpl.java
      keys = new GridConcurrentHashSet<>(entries.size(), U.capacity(entries.size()), 1);

      [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

      [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

      Attachments

        Issue Links

          Activity

            People

              ivanan.fed Ivan Fedotov
              ivanan.fed Ivan Fedotov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: