From 8b431fe33ec0c589a7cb7a11c974f56101ec0116 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 31 Dec 2024 15:10:21 +0800 Subject: [PATCH] [BugFix] Use a separate thread pool for dictionary collection (backport #54454) (#54513) Signed-off-by: stdpain <34912776+stdpain@users.noreply.github.com> Co-authored-by: stdpain <34912776+stdpain@users.noreply.github.com> --- fe/fe-core/src/main/java/com/starrocks/common/Config.java | 3 +++ .../starrocks/sql/optimizer/statistics/CacheDictManager.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/com/starrocks/common/Config.java b/fe/fe-core/src/main/java/com/starrocks/common/Config.java index 374fd9f0a4c13..df8a2ba08dd08 100644 --- a/fe/fe-core/src/main/java/com/starrocks/common/Config.java +++ b/fe/fe-core/src/main/java/com/starrocks/common/Config.java @@ -1868,6 +1868,9 @@ public class Config extends ConfigBase { @ConfField public static long statistic_dict_columns = 100000; + @ConfField + public static int dict_collect_thread_pool_size = 16; + /** * The column statistic cache update interval */ diff --git a/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/statistics/CacheDictManager.java b/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/statistics/CacheDictManager.java index e1b4c02ae9a16..c67aa0fd515b3 100644 --- a/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/statistics/CacheDictManager.java +++ b/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/statistics/CacheDictManager.java @@ -24,6 +24,7 @@ import com.starrocks.common.Config; import com.starrocks.common.Pair; import com.starrocks.common.Status; +import com.starrocks.common.ThreadPoolManager; import com.starrocks.memory.MemoryTrackable; import com.starrocks.qe.ConnectContext; import com.starrocks.server.GlobalStateMgr; @@ -53,7 +54,7 @@ public class CacheDictManager implements IDictManager, MemoryTrackable { public static final Integer LOW_CARDINALITY_THRESHOLD = 255; - private CacheDictManager() { + public CacheDictManager() { } private static final CacheDictManager INSTANCE = new CacheDictManager(); @@ -106,6 +107,8 @@ public CompletableFuture> asyncReload( private final AsyncLoadingCache> dictStatistics = Caffeine.newBuilder() .maximumSize(Config.statistic_dict_columns) + .executor(ThreadPoolManager.newDaemonCacheThreadPool(Config.dict_collect_thread_pool_size, "cache-dict", + false)) .buildAsync(dictLoader); private Optional deserializeColumnDict(long tableId, String columnName, TStatisticData statisticData) {