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

   This patch implements two optimizations, and their JMH benchmarks.
   
   1. Skipping
   Previously the raw value extraction in headers-aware deserializers undergoes 
deserialization and/or copying of headers, while only skipping is required.   
This happens for both empty and nonempty headers.
   
   2. Empty headers copying
   Empty headers have constant metadata footprint: the headers size is 
varint-encoded 1 byte of 0, and headers themselves consume no bytes.  Based on 
this invariant, the ByteBuffer-based extraction can be replaced with a direct 
`System.arraycopy`, which is a Java native method optimized for specific 
platforms.
   
   **Benchmark:**
   This patch also includes JMH benchmarks to test the speedup.  On my local 
machine, Optimization 1 speedup is 2-6x speedup.  Optimization 2 is 1.35x.  
   
   Below is the throughput comparison of a recorded JMH run:
   ```
   Benchmark                                                Mode  Cnt      
Score     Error  Units
   RawBytesExtraction.testRawAggregationWithHeaders        thrpt   15   
1481.854 ±  31.448  ops/s
   RawBytesExtraction.testRawAggregationWithHeadersOpt     thrpt   15  
11797.165 ± 103.432  ops/s
   
   RawBytesExtraction.testRawAggregationWithoutHeaders     thrpt   15   
8359.080 ±  47.918  ops/s
   RawBytesExtraction.testRawAggregationWithoutHeadersOpt  thrpt   15  
15298.827 ± 452.741  ops/s
   
   RawBytesExtraction.testRawValueWithoutHeaders           thrpt   15  
11329.997 ± 260.399  ops/s
   RawBytesExtraction.testRawValueWithoutHeadersOpt        thrpt   15  
15372.816 ± 184.651  ops/s
   ```
   
   **Test:**
   - Existing unit test covering nonempty headers
   - Added test case for empty headers
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to