ben-manes commented on code in PR #23052:
URL: https://github.com/apache/pulsar/pull/23052#discussion_r1685279688
##########
pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java:
##########
@@ -79,11 +78,7 @@ public static TopicName get(String domain, String tenant,
String cluster, String
}
public static TopicName get(String topic) {
- try {
- return cache.get(topic);
- } catch (ExecutionException | UncheckedExecutionException e) {
- throw (RuntimeException) e.getCause();
- }
+ return cache.computeIfAbsent(topic, k -> new TopicName(k));
Review Comment:
computeIfAbsent is most often pessimistic in its locking, whereas Caffeine
does a lock-free read first before falling back to a computation. Since
caffeine is built on top of CHM and your readers will often block each other,
something seems very amiss with your benchmark results being so vastly
different in performance.
--
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]