[ 
https://issues.apache.org/jira/browse/CASSANDRA-20804?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dmitry Konstantinov updated CASSANDRA-20804:
--------------------------------------------
    Test and Documentation Plan: the logic is covered by existing tests
                         Status: Patch Available  (was: In Progress)

> Optimize DataPlacement lookup by ReplicationParams
> --------------------------------------------------
>
>                 Key: CASSANDRA-20804
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-20804
>             Project: Apache Cassandra
>          Issue Type: Improvement
>          Components: Consistency/Coordination, Transactional Cluster Metadata
>            Reporter: Dmitry Konstantinov
>            Assignee: Dmitry Konstantinov
>            Priority: Normal
>             Fix For: 5.x
>
>         Attachments: image-2025-07-30-18-39-40-063.png
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> When we execute a plain write to identify replicas we do several lookups from 
> ClusterMetadata.placements map using ReplicationParams as a map key.
> Equals and hashcode for ReplicationParams objects are not very cheap, so 
> there is a noticible overhead for this logic in CPU profile (0.77% of overall 
> CPU usage for a plain write Cassandra stress test):
> !image-2025-07-30-18-39-40-063.png|width=700!
> To reduce it the following optimisations can be applied:
>  # Avoid double lookup of the same DataPlacement in 
> forNonLocalStrategyTokenRead and forNonLocalStrategyTokenWrite methods
>  # Memorize hashCode value
>  # Deduplicate ReplicationParams to use the same objects in DataPlacements 
> and KeyspaceMetadata to use the fast == path in the equals
> The last two optimizations are safe because ReplicationParams is immutable.
> Note: it is related to TCM logic, so it is trunk only issue.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to