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.  ## 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