netudima commented on code in PR #4282:
URL: https://github.com/apache/cassandra/pull/4282#discussion_r2267482852


##########
src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java:
##########
@@ -82,6 +82,13 @@ public Keyspaces apply(ClusterMetadata metadata)
         }
 
         KeyspaceMetadata keyspaceMetadata = 
KeyspaceMetadata.create(keyspaceName, attrs.asNewKeyspaceParams());
+        // we deduplicate ReplicationParams here to use the same objects in 
KeyspaceMetadata
+        // as we have as keys in metadata.placements to have a fast map lookup
+        // ReplicationParams are immutable, so it is a safe optimization
+        KeyspaceParams keyspaceParams = keyspaceMetadata.params;
+        ReplicationParams replicationParams = 
metadata.placements.deduplicateReplicationParams(keyspaceParams.replication);

Review Comment:
   I've added the deduplication for the snapshot loading case as well.
   The cost of the remaining equals logic is about 0.3% of total CPU (the test 
load is CPU-bound, so it corresponds to the real 0.3% of CPU).
   While it may look as a small amount the problem is that the majority of our 
hot write path is composed of such small fragments, each one take a little, but 
in sum they consume a lot of CPU, so if we want to improve overall performance 
we have to deal with such small things.
   So, my suggestion is to add the deduplication, the logic is straightforward 
and I do not see particular risks here to make it less stable.
   <img width="1509" height="615" alt="image" 
src="https://github.com/user-attachments/assets/caadfb6d-365a-4075-b16b-984509fc5730";
 />
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to