You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2023/11/01 02:15:05 UTC
(iotdb) 01/01: Pipe: remove unnecessary waiting operation for memory alloc calculation
This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch fix-long-time-allocate
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 0309be6d8329b176f172f57bc0eaf99d33a179a6
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Wed Nov 1 10:14:56 2023 +0800
Pipe: remove unnecessary waiting operation for memory alloc calculation
---
.../iotdb/db/pipe/resource/memory/PipeMemoryManager.java | 7 -------
.../storageengine/dataregion/wal/utils/WALInsertNodeCache.java | 10 +++++++++-
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryManager.java
index 895d5890a03..97688e7b87d 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryManager.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryManager.java
@@ -170,13 +170,6 @@ public class PipeMemoryManager {
return new PipeMemoryBlock(sizeToAllocateInBytes);
}
- try {
- this.wait(MEMORY_ALLOCATE_RETRY_INTERVAL_IN_MS);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- LOGGER.warn("tryAllocate: interrupted while waiting for available memory", e);
- }
-
sizeToAllocateInBytes =
Math.max(sizeToAllocateInBytes * 2 / 3, MEMORY_ALLOCATE_MIN_SIZE_IN_BYTES);
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/WALInsertNodeCache.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/WALInsertNodeCache.java
index 44e2c287622..3286c54640d 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/WALInsertNodeCache.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/WALInsertNodeCache.java
@@ -19,6 +19,8 @@
package org.apache.iotdb.db.storageengine.dataregion.wal.utils;
+import org.apache.iotdb.commons.conf.CommonConfig;
+import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.utils.TestOnly;
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
@@ -56,6 +58,7 @@ public class WALInsertNodeCache {
private static final Logger LOGGER = LoggerFactory.getLogger(WALInsertNodeCache.class);
private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
+ private static final CommonConfig COMMON_CONFIG = CommonDescriptor.getInstance().getConfig();
// LRU cache, find Pair<ByteBuffer, InsertNode> by WALEntryPosition
private final PipeMemoryBlock allocatedMemoryBlock;
@@ -69,7 +72,12 @@ public class WALInsertNodeCache {
private WALInsertNodeCache(Integer dataRegionId) {
allocatedMemoryBlock =
- PipeResourceManager.memory().tryAllocate(2 * CONFIG.getWalFileSizeThresholdInByte());
+ PipeResourceManager.memory()
+ .tryAllocate(
+ (long)
+ Math.min(
+ 2 * CONFIG.getWalFileSizeThresholdInByte(),
+ CONFIG.getAllocateMemoryForPipe() * 0.8 / 5));
isBatchLoadEnabled =
allocatedMemoryBlock.getMemoryUsageInBytes() >= CONFIG.getWalFileSizeThresholdInByte();
lruCache =