Skip to content

[CASSANDRA-21360][trunk] Reduce memory allocations in miscellaneous places along read path#4797

Open
netudima wants to merge 3 commits into
apache:trunkfrom
netudima:CASSANDRA-21360-trunk
Open

[CASSANDRA-21360][trunk] Reduce memory allocations in miscellaneous places along read path#4797
netudima wants to merge 3 commits into
apache:trunkfrom
netudima:CASSANDRA-21360-trunk

Conversation

@netudima
Copy link
Copy Markdown
Contributor

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

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
Copy link
Copy Markdown
Contributor

@frankgh frankgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a potential of NPE with the lazy initialization of markerMerger in the UnfilteredRowIterators class.

return merged;
}
else
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing NPEs in tests without this check

Copy link
Copy Markdown
Contributor Author

@netudima netudima May 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing NPEs in tests without this check

ok, let me check in more details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants