This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch rel/1.2
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/1.2 by this push:
     new bf0860b9986 [To rel/1.2] Fix schema memory config initialization 
(#10078)
bf0860b9986 is described below

commit bf0860b9986248cfa14ba292b5d5cc3934654f60
Author: Marcos_Zyk <[email protected]>
AuthorDate: Fri Jun 9 09:21:41 2023 +0800

    [To rel/1.2] Fix schema memory config initialization (#10078)
---
 .../java/org/apache/iotdb/db/conf/IoTDBConfig.java | 33 +++++++------
 .../org/apache/iotdb/db/conf/IoTDBDescriptor.java  | 54 +++++++++++-----------
 2 files changed, 43 insertions(+), 44 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java 
b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index 816916ac7b1..b640f9198a2 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -1019,17 +1019,16 @@ public class IoTDBConfig {
   /** ThreadPool size for write operation in coordinator */
   private int coordinatorWriteExecutorSize = 50;
 
+  private int[] schemaMemoryProportion = new int[] {5, 4, 1};
+
   /** Memory allocated for schemaRegion */
-  private long allocateMemoryForSchemaRegion = allocateMemoryForSchema * 8 / 
10;
+  private long allocateMemoryForSchemaRegion = allocateMemoryForSchema * 5 / 
10;
 
   /** Memory allocated for SchemaCache */
-  private long allocateMemoryForSchemaCache = allocateMemoryForSchema / 10;
+  private long allocateMemoryForSchemaCache = allocateMemoryForSchema * 4 / 10;
 
   /** Memory allocated for PartitionCache */
-  private long allocateMemoryForPartitionCache = 0;
-
-  /** Memory allocated for LastCache */
-  private long allocateMemoryForLastCache = allocateMemoryForSchema / 10;
+  private long allocateMemoryForPartitionCache = allocateMemoryForSchema / 10;
 
   /** Policy of DataNodeSchemaCache eviction */
   private String dataNodeSchemaCacheEvictionPolicy = "FIFO";
@@ -1945,9 +1944,9 @@ public class IoTDBConfig {
   public void setAllocateMemoryForSchema(long allocateMemoryForSchema) {
     this.allocateMemoryForSchema = allocateMemoryForSchema;
 
-    this.allocateMemoryForSchemaRegion = allocateMemoryForSchema * 8 / 10;
-    this.allocateMemoryForSchemaCache = allocateMemoryForSchema / 10;
-    this.allocateMemoryForLastCache = allocateMemoryForSchema / 10;
+    this.allocateMemoryForSchemaRegion = allocateMemoryForSchema * 5 / 10;
+    this.allocateMemoryForSchemaCache = allocateMemoryForSchema * 4 / 10;
+    this.allocateMemoryForPartitionCache = allocateMemoryForSchema / 10;
   }
 
   public long getAllocateMemoryForConsensus() {
@@ -3377,6 +3376,14 @@ public class IoTDBConfig {
     return new TEndPoint(rpcAddress, rpcPort);
   }
 
+  public int[] getSchemaMemoryProportion() {
+    return schemaMemoryProportion;
+  }
+
+  public void setSchemaMemoryProportion(int[] schemaMemoryProportion) {
+    this.schemaMemoryProportion = schemaMemoryProportion;
+  }
+
   public long getAllocateMemoryForSchemaRegion() {
     return allocateMemoryForSchemaRegion;
   }
@@ -3401,14 +3408,6 @@ public class IoTDBConfig {
     this.allocateMemoryForPartitionCache = allocateMemoryForPartitionCache;
   }
 
-  public long getAllocateMemoryForLastCache() {
-    return allocateMemoryForLastCache;
-  }
-
-  public void setAllocateMemoryForLastCache(long allocateMemoryForLastCache) {
-    this.allocateMemoryForLastCache = allocateMemoryForLastCache;
-  }
-
   public String getDataNodeSchemaCacheEvictionPolicy() {
     return dataNodeSchemaCacheEvictionPolicy;
   }
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java 
b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
index 7d3093d1ba0..386920dbf4c 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
@@ -1802,59 +1802,59 @@ public class IoTDBDescriptor {
   private void initSchemaMemoryAllocate(Properties properties) {
     long schemaMemoryTotal = conf.getAllocateMemoryForSchema();
 
-    int proportionSum = 10;
-    int schemaRegionProportion = 5;
-    int schemaCacheProportion = 4;
-    int partitionCacheProportion = 1;
-    int lastCacheProportion = 0;
-
-    String schemaMemoryAllocatePortion = 
properties.getProperty("schema_memory_proportion");
-    if (schemaMemoryAllocatePortion != null) {
-      String[] proportions = schemaMemoryAllocatePortion.split(":");
+    String schemaMemoryPortionInput = 
properties.getProperty("schema_memory_proportion");
+    if (schemaMemoryPortionInput != null) {
+      String[] proportions = schemaMemoryPortionInput.split(":");
       int loadedProportionSum = 0;
       for (String proportion : proportions) {
         loadedProportionSum += Integer.parseInt(proportion.trim());
       }
 
       if (loadedProportionSum != 0) {
-        proportionSum = loadedProportionSum;
-        schemaRegionProportion = Integer.parseInt(proportions[0].trim());
-        schemaCacheProportion = Integer.parseInt(proportions[1].trim());
-        partitionCacheProportion = Integer.parseInt(proportions[2].trim());
+        conf.setSchemaMemoryProportion(
+            new int[] {
+              Integer.parseInt(proportions[0].trim()),
+              Integer.parseInt(proportions[1].trim()),
+              Integer.parseInt(proportions[2].trim())
+            });
       }
 
     } else {
-      schemaMemoryAllocatePortion = 
properties.getProperty("schema_memory_allocate_proportion");
-      if (schemaMemoryAllocatePortion != null) {
-        String[] proportions = schemaMemoryAllocatePortion.split(":");
+      schemaMemoryPortionInput = 
properties.getProperty("schema_memory_allocate_proportion");
+      if (schemaMemoryPortionInput != null) {
+        String[] proportions = schemaMemoryPortionInput.split(":");
         int loadedProportionSum = 0;
         for (String proportion : proportions) {
           loadedProportionSum += Integer.parseInt(proportion.trim());
         }
 
         if (loadedProportionSum != 0) {
-          proportionSum = loadedProportionSum;
-          schemaRegionProportion = Integer.parseInt(proportions[0].trim());
-          schemaCacheProportion = Integer.parseInt(proportions[1].trim());
-          partitionCacheProportion = Integer.parseInt(proportions[2].trim());
-          lastCacheProportion = Integer.parseInt(proportions[3].trim());
+          conf.setSchemaMemoryProportion(
+              new int[] {
+                Integer.parseInt(proportions[0].trim()),
+                Integer.parseInt(proportions[1].trim()) + 
Integer.parseInt(proportions[3].trim()),
+                Integer.parseInt(proportions[2].trim())
+              });
         }
       }
     }
 
+    int proportionSum = 0;
+    for (int proportion : conf.getSchemaMemoryProportion()) {
+      proportionSum += proportion;
+    }
+
     conf.setAllocateMemoryForSchemaRegion(
-        schemaMemoryTotal * schemaRegionProportion / proportionSum);
+        schemaMemoryTotal * conf.getSchemaMemoryProportion()[0] / 
proportionSum);
     logger.info("allocateMemoryForSchemaRegion = {}", 
conf.getAllocateMemoryForSchemaRegion());
 
-    conf.setAllocateMemoryForSchemaCache(schemaMemoryTotal * 
schemaCacheProportion / proportionSum);
+    conf.setAllocateMemoryForSchemaCache(
+        schemaMemoryTotal * conf.getSchemaMemoryProportion()[1] / 
proportionSum);
     logger.info("allocateMemoryForSchemaCache = {}", 
conf.getAllocateMemoryForSchemaCache());
 
     conf.setAllocateMemoryForPartitionCache(
-        schemaMemoryTotal * partitionCacheProportion / proportionSum);
+        schemaMemoryTotal * conf.getSchemaMemoryProportion()[2] / 
proportionSum);
     logger.info("allocateMemoryForPartitionCache = {}", 
conf.getAllocateMemoryForPartitionCache());
-
-    conf.setAllocateMemoryForLastCache(schemaMemoryTotal * lastCacheProportion 
/ proportionSum);
-    logger.info("allocateMemoryForLastCache = {}", 
conf.getAllocateMemoryForLastCache());
   }
 
   @SuppressWarnings("squid:S3518") // "proportionSum" can't be zero

Reply via email to