Dmitry Konstantinov created CASSANDRA-21359:
-----------------------------------------------
Summary: Reduce allocation in row merge logic
Key: CASSANDRA-21359
URL: https://issues.apache.org/jira/browse/CASSANDRA-21359
Project: Apache Cassandra
Issue Type: Improvement
Components: Local/Other
Reporter: Dmitry Konstantinov
Attachments: image-2026-05-09-15-14-10-274.png,
image-2026-05-09-15-26-52-036.png
background: 10 rows partition read test, CASSANDRA-21354 change applied
* org.apache.cassandra.utils.MergeIterator.Candidate - has Comparator field
which is the same for all Candidates under an MergeIterator instance, we can
move the field to MergeIterator level. Candidate is 4.8% of all allocations and
we can save 20% of it for JDK 21 with compressed references on.
{code}
org.apache.cassandra.utils.MergeIterator$Candidate object internals:
OFF SZ TYPE DESCRIPTION VALUE
0 8 (object header: mark) N/A
8 4 (object header: class) N/A
12 4 int Candidate.idx N/A
16 1 boolean Candidate.equalParent N/A
17 3 (alignment/padding gap)
20 4 java.util.Iterator Candidate.iter N/A
24 4 java.util.Comparator Candidate.comp N/A
28 4 java.lang.Object Candidate.item N/A
32 4 java.lang.Object Candidate.lowerBound N/A
36 4 (object alignment gap)
Instance size: 40 bytes
{code}
without comp we dropped to 32 bytes, so 20% less object size
{code}
OFF SZ TYPE DESCRIPTION VALUE
0 8 (object header: mark) N/A
8 4 (object header: class) N/A
12 4 int Candidate.idx N/A
16 1 boolean Candidate.equalParent N/A
17 3 (alignment/padding gap)
20 4 java.util.Iterator Candidate.iter N/A
24 4 java.lang.Object Candidate.item N/A
28 4 java.lang.Object Candidate.lowerBound N/A
Instance size: 32 bytes
{code}
!image-2026-05-09-15-14-10-274.png|width=400!
* we can switch from ArrayList to array in
org.apache.cassandra.db.rows.Row.Merger
The ArrayList iterator costs 0.72% and BulkIterator.Adapter costs 0.35%. So, in
total we can save here ~1% of total allocations.
!image-2026-05-09-15-26-52-036.png!
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]