[CASSANDRA-21360][trunk] Reduce memory allocations in miscellaneous places along read path#4797
[CASSANDRA-21360][trunk] Reduce memory allocations in miscellaneous places along read path#4797netudima wants to merge 3 commits into
Conversation
org.apache.cassandra.db.rows.RangeTombstoneMarker.Merger is allocated on demand Optional usage in org.apache.cassandra.db.rows.UnfilteredRowIteratorWithLowerBound is replaced with a boolean field Double in org.apache.cassandra.io.util.CompressedChunkReader#getCrcCheckChance - specialized supplier is used to avoid boxing Stack - adjust default from 5 to 6 to avoid extra resizings in org.apache.cassandra.db.transform.Stack#resize EnumSet for CL guardrail in SelectStatement - add a condition to allocate it only if the guardrail is enabled EnumSet in ResultMetadata - replace it with plain int flags patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-21360
frankgh
left a comment
There was a problem hiding this comment.
I think there's a potential of NPE with the lazy initialization of markerMerger in the UnfilteredRowIterators class.
| return merged; | ||
| } | ||
| else | ||
| { |
There was a problem hiding this comment.
In the else block in getReduced() we need to also do a markerMerger null check, since it is now lazily initialized, it can produce NPEs
{
if (markerMerger == null)
return null;
There was a problem hiding this comment.
if I am not mistaken, reduce() should be always invoked before getReduced(), so nextKind != Unfiltered.Kind.ROW condition is the same for both methods and markerMerger should be not null
There was a problem hiding this comment.
I'm seeing NPEs in tests without this check
There was a problem hiding this comment.
for example, org.apache.cassandra.db.rows.RangeTombstoneMarker.Merger#bound is set in add and used in merge, so if add was no invoked we would get a NPE on bound dereference in the current logic already.
There was a problem hiding this comment.
I'm seeing NPEs in tests without this check
ok, let me check in more details
org.apache.cassandra.db.rows.RangeTombstoneMarker.Merger is allocated on demand Optional usage in org.apache.cassandra.db.rows.UnfilteredRowIteratorWithLowerBound is replaced with a boolean field Double in org.apache.cassandra.io.util.CompressedChunkReader#getCrcCheckChance - specialized supplier is used to avoid boxing Stack - adjust default from 5 to 6 to avoid extra resizings in org.apache.cassandra.db.transform.Stack#resize EnumSet for CL guardrail in SelectStatement - add a condition to allocate it only if the guardrail is enabled EnumSet in ResultMetadata - replace it with plain int flags
patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-21360