File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed
iotdb-core/datanode/src/main/java/org/apache/iotdb/db
queryengine/plan/analyze/cache/schema/dualkeycache/impl Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -980,6 +980,12 @@ public class IoTDBConfig {
980980 /** Policy of DataNodeSchemaCache eviction */
981981 private String dataNodeSchemaCacheEvictionPolicy = "FIFO" ;
982982
983+ /**
984+ * Threshold for cache size in mayEvict. When cache size exceeds this threshold, the system will
985+ * compute total memory in each eviction iteration to ensure accurate memory management.
986+ */
987+ private int cacheEvictionMemoryComputationThreshold = 20 ;
988+
983989 private int dataNodeTableCacheSemaphorePermitNum = 5 ;
984990
985991 /** GRASS Service */
@@ -3269,6 +3275,15 @@ public void setDataNodeSchemaCacheEvictionPolicy(String dataNodeSchemaCacheEvict
32693275 this .dataNodeSchemaCacheEvictionPolicy = dataNodeSchemaCacheEvictionPolicy ;
32703276 }
32713277
3278+ public int getCacheEvictionMemoryComputationThreshold () {
3279+ return cacheEvictionMemoryComputationThreshold ;
3280+ }
3281+
3282+ public void setCacheEvictionMemoryComputationThreshold (
3283+ int cacheEvictionMemoryComputationThreshold ) {
3284+ this .cacheEvictionMemoryComputationThreshold = cacheEvictionMemoryComputationThreshold ;
3285+ }
3286+
32723287 public int getDataNodeTableCacheSemaphorePermitNum () {
32733288 return dataNodeTableCacheSemaphorePermitNum ;
32743289 }
Original file line number Diff line number Diff line change @@ -1061,6 +1061,12 @@ public void loadProperties(TrimProperties properties) throws BadNodeUrlException
10611061 properties .getProperty (
10621062 "datanode_schema_cache_eviction_policy" , conf .getDataNodeSchemaCacheEvictionPolicy ()));
10631063
1064+ conf .setCacheEvictionMemoryComputationThreshold (
1065+ Integer .parseInt (
1066+ properties .getProperty (
1067+ "cache_eviction_memory_computation_threshold" ,
1068+ String .valueOf (conf .getCacheEvictionMemoryComputationThreshold ()))));
1069+
10641070 conf .setDataNodeTableCacheSemaphorePermitNum (
10651071 Integer .parseInt (
10661072 properties .getProperty (
@@ -2131,6 +2137,13 @@ public synchronized void loadHotModifiedProps(TrimProperties properties)
21312137 // update trusted_uri_pattern
21322138 loadTrustedUriPattern (properties );
21332139
2140+ // update cache_eviction_memory_computation_threshold
2141+ conf .setCacheEvictionMemoryComputationThreshold (
2142+ Integer .parseInt (
2143+ properties .getProperty (
2144+ "cache_eviction_memory_computation_threshold" ,
2145+ String .valueOf (conf .getCacheEvictionMemoryComputationThreshold ()))));
2146+
21342147 // tvlist_sort_threshold
21352148 conf .setTVListSortThreshold (
21362149 Integer .parseInt (
Original file line number Diff line number Diff line change 1919
2020package org .apache .iotdb .db .queryengine .plan .analyze .cache .schema .dualkeycache .impl ;
2121
22+ import org .apache .iotdb .db .conf .IoTDBDescriptor ;
2223import org .apache .iotdb .db .queryengine .plan .analyze .cache .schema .dualkeycache .IDualKeyCache ;
2324import org .apache .iotdb .db .queryengine .plan .analyze .cache .schema .dualkeycache .IDualKeyCacheStats ;
2425
@@ -199,12 +200,13 @@ public void update(
199200
200201 private void mayEvict () {
201202 long exceedMemory ;
203+ final int threshold =
204+ IoTDBDescriptor .getInstance ().getConfig ().getCacheEvictionMemoryComputationThreshold ();
202205 while ((exceedMemory = cacheStats .getExceedMemory ()) > 0 ) {
203206 // Not compute each time to save time when FK is too many
204- // The hard-coded size is 100
205207 do {
206208 exceedMemory -= evictOneCacheEntry ();
207- } while (exceedMemory > 0 && firstKeyMap .size () > 100 );
209+ } while (exceedMemory > 0 && firstKeyMap .size () > threshold );
208210 }
209211 }
210212
You can’t perform that action at this time.
0 commit comments