summaryrefslogtreecommitdiffstats
path: root/container-search/src/main
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-03-06 16:04:10 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-03-06 16:04:10 +0000
commit41bdd708697929dc19f433417797ddad4533bd3e (patch)
tree690dac61c2a6e4a63be1f835e9fb0cc7a710321d /container-search/src/main
parent32f2ffc16a9fce1f35a47879aa3473661aa32228 (diff)
Let the implementation decide what kind of warmup is needed.
Diffstat (limited to 'container-search/src/main')
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java22
1 files changed, 8 insertions, 14 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java b/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java
index 6a25c9a5f4f..c2ea706acda 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java
@@ -128,7 +128,7 @@ public class Dispatcher extends AbstractComponent {
Thread warmup = new Thread(new Runnable() {
@Override
public void run() {
- warmupLZ4(dispatchConfig.warmuptime());
+ warmup(dispatchConfig.warmuptime());
}
});
warmup.start();
@@ -148,19 +148,13 @@ public class Dispatcher extends AbstractComponent {
searchCluster.pingIterationCompleted();
}
- private static long warmupLZ4(double seconds) {
- byte [] input = new byte[0x4000];
- Compressor lz4 = new Compressor();
- new Random().nextBytes(input);
- long timeDone = System.nanoTime() + (long)(seconds*1000000000);
- long compressedBytes = 0;
- byte [] decompressed = new byte [input.length];
- while (System.nanoTime() < timeDone) {
- byte [] compressed = lz4.compressUnconditionally(input);
- lz4.decompressUnconditionally(compressed, decompressed);
- compressedBytes += compressed.length;
- }
- return compressedBytes;
+ /*
+ Will run important code in order to trigger JIT compilation and avoid cold start issues.
+ Currently warms up lz4 compression code.
+ */
+
+ private static long warmup(double seconds) {
+ return new Compressor().warmup(seconds);
}
/** Returns the search cluster this dispatches to */