Use compact primitive storage for star-tree record offsets in OffHeapSingleTreeBuilder - #19317
Open
Jackie-Jiang wants to merge 1 commit into
Open
Use compact primitive storage for star-tree record offsets in OffHeapSingleTreeBuilder#19317Jackie-Jiang wants to merge 1 commit into
Jackie-Jiang wants to merge 1 commit into
Conversation
…SingleTreeBuilder
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #19317 +/- ##
============================================
- Coverage 67.12% 67.12% -0.01%
Complexity 1424 1424
============================================
Files 3462 3462
Lines 220669 220677 +8
Branches 35253 35255 +2
============================================
- Hits 148129 148123 -6
- Misses 60720 60722 +2
- Partials 11820 11832 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
yashmayya
approved these changes
Aug 19, 2026
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.
Summary
OffHeapSingleTreeBuilderkeeps the star-tree record file offsets in aList<Long>, which costs ~28 bytes of heap per record (24-byte boxedLongplus a 4-byte reference under compressed oops). The number of star-tree records can go into the hundreds of millions for large segments with a widedimensionsSplitOrder; in one production incident the offsets list alone held ~700M boxedLongs (~19.6GB including theArrayListbacking array), OOMing the server during realtime segment conversion.This PR replaces the boxed list with a compact
RecordOffsetsstructure:appendRecordpasses the record length instead of computing the next offset from a read-back of the last element.IntArrayList(4 bytes per record) until the record file grows beyondInteger.MAX_VALUE, and in aLongArrayList(8 bytes per record) afterwards. Offsets increase monotonically, so the switch happens at most once and needs no copy: reads pick the list by comparing the index against the int head's size.longfield, removing the extra end-sentinel entry and the boxing/unboxing on every append and on every read in the star-node sort comparator.For the build above this reduces the offset bookkeeping from ~19.6GB to ~5.6GB of heap (4 bytes per record while the record file stays under 2GB), and removes the
Longallocation churn from the build hot path.