[ 
https://issues.apache.org/jira/browse/KAFKA-13629?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Luke Chen resolved KAFKA-13629.
-------------------------------
    Fix Version/s: 3.2.0
         Reviewer: Ismael Juma
       Resolution: Fixed

> Client producer use faster ByteUtils sizeOfXxx algorithm
> --------------------------------------------------------
>
>                 Key: KAFKA-13629
>                 URL: https://issues.apache.org/jira/browse/KAFKA-13629
>             Project: Kafka
>          Issue Type: Improvement
>          Components: clients, producer 
>            Reporter: Jason Koch
>            Priority: Minor
>             Fix For: 3.2.0
>
>
> Kafka Java client producer path uses `tryAppend()` requires an estimated 
> size. The sizeOf algorithm currently uses an [iterative while 
> loop|https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/common/utils/ByteUtils.java#L394-L401]
>  which can be improved.
> On real system this reduces the producer path CPU by 4%. JMH benchmarking 
> shows the algorithm is approx 3x faster (90 op/ms -> 290op/ms).
> Specifically, we can use a prepared table with the following lookup which 
> relies on JVM intrinsic for fast performance, and also avoids any branching:.
> --
> {{int leadingZeros = Integer.numberOfLeadingZeros(value);}}
> {{return LEADING_ZEROS_TO_U_VARINT_SIZE[leadingZeros];}}
> --



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to