[ 
https://issues.apache.org/jira/browse/CASSANDRA-20804?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18011610#comment-18011610
 ] 

Dmitry Konstantinov edited comment on CASSANDRA-20804 at 8/2/25 4:49 PM:
-------------------------------------------------------------------------

After applying changes (https://github.com/apache/cassandra/pull/4282)  the 
lookup cost is now invisible in CPU flamegraphs:

!image-2025-08-02-17-47-11-156.png|width=700!
 [^5.1_repl_cpu.html] 


 


was (Author: dnk):
After applying changes (https://github.com/apache/cassandra/pull/4282) there 
lookup cost is not invisible in CPU flamegraphs:

!image-2025-08-02-17-47-11-156.png|width=700!
 [^5.1_repl_cpu.html] 


 

> 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: 5.1_repl_cpu.html, image-2025-07-30-18-39-40-063.png, 
> image-2025-08-02-17-47-11-156.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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to