KAFKA-20249: Optimize raw value extraction in headers-aware deserializers#21706
Open
zheguang wants to merge 4 commits intoapache:trunkfrom
Open
KAFKA-20249: Optimize raw value extraction in headers-aware deserializers#21706zheguang wants to merge 4 commits intoapache:trunkfrom
zheguang wants to merge 4 commits intoapache:trunkfrom
Conversation
Benchmark Mode Cnt Score Error Units RawBytesExtraction.testRawAggregationWithoutHeaders thrpt 15 7850.891 ± 307.428 ops/s RawBytesExtraction.testRawAggregationWithoutHeadersFastPath thrpt 15 14957.556 ± 517.450 ops/s
Benchmark Mode Cnt Score Error Units RawBytesExtraction.testRawAggregationWithHeaders thrpt 15 1411.338 ± 110.527 ops/s RawBytesExtraction.testRawAggregationWithHeadersFastPath thrpt 15 6106.665 ± 218.032 ops/s RawBytesExtraction.testRawAggregationWithoutHeaders thrpt 15 7734.538 ± 525.487 ops/s RawBytesExtraction.testRawAggregationWithoutHeadersFastPath thrpt 15 14300.408 ± 212.519 ops/s
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch implements two optimizations, and their JMH benchmarks.
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.
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:
Test: