From 79bada9e9fa9e4de21c234a08600cc9b2c04c136 Mon Sep 17 00:00:00 2001 From: Pooya Salehi Date: Wed, 28 Aug 2024 10:14:57 +0200 Subject: [PATCH] comment --- .../threadpool/DefaultBuiltInExecutorBuilders.java | 7 ++++--- .../main/java/org/elasticsearch/threadpool/ThreadPool.java | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/threadpool/DefaultBuiltInExecutorBuilders.java b/server/src/main/java/org/elasticsearch/threadpool/DefaultBuiltInExecutorBuilders.java index bf7e2a7bbdc86..a4046f2f1594c 100644 --- a/server/src/main/java/org/elasticsearch/threadpool/DefaultBuiltInExecutorBuilders.java +++ b/server/src/main/java/org/elasticsearch/threadpool/DefaultBuiltInExecutorBuilders.java @@ -18,6 +18,7 @@ import java.util.Map; import static java.util.Collections.unmodifiableMap; +import static org.elasticsearch.threadpool.ThreadPool.indexAutoscalingEWMA; import static org.elasticsearch.threadpool.ThreadPool.searchAutoscalingEWMA; public class DefaultBuiltInExecutorBuilders implements BuiltInExecutorBuilders { @@ -41,7 +42,7 @@ public Map getBuilders(Settings settings, int allocated ThreadPool.Names.WRITE, allocatedProcessors, 10000, - new EsExecutors.TaskTrackingConfig(true, 0.1) + new EsExecutors.TaskTrackingConfig(true, indexAutoscalingEWMA) ) ); int searchOrGetThreadPoolSize = ThreadPool.searchOrGetThreadPoolSize(allocatedProcessors); @@ -187,7 +188,7 @@ public Map getBuilders(Settings settings, int allocated ThreadPool.Names.SYSTEM_WRITE, halfProcMaxAt5, 1000, - new EsExecutors.TaskTrackingConfig(true, 0.1) + new EsExecutors.TaskTrackingConfig(true, indexAutoscalingEWMA) ) ); result.put( @@ -207,7 +208,7 @@ public Map getBuilders(Settings settings, int allocated ThreadPool.Names.SYSTEM_CRITICAL_WRITE, halfProcMaxAt5, 1500, - new EsExecutors.TaskTrackingConfig(true, 0.1) + new EsExecutors.TaskTrackingConfig(true, indexAutoscalingEWMA) ) ); return unmodifiableMap(result); diff --git a/server/src/main/java/org/elasticsearch/threadpool/ThreadPool.java b/server/src/main/java/org/elasticsearch/threadpool/ThreadPool.java index 859c4a3e924c6..10b92f8c6dace 100644 --- a/server/src/main/java/org/elasticsearch/threadpool/ThreadPool.java +++ b/server/src/main/java/org/elasticsearch/threadpool/ThreadPool.java @@ -178,6 +178,13 @@ public static ThreadPoolType fromType(String type) { public static final double searchAutoscalingEWMA = 0.1; + // This value is chosen such that a sudden increase in the task durations would need to persist roughly for 120 samples + // for the EWMA value to be mostly representative of the increased task durations. Mostly representative means that the + // EWMA value is at least within 90% of the new increased task duration. This value also determines the impact of a single + // long-running task on the moving average and limits it roughly to 2% of the (long) task duration, e.g. if the current + // moving average is 100ms, and we get one task which takes 20s the new EWMA will be ~500ms. + public static final double indexAutoscalingEWMA = 0.02; + private final Map executors; private final ThreadPoolInfo threadPoolInfo;