CASSANDRA-21683 Reuse scratch key bytes in PartitionIndexBuilder - #5181
Open
rustyrazorblade wants to merge 1 commit into
Open
rustyrazorblade wants to merge 1 commit into
rustyrazorblade wants to merge 1 commit into
Conversation
Cut the byte-comparable key-encoding allocation on the BTI partition-index build path. addEntry re-encoded the same one or two keys about four times per partition through diffPoint, cut, and the trie's prev re-read, which is about nineteen short-lived ByteSource, Multi, varargs, and escaper objects per partition. Encode each key's comparable bytes once into a reusable scratch byte[], do diffPoint as an array compare, and feed the trie a fixed-length source over the captured bytes. A three-slot ring keeps the previous key stable while the trie re-streams it on the next add. Output is byte-identical. JMH PartitionIndexBuildBench with -prof gc: gc.alloc.rate.norm falls about 288 bytes per partition, -59.3% at one million keys, with no change to build time.
rustyrazorblade
force-pushed
the
21683-bti-index-key-alloc-6.0
branch
from
September 19, 2026 18:59
86651b2 to
cd40156
Compare
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.
Cut the byte-comparable key-encoding allocation on the BTI partition-index build path. addEntry re-encoded the same one or two keys about four times per partition through diffPoint, cut, and the trie's prev re-read, which is about nineteen short-lived ByteSource, Multi, varargs, and escaper objects per partition.
Encode each key's comparable bytes once into a reusable scratch byte[], do diffPoint as an array compare, and feed the trie a fixed-length source over the captured bytes. A three-slot ring keeps the previous key stable while the trie re-streams it on the next add. Output is byte-identical.
JMH PartitionIndexBuildBench with -prof gc: gc.alloc.rate.norm falls about 288 bytes per partition, -59.3% at one million keys, with no change to build time.