lhotari commented on PR #24463:
URL: https://github.com/apache/pulsar/pull/24463#issuecomment-4289722206

   > Actually, the performance is also affected by the slow `NamespaceName#get` 
call. I tried removing the `namespace` field from both `LegacyTopicName` and 
`TopicName` and ran the benchmark again, the result is:
   
   One additional detail to check is to see if optimizing 
org.apache.pulsar.common.naming.TopicDomain#getEnum would help. A general 
performance advice has been in the past to avoid calling Enum's `values()` in 
hot paths.
   
   something like this:
   ```java
       public static TopicDomain getEnum(String value) {
           if (persistent.value.equalsIgnoreCase(value)) {
              return persistent;
           }
           if (non_persistent.value.equalsIgnoreCase(value)) {
              return non_persistent;
           }
           if (topic.value.equalsIgnoreCase(value)) {
              return topic;
           }
           if (segment.value.equalsIgnoreCase(value)) {
              return segment;
           }
           throw new IllegalArgumentException("Invalid topic domain: '" + value 
+ "'");
       }
   ```
   
   I'm not sure if this type of optimization applies to modern JVMs.


-- 
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]

Reply via email to