This is an automated email from the ASF dual-hosted git repository.
justinchen pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/dev/1.3 by this push:
new b46f637b2af [To dev/1.3] Optimize the efficiency of DualKeyCacheImpl's
mayEvict (#16445) (#16669)
b46f637b2af is described below
commit b46f637b2af8bf739388cb6b9d12463d48e1b55a
Author: Zhenyu Luo <[email protected]>
AuthorDate: Tue Oct 28 19:19:07 2025 +0800
[To dev/1.3] Optimize the efficiency of DualKeyCacheImpl's mayEvict
(#16445) (#16669)
---
.../main/java/org/apache/iotdb/db/conf/IoTDBConfig.java | 15 +++++++++++++++
.../java/org/apache/iotdb/db/conf/IoTDBDescriptor.java | 13 +++++++++++++
.../cache/schema/dualkeycache/impl/DualKeyCacheImpl.java | 6 ++++--
3 files changed, 32 insertions(+), 2 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 ce69ed58574..1a65d588aa5 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
@@ -1051,6 +1051,12 @@ public class IoTDBConfig {
/** Policy of DataNodeSchemaCache eviction */
private String dataNodeSchemaCacheEvictionPolicy = "FIFO";
+ /**
+ * Threshold for cache size in mayEvict. When cache size exceeds this
threshold, the system will
+ * compute total memory in each eviction iteration to ensure accurate memory
management.
+ */
+ private int cacheEvictionMemoryComputationThreshold = 20;
+
private int schemaThreadCount = 5;
private String readConsistencyLevel = "strong";
@@ -3506,6 +3512,15 @@ public class IoTDBConfig {
this.dataNodeSchemaCacheEvictionPolicy = dataNodeSchemaCacheEvictionPolicy;
}
+ public int getCacheEvictionMemoryComputationThreshold() {
+ return cacheEvictionMemoryComputationThreshold;
+ }
+
+ public void setCacheEvictionMemoryComputationThreshold(
+ int cacheEvictionMemoryComputationThreshold) {
+ this.cacheEvictionMemoryComputationThreshold =
cacheEvictionMemoryComputationThreshold;
+ }
+
public int getSchemaThreadCount() {
return schemaThreadCount;
}
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 7cbfa232e67..e093d73a3c6 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
@@ -1097,6 +1097,12 @@ public class IoTDBDescriptor {
properties.getProperty(
"datanode_schema_cache_eviction_policy",
conf.getDataNodeSchemaCacheEvictionPolicy()));
+ conf.setCacheEvictionMemoryComputationThreshold(
+ Integer.parseInt(
+ properties.getProperty(
+ "cache_eviction_memory_computation_threshold",
+
String.valueOf(conf.getCacheEvictionMemoryComputationThreshold()))));
+
conf.setSchemaThreadCount(
Integer.parseInt(
properties.getProperty(
@@ -2076,6 +2082,13 @@ public class IoTDBDescriptor {
// update trusted_uri_pattern
loadTrustedUriPattern(properties);
+ // update cache_eviction_memory_computation_threshold
+ conf.setCacheEvictionMemoryComputationThreshold(
+ Integer.parseInt(
+ properties.getProperty(
+ "cache_eviction_memory_computation_threshold",
+
String.valueOf(conf.getCacheEvictionMemoryComputationThreshold()))));
+
// tvlist_sort_threshold
conf.setTVListSortThreshold(
Integer.parseInt(
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/schema/dualkeycache/impl/DualKeyCacheImpl.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/schema/dualkeycache/impl/DualKeyCacheImpl.java
index 5e614fa5fd3..86d10422249 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/schema/dualkeycache/impl/DualKeyCacheImpl.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/schema/dualkeycache/impl/DualKeyCacheImpl.java
@@ -19,6 +19,7 @@
package
org.apache.iotdb.db.queryengine.plan.analyze.cache.schema.dualkeycache.impl;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
import
org.apache.iotdb.db.queryengine.plan.analyze.cache.schema.dualkeycache.IDualKeyCache;
import
org.apache.iotdb.db.queryengine.plan.analyze.cache.schema.dualkeycache.IDualKeyCacheStats;
@@ -199,12 +200,13 @@ class DualKeyCacheImpl<FK, SK, V, T extends
ICacheEntry<SK, V>>
private void mayEvict() {
long exceedMemory;
+ final int threshold =
+
IoTDBDescriptor.getInstance().getConfig().getCacheEvictionMemoryComputationThreshold();
while ((exceedMemory = cacheStats.getExceedMemory()) > 0) {
// Not compute each time to save time when FK is too many
- // The hard-coded size is 100
do {
exceedMemory -= evictOneCacheEntry();
- } while (exceedMemory > 0 && firstKeyMap.size() > 100);
+ } while (exceedMemory > 0 && firstKeyMap.size() > threshold);
}
}