Skip to content

Commit 212df13

Browse files
authored
[To dev/1.3] Change sort_buffer_size_in_bytes default value
(cherry picked from commit 2459e52)
1 parent 1b67ec5 commit 212df13

3 files changed

Lines changed: 27 additions & 8 deletions

File tree

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ public class IoTDBConfig {
452452
private volatile boolean enableAutoRepairCompaction = true;
453453

454454
/** The buffer for sort operation */
455-
private long sortBufferSize = 1024 * 1024L;
455+
private long sortBufferSize = 32 * 1024 * 1024L;
456456

457457
/**
458458
* The strategy of inner space compaction task. There are just one inner space compaction strategy

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,11 +1080,8 @@ public void loadProperties(TrimProperties properties) throws BadNodeUrlException
10801080
properties.getProperty("quota_enable", String.valueOf(conf.isQuotaEnable()))));
10811081

10821082
// The buffer for sort operator to calculate
1083-
conf.setSortBufferSize(
1084-
Long.parseLong(
1085-
properties
1086-
.getProperty("sort_buffer_size_in_bytes", Long.toString(conf.getSortBufferSize()))
1087-
.trim()));
1083+
1084+
loadSortBuffer(properties);
10881085

10891086
// tmp filePath for sort operator
10901087
conf.setSortTmpDir(properties.getProperty("sort_tmp_dir", conf.getSortTmpDir()));
@@ -1109,6 +1106,23 @@ public void loadProperties(TrimProperties properties) throws BadNodeUrlException
11091106
loadTrustedUriPattern(properties);
11101107
}
11111108

1109+
private void loadSortBuffer(TrimProperties properties) {
1110+
long defaultValue = calculateDefaultSortBufferSize();
1111+
long sortBufferSize =
1112+
Long.parseLong(
1113+
properties.getProperty("sort_buffer_size_in_bytes", Long.toString(defaultValue)));
1114+
if (sortBufferSize <= 0) {
1115+
sortBufferSize = defaultValue;
1116+
}
1117+
// The buffer for sort operator to calculate
1118+
conf.setSortBufferSize(sortBufferSize);
1119+
}
1120+
1121+
public static long calculateDefaultSortBufferSize() {
1122+
return Math.min(
1123+
32 * 1024 * 1024L, conf.getAllocateMemoryForOperators() / conf.getQueryThreadCount() / 2);
1124+
}
1125+
11121126
private void reloadConsensusProps(TrimProperties properties) throws IOException {
11131127
loadIoTConsensusProps(properties);
11141128
loadPipeConsensusProps(properties);
@@ -2042,6 +2056,9 @@ public synchronized void loadHotModifiedProps(TrimProperties properties)
20422056
properties.getProperty(
20432057
"tvlist_sort_threshold",
20442058
ConfigurationFileUtils.getConfigurationDefaultValue("tvlist_sort_threshold"))));
2059+
2060+
// sort_buffer_size_in_bytes
2061+
loadSortBuffer(properties);
20452062
} catch (Exception e) {
20462063
if (e instanceof InterruptedException) {
20472064
Thread.currentThread().interrupt();

iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,9 +1061,11 @@ mode_map_size_threshold=10000
10611061
batch_size=100000
10621062

10631063
# The memory for external sort in sort operator, when the data size is smaller than sort_buffer_size_in_bytes, the sort operator will use in-memory sort.
1064-
# effectiveMode: restart
1064+
# if sort_buffer_size_in_bytes <= 0, default value will be used, default value = min(32MB, memory for query operators / query_thread_count / 2)
1065+
# if sort_buffer_size_in_bytes > 0, the specified value will be used.
1066+
# effectiveMode: hot_reload
10651067
# Datatype: long
1066-
sort_buffer_size_in_bytes=1048576
1068+
sort_buffer_size_in_bytes=0
10671069

10681070
# The threshold of operator count in the result set of EXPLAIN ANALYZE, if the number of operator in the result set is larger than this threshold, operator will be merged.
10691071
# effectiveMode: hot_reload

0 commit comments

Comments
 (0)