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

spricoder pushed a commit to branch feature/optimize_memory
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/feature/optimize_memory by 
this push:
     new 05b0757a23f add total
05b0757a23f is described below

commit 05b0757a23f5d6b5046dcf531cc10ab959e7f838
Author: spricoder <[email protected]>
AuthorDate: Fri Dec 27 10:49:25 2024 +0800

    add total
---
 .../java/org/apache/iotdb/db/conf/IoTDBConfig.java |  7 ----
 .../metrics/memory/ThresholdMemoryMetrics.java     | 44 ++++++++++++++++------
 2 files changed, 32 insertions(+), 19 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 9b26ca3da23..3554610e20b 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
@@ -2156,13 +2156,6 @@ public class IoTDBConfig {
     this.allocateMemoryForPipe = allocateMemoryForPipe;
   }
 
-  public long getAllocateMemoryForFree() {
-    return Runtime.getRuntime().maxMemory()
-        - allocateMemoryForStorageEngine
-        - allocateMemoryForRead
-        - allocateMemoryForSchema;
-  }
-
   public boolean isEnablePartialInsert() {
     return enablePartialInsert;
   }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/ThresholdMemoryMetrics.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/ThresholdMemoryMetrics.java
index bdb333a3795..bd31e32f4b9 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/ThresholdMemoryMetrics.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/metrics/memory/ThresholdMemoryMetrics.java
@@ -40,11 +40,22 @@ public class ThresholdMemoryMetrics implements IMetricSet {
             Metric.THRESHOLD_MEMORY_SIZE.toString(),
             MetricLevel.NORMAL,
             Tag.NAME.toString(),
-            "StorageEngine",
+            "Total",
             Tag.TYPE.toString(),
             "OnHeap",
             Tag.LEVEL.toString(),
             "0")
+        .set(Runtime.getRuntime().maxMemory());
+    metricService
+        .getOrCreateGauge(
+            Metric.THRESHOLD_MEMORY_SIZE.toString(),
+            MetricLevel.NORMAL,
+            Tag.NAME.toString(),
+            "StorageEngine",
+            Tag.TYPE.toString(),
+            "OnHeap",
+            Tag.LEVEL.toString(),
+            "1")
         .set(config.getAllocateMemoryForStorageEngine());
     metricService
         .getOrCreateGauge(
@@ -55,7 +66,7 @@ public class ThresholdMemoryMetrics implements IMetricSet {
             Tag.TYPE.toString(),
             "OnHeap",
             Tag.LEVEL.toString(),
-            "0")
+            "1")
         .set(config.getAllocateMemoryForRead());
     metricService
         .getOrCreateGauge(
@@ -66,7 +77,7 @@ public class ThresholdMemoryMetrics implements IMetricSet {
             Tag.TYPE.toString(),
             "OnHeap",
             Tag.LEVEL.toString(),
-            "0")
+            "1")
         .set(config.getAllocateMemoryForSchema());
     metricService
         .getOrCreateGauge(
@@ -77,7 +88,7 @@ public class ThresholdMemoryMetrics implements IMetricSet {
             Tag.TYPE.toString(),
             "OnHeap",
             Tag.LEVEL.toString(),
-            "0")
+            "1")
         .set(config.getAllocateMemoryForConsensus());
     metricService
         .getOrCreateGauge(
@@ -88,7 +99,7 @@ public class ThresholdMemoryMetrics implements IMetricSet {
             Tag.TYPE.toString(),
             "OnHeap",
             Tag.LEVEL.toString(),
-            "0")
+            "1")
         .set(config.getAllocateMemoryForPipe());
     metricService
         .getOrCreateGauge(
@@ -99,7 +110,7 @@ public class ThresholdMemoryMetrics implements IMetricSet {
             Tag.TYPE.toString(),
             "OffHeap",
             Tag.LEVEL.toString(),
-            "0")
+            "1")
         .set(systemInfo.getTotalDirectBufferMemorySizeLimit());
   }
 
@@ -109,11 +120,20 @@ public class ThresholdMemoryMetrics implements IMetricSet 
{
         MetricType.GAUGE,
         Metric.THRESHOLD_MEMORY_SIZE.toString(),
         Tag.NAME.toString(),
-        "StorageEngine",
+        "Total",
         Tag.TYPE.toString(),
         "OnHeap",
         Tag.LEVEL.toString(),
         "0");
+    metricService.remove(
+        MetricType.GAUGE,
+        Metric.THRESHOLD_MEMORY_SIZE.toString(),
+        Tag.NAME.toString(),
+        "StorageEngine",
+        Tag.TYPE.toString(),
+        "OnHeap",
+        Tag.LEVEL.toString(),
+        "1");
     metricService.remove(
         MetricType.GAUGE,
         Metric.THRESHOLD_MEMORY_SIZE.toString(),
@@ -122,7 +142,7 @@ public class ThresholdMemoryMetrics implements IMetricSet {
         Tag.TYPE.toString(),
         "OnHeap",
         Tag.LEVEL.toString(),
-        "0");
+        "1");
     metricService.remove(
         MetricType.GAUGE,
         Metric.THRESHOLD_MEMORY_SIZE.toString(),
@@ -131,7 +151,7 @@ public class ThresholdMemoryMetrics implements IMetricSet {
         Tag.TYPE.toString(),
         "OnHeap",
         Tag.LEVEL.toString(),
-        "0");
+        "1");
     metricService.remove(
         MetricType.GAUGE,
         Metric.THRESHOLD_MEMORY_SIZE.toString(),
@@ -140,7 +160,7 @@ public class ThresholdMemoryMetrics implements IMetricSet {
         Tag.TYPE.toString(),
         "OnHeap",
         Tag.LEVEL.toString(),
-        "0");
+        "1");
     metricService.remove(
         MetricType.GAUGE,
         Metric.THRESHOLD_MEMORY_SIZE.toString(),
@@ -149,7 +169,7 @@ public class ThresholdMemoryMetrics implements IMetricSet {
         Tag.TYPE.toString(),
         "OnHeap",
         Tag.LEVEL.toString(),
-        "0");
+        "1");
     metricService.remove(
         MetricType.GAUGE,
         Metric.THRESHOLD_MEMORY_SIZE.toString(),
@@ -158,7 +178,7 @@ public class ThresholdMemoryMetrics implements IMetricSet {
         Tag.TYPE.toString(),
         "OffHeap",
         Tag.LEVEL.toString(),
-        "0");
+        "1");
   }
 
   public static ThresholdMemoryMetrics getInstance() {

Reply via email to