You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "orpiske (via GitHub)" <gi...@apache.org> on 2023/05/03 13:28:06 UTC

[GitHub] [camel] orpiske commented on a diff in pull request #9986: CAMEL-19058: cache the producer and endpoint locally to avoid hitting the type check scalability issue

orpiske commented on code in PR #9986:
URL: https://github.com/apache/camel/pull/9986#discussion_r1183687861


##########
core/camel-support/src/main/java/org/apache/camel/support/cache/DefaultProducerCache.java:
##########
@@ -120,11 +123,20 @@ public Object getSource() {
 
     @Override
     public AsyncProducer acquireProducer(Endpoint endpoint) {
+        // Try to favor thread locality as some data in the producer's cache may be shared among threads,
+        // triggering cases of false sharing
+        if (endpoint == lastUsedEndpoint && endpoint.isSingletonProducer()) {
+            return lastUsedProducer;
+        }
+
         try {
             AsyncProducer producer = producers.acquire(endpoint);
             if (statistics != null) {
                 statistics.onHit(endpoint.getEndpointUri());
             }
+            lastUsedEndpoint = endpoint;

Review Comment:
   Hm, I guess I should synchronize this, then ...



-- 
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-unsubscribe@camel.apache.org

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