divijvaidya opened a new pull request, #12890:
URL: https://github.com/apache/kafka/pull/12890

   ## Motivation 
   We create an instance of ObjectSerializationCache  at 
https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/network/RequestChannel.scala#L113
 which does not get used at all. We always "add" to the cache but never 
retrieve from it (as is evident by the fact that we don't store the reference 
of the cache anywhere).
   
   Adding information to the cache is expensive because it uses 
`System.identityHashCode(Object)` which is expensive as demonstrated by the 
flame graph of producer requests over Apache Kafka 3.3.1 plaintext broker.
   
   ![Screenshot 2022-11-21 at 19 23 
53](https://user-images.githubusercontent.com/71267/203320985-c08e4447-cc8e-40d2-88f5-69eb454ef63b.png)
   
   ## Change
   Currently, the header of a request is parsed by the processor thread prior 
to adding it to RequestChannel. With this change, we cache the computed size in 
the `RequestHeader` object itself at the time of parsing the bytebuffer into a 
`RequestHeader` object. The cached size is re-used when it is required at 
`RequestChannel`.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to