camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/8] camel git commit: CAMEL-11321: Start Camel faster by letting LRUCache warmup concurrently as that takes up 150 millis or more.
Date Wed, 05 Jul 2017 07:28:34 GMT
Repository: camel
Updated Branches:
  refs/heads/master 253b99c23 -> 763c9e021


CAMEL-11321: Start Camel faster by letting LRUCache warmup concurrently as that takes up 150
millis or more.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/95051f10
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/95051f10
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/95051f10

Branch: refs/heads/master
Commit: 95051f102ffdf1a14eb5b38ac78ceb2b97a52f81
Parents: 847241f
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Jul 4 18:12:26 2017 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Jul 5 09:28:22 2017 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/camel/util/LRUCacheFactory.java    | 9 +++++----
 .../src/test/java/org/apache/camel/ContextTestSupport.java  | 2 --
 2 files changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/95051f10/camel-core/src/main/java/org/apache/camel/util/LRUCacheFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/LRUCacheFactory.java b/camel-core/src/main/java/org/apache/camel/util/LRUCacheFactory.java
index 052f72d3..71363b3 100644
--- a/camel-core/src/main/java/org/apache/camel/util/LRUCacheFactory.java
+++ b/camel-core/src/main/java/org/apache/camel/util/LRUCacheFactory.java
@@ -29,7 +29,7 @@ public final class LRUCacheFactory {
 
     private static final Logger LOG = LoggerFactory.getLogger(LRUCacheFactory.class);
 
-    private static final AtomicBoolean done = new AtomicBoolean();
+    private static final AtomicBoolean init = new AtomicBoolean();
 
     private LRUCacheFactory() {
     }
@@ -39,8 +39,9 @@ public final class LRUCacheFactory {
         // create a dummy map in a separate thread to warm-up the Caffeine cache concurrently
         // while Camel is starting up. This allows us to overall startup Camel a bit faster
         // as Caffeine takes 150+ millis to initialize.
-        if (!done.compareAndSet(false, true)) {
-            Runnable warmup = () -> {
+        if (init.compareAndSet(false, true)) {
+            // only need to init Caffeine once in the JVM/classloader
+            Runnable task = () -> {
                 StopWatch watch = new StopWatch();
                 LOG.debug("Warming up LRUCache ...");
                 newLRUCache(16);
@@ -49,7 +50,7 @@ public final class LRUCacheFactory {
 
             String threadName = ThreadHelper.resolveThreadName(null, "LRUCacheFactory");
 
-            Thread thread = new Thread(warmup, threadName);
+            Thread thread = new Thread(task, threadName);
             thread.start();
         }
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/95051f10/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java b/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
index 8b9dfe4..e4544ce 100644
--- a/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
+++ b/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
@@ -83,8 +83,6 @@ public abstract class ContextTestSupport extends TestSupport {
     protected void setUp() throws Exception {
         // make SEDA testing faster
         System.setProperty("CamelSedaPollTimeout", "10");
-        // no need to warm-up when testing camel-core as that creates a new thread per CamelContext
and Caffiene is initialized only once
-        System.setProperty("CamelWarmUpLRUCacheFactory", "false");
 
         if (!useJmx()) {
             disableJMX();


Mime
View raw message