-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[ CASSANDRA-21088][trunk] Minor perf optimizations around memtable put logic #4538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
Avoid BTree iterators allocation in ColumnsCollector.update reduce amout of virtual calls for Cell.dataSize avoid capturing lambda allocation in BTreeRow.clone do not recalculate minLocalDeletionTime when BTreeRow is cloned Patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-21088
| BTree.apply(columns, function); | ||
| } | ||
|
|
||
| public <V> void apply(BiConsumer<V, ColumnMetadata> function, V argument) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is identical to other method public void apply(Consumer<ColumnMetadata> function), does passing the argument improves the performance and do you have any metrics to support that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the idea was to avoid BTree iterator allocation AbstractMemtable.ColumnsCollector#update(org.apache.cassandra.db.RegularAndStaticColumns) using the apply method logic. At the same time I worried about introducing a capturing lambda as an extra allocation.
But, I've decided to re-check if a non-static method reference works as a capturing lambda and apparently it is not, I do not see an allocation in profiles if I use a method reference. So, I can just use the existing apply method without an extra argument and introducing of apply with an argument is not needed to solve the current issue.
| return result; | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method & transformLeaf is duplicating a lot of code. Do we have any metrics on performance improvements? otherwise the duplication could cause cause inconsistencies in code, maintenance issues and could create bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I've attached test results to the ticket. Unfortunately the method reference trick which I mentioned in another comment does not work for logic in org.apache.cassandra.db.rows.BTreeRow#clone.
BTree functionality is stable and does not change frequently to introduce too much maintenance cost here. Also, the same pattern has been already used previously in this class for transformAndFilter logic.
Avoid BTree iterators allocation in ColumnsCollector.update
reduce amount of virtual calls for Cell.dataSize
avoid capturing lambda allocation in BTreeRow.clone
do not recalculate minLocalDeletionTime when BTreeRow is cloned
Patch by Dmitry Konstantinov; reviewed by TBD for CASSANDRA-21088