You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Kuan Po Tseng (Jira)" <ji...@apache.org> on 2024/06/12 15:59:00 UTC

[jira] [Created] (KAFKA-16942) Use ConcurrentHashMap in RecordAccumulator#nodeStats

Kuan Po Tseng created KAFKA-16942:
-------------------------------------

             Summary: Use ConcurrentHashMap in RecordAccumulator#nodeStats
                 Key: KAFKA-16942
                 URL: https://issues.apache.org/jira/browse/KAFKA-16942
             Project: Kafka
          Issue Type: Improvement
          Components: clients
            Reporter: Kuan Po Tseng
            Assignee: Kuan Po Tseng


per discussed in [https://github.com/apache/kafka/pull/16231#discussion_r1635345881]

Through the ConcurrentMapBenchmark, we observed that in scenarios where write operations (i.e., computeIfAbsent) constitute 10%, the get performance of CopyOnWriteMap is lower compared to ConcurrentHashMap. However, when iterating over entrySet and values, CopyOnWriteMap performs better than ConcurrentHashMap.

In RecordAccumulator#nodeStats, the computeIfAbsent method is rarely triggered, and we only use the get method to read data. Therefore, switching to ConcurrentHashMap would gain better performance.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)