Skip to content

[CASSANDRA-21289][trunk] Avoid capturing lambda allocation in UnfilteredSerializer.deserializeRowBody#4710

Closed
netudima wants to merge 1 commit into
apache:trunkfrom
netudima:CASSANDRA-21289-trunk
Closed

[CASSANDRA-21289][trunk] Avoid capturing lambda allocation in UnfilteredSerializer.deserializeRowBody#4710
netudima wants to merge 1 commit into
apache:trunkfrom
netudima:CASSANDRA-21289-trunk

Conversation

@netudima
Copy link
Copy Markdown
Contributor

@netudima netudima commented Apr 6, 2026

Avoid capturing lambda allocation in UnfilteredSerializer.deserializeRowBody

The same idea was applied previously in UnfilteredSerializer#serializeRowBody. A state is passed into a consumer function using the existing helper object.

patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-21289

Comment thread src/java/org/apache/cassandra/db/rows/UnfilteredSerializer.java
@maedhroz maedhroz self-requested a review April 10, 2026 18:54
Comment thread src/java/org/apache/cassandra/db/Columns.java Outdated
throw (IOException) e.getCause();

throw e;
}
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.

nit: Given the helper doesn't already fall off the stack when this method is done, we could add...

...
finally
{
    // Avoid retaining references longer than necessary
    helper.in = null;
    helper.header = null;
    helper.builder = null;
    helper.livenessInfo = null;
}

I guess we'll just be overwriting these 4 every time we process a new row, so maybe it's not a big deal.

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.

yes, it is overridden frequently for every row, so I think the benefit of early ref cleanup is low here, taking in account:

  • header is long living object
  • helper.in is also going to live together with helper after the re-use change in CASSANDRA-21296
  • livenessInfo is light
  • builder is re-used for a partition

also, technically writes are not totally free (due to GC barriers), so I would avoid extra ones for very frequent cell level logic.

Copy link
Copy Markdown
Contributor

@maedhroz maedhroz left a comment

Choose a reason for hiding this comment

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

LGTM, just left a couple nits

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.

+1

Comment thread src/java/org/apache/cassandra/db/rows/UnfilteredSerializer.java
@netudima netudima force-pushed the CASSANDRA-21289-trunk branch from 21f994a to 958eb59 Compare April 12, 2026 11:33
…RowBody

The same idea was applied previously in UnfilteredSerializer#serializeRowBody. A state is passed into a consumer function using the existing helper object.

patch by Dmitry Konstantinov; reviewed by Caleb Rackliffe, Francisco Guerrero for CASSANDRA-21289
@netudima netudima force-pushed the CASSANDRA-21289-trunk branch from 958eb59 to 2b991a6 Compare April 12, 2026 11:45
@netudima
Copy link
Copy Markdown
Contributor Author

committed as b09bc8b

@netudima netudima closed this Apr 12, 2026
@pmcfadin pmcfadin added the needs-committer Patch ready, waiting for a committer to review and merge label Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-committer Patch ready, waiting for a committer to review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants