lhotari commented on code in PR #24457:
URL: https://github.com/apache/pulsar/pull/24457#discussion_r2166678550


##########
pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java:
##########
@@ -152,18 +139,18 @@ private TopicName(String completeTopicName) {
             parts = Splitter.on("/").limit(4).splitToList(rest);
             if (parts.size() == 3) {
                 // New topic name without cluster name
-                this.tenant = parts.get(0);
+                this.tenant = StringInterner.intern(parts.get(0));
                 this.cluster = null;
-                this.namespacePortion = parts.get(1);
-                this.localName = parts.get(2);
+                this.namespacePortion = StringInterner.intern(parts.get(1));
+                this.localName = StringInterner.intern(parts.get(2));
                 this.partitionIndex = getPartitionIndex(completeTopicName);
                 this.namespaceName = NamespaceName.get(tenant, 
namespacePortion);
             } else if (parts.size() == 4) {
                 // Legacy topic name that includes cluster name
-                this.tenant = parts.get(0);
-                this.cluster = parts.get(1);
-                this.namespacePortion = parts.get(2);
-                this.localName = parts.get(3);
+                this.tenant = StringInterner.intern(parts.get(0));
+                this.cluster = StringInterner.intern(parts.get(1));
+                this.namespacePortion = StringInterner.intern(parts.get(2));
+                this.localName = StringInterner.intern(parts.get(3));

Review Comment:
   The duplicate tenant and namespace parts add up. Within a cluster, lookups 
could happen on any broker. The topic pattern listing use case will load up 
more topic names into a single broker than it can hold. For partitioned topics 
this is multiplied by the number of partitions. There's a need to optimize 
memory usage of topic pattern listing use cases and String instance 
deduplication is a key solution in that. We can come back to that later.



-- 
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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to