From 574ba8ddd5753972305a2fc60f3cbad3f8085dda Mon Sep 17 00:00:00 2001 From: YC27 <76414902+YC27@users.noreply.github.com> Date: Tue, 22 Oct 2024 18:03:36 +0800 Subject: [PATCH] Active Load: Adjust the default execution thread to match the number of CPU cores (#13865) --- .../org/apache/iotdb/db/conf/IoTDBConfig.java | 2 +- .../apache/iotdb/db/conf/IoTDBDescriptor.java | 16 ++++++---------- .../conf/iotdb-system.properties.template | 4 ++-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java index 2dddbd3318dd..eb046f03989d 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java @@ -1199,7 +1199,7 @@ public class IoTDBConfig { private long loadActiveListeningCheckIntervalSeconds = 5L; - private int loadActiveListeningMaxThreadNum = 8; + private int loadActiveListeningMaxThreadNum = Runtime.getRuntime().availableProcessors(); /** Pipe related */ /** initialized as empty, updated based on the latest `systemDir` during querying */ diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java index f45025a2ad01..3376a4132395 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java @@ -2357,19 +2357,15 @@ private void loadLoadTsFileProps(Properties properties) { ? conf.getLoadActiveListeningCheckIntervalSeconds() : loadActiveListeningCheckIntervalSeconds); - final int defaultLoadActiveListeningMaxThreadNum = - Math.min( - conf.getLoadActiveListeningMaxThreadNum(), - Math.max(1, Runtime.getRuntime().availableProcessors() / 2)); - final int loadActiveListeningMaxThreadNum = + conf.setLoadActiveListeningMaxThreadNum( Integer.parseInt( properties.getProperty( "load_active_listening_max_thread_num", - Integer.toString(defaultLoadActiveListeningMaxThreadNum))); - conf.setLoadActiveListeningMaxThreadNum( - loadActiveListeningMaxThreadNum <= 0 - ? defaultLoadActiveListeningMaxThreadNum - : loadActiveListeningMaxThreadNum); + Integer.toString(conf.getLoadActiveListeningMaxThreadNum())))); + + if (conf.getLoadActiveListeningMaxThreadNum() <= 0) { + conf.setLoadActiveListeningMaxThreadNum(Runtime.getRuntime().availableProcessors()); + } } private void loadLoadTsFileHotModifiedProp(Properties properties) throws IOException { diff --git a/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template b/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template index 5e61fa8926f3..531891e456da 100644 --- a/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template +++ b/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template @@ -1949,10 +1949,10 @@ load_active_listening_dirs=ext/load/pending load_active_listening_fail_dir=ext/load/failed # The maximum number of threads that can be used to load tsfile actively. -# The default value, when this parameter is commented out, is the minimum of 8 or the number of CPU cores. +# The default value, when this parameter is commented out or <= 0, use CPU core number. # effectiveMode: restart # Datatype: int -load_active_listening_max_thread_num=8 +load_active_listening_max_thread_num=0 # The interval specified in seconds for the active listening mode to check the directory specified in load_active_listening_dirs. # The active listening mode will check the directory every load_active_listening_check_interval_seconds seconds.