Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-16942

Use ConcurrentHashMap in RecordAccumulator#nodeStats

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Won't Do
    • None
    • None
    • clients, producer
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              brandboat Kuan Po Tseng
              brandboat Kuan Po Tseng
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: