You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2023/05/11 01:23:47 UTC
[iotdb] branch master updated: [IOTDB-5858] Remove useless class cast and update schema cache hit
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 921faa061b [IOTDB-5858] Remove useless class cast and update schema cache hit
921faa061b is described below
commit 921faa061be016ed9a888bad267c6ec0844a0f53
Author: ZhangHongYin <46...@users.noreply.github.com>
AuthorDate: Thu May 11 09:23:39 2023 +0800
[IOTDB-5858] Remove useless class cast and update schema cache hit
---
docs/UserGuide/Monitor-Alert/Metric-Tool.md | 8 +++++---
docs/zh/UserGuide/Monitor-Alert/Metric-Tool.md | 24 ++++++++++++----------
.../metrics/metricsets/jvm/JvmMemoryMetrics.java | 6 +++---
.../db/engine/cache/TimeSeriesMetadataCache.java | 7 +++----
.../db/metadata/cache/DataNodeSchemaCache.java | 12 ++++++-----
.../metadata/cache/DataNodeSchemaCacheMetrics.java | 17 ++++++++++++---
6 files changed, 45 insertions(+), 29 deletions(-)
diff --git a/docs/UserGuide/Monitor-Alert/Metric-Tool.md b/docs/UserGuide/Monitor-Alert/Metric-Tool.md
index f670e83911..4f655938b7 100644
--- a/docs/UserGuide/Monitor-Alert/Metric-Tool.md
+++ b/docs/UserGuide/Monitor-Alert/Metric-Tool.md
@@ -308,7 +308,7 @@ carefully evaluated. The current Core-level metrics are as follows:
#### 4.2.4. Cache
| Metric | Tags | Type | Description |
-| --------- | ---------------------------------- | --------- | ------------------------------------------------------------------------ |
+| --------- |------------------------------------| --------- |--------------------------------------------------------------------------|
| cache_hit | name="chunk" | AutoGauge | The cache hit ratio of ChunkCache, Unit: % |
| cache_hit | name="schema" | AutoGauge | The cache hit ratio of SchemaCache, Unit: % |
| cache_hit | name="timeSeriesMeta" | AutoGauge | The cache hit ratio of TimeseriesMetadataCache, Unit: % |
@@ -316,9 +316,11 @@ carefully evaluated. The current Core-level metrics are as follows:
| cache | name="Database", type="hit" | Counter | The hit number of Database Cache |
| cache | name="Database", type="all" | Counter | The access number of Database Cache |
| cache | name="SchemaPartition", type="hit" | Counter | The hit number of SchemaPartition Cache |
-| cache | name="SchemaPartition", type="all" | Counter | The access number of SSchemaPartition Cache |
+| cache | name="SchemaPartition", type="all" | Counter | The access number of SchemaPartition Cache |
| cache | name="DataPartition", type="hit" | Counter | The hit number of DataPartition Cache |
-| cache | name="DataPartition", type="all" | Counter | The access number of SDataPartition Cache |
+| cache | name="DataPartition", type="all" | Counter | The access number of DataPartition Cache |
+| cache | name="SchemaCache", type="hit" | Counter | The hit number of Schema Cache |
+| cache | name="SchemaCache", type="all" | Counter | The access number of Schema Cache |
#### 4.2.5. Memory
diff --git a/docs/zh/UserGuide/Monitor-Alert/Metric-Tool.md b/docs/zh/UserGuide/Monitor-Alert/Metric-Tool.md
index b2e8cf5e58..86bffaa4fe 100644
--- a/docs/zh/UserGuide/Monitor-Alert/Metric-Tool.md
+++ b/docs/zh/UserGuide/Monitor-Alert/Metric-Tool.md
@@ -286,18 +286,20 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
#### 4.2.4. 缓存统计
-| Metric | Tags | Type | Description |
-| --------- | ---------------------------------- | --------- | ------------------------------------------------------- |
-| cache_hit | name="chunk" | AutoGauge | ChunkCache的命中率,单位为% |
-| cache_hit | name="schema" | AutoGauge | SchemaCache的命中率,单位为% |
-| cache_hit | name="timeSeriesMeta" | AutoGauge | TimeseriesMetadataCache的命中率,单位为% |
+| Metric | Tags | Type | Description |
+| --------- |------------------------------------| --------- |-----------------------------------------------|
+| cache_hit | name="chunk" | AutoGauge | ChunkCache的命中率,单位为% |
+| cache_hit | name="schema" | AutoGauge | SchemaCache的命中率,单位为% |
+| cache_hit | name="timeSeriesMeta" | AutoGauge | TimeseriesMetadataCache的命中率,单位为% |
| cache_hit | name="bloomFilter" | AutoGauge | TimeseriesMetadataCache中的bloomFilter的拦截率,单位为% |
-| cache | name="Database", type="hit" | Counter | Database Cache 的命中次数 |
-| cache | name="Database", type="all" | Counter | Database Cache 的访问次数 |
-| cache | name="SchemaPartition", type="hit" | Counter | SchemaPartition Cache 的命中次数 |
-| cache | name="SchemaPartition", type="all" | Counter | SchemaPartition Cache 的访问次数 |
-| cache | name="DataPartition", type="hit" | Counter | DataPartition Cache 的命中次数 |
-| cache | name="DataPartition", type="all" | Counter | DataPartition Cache 的访问次数 |
+| cache | name="Database", type="hit" | Counter | Database Cache 的命中次数 |
+| cache | name="Database", type="all" | Counter | Database Cache 的访问次数 |
+| cache | name="SchemaPartition", type="hit" | Counter | SchemaPartition Cache 的命中次数 |
+| cache | name="SchemaPartition", type="all" | Counter | SchemaPartition Cache 的访问次数 |
+| cache | name="DataPartition", type="hit" | Counter | DataPartition Cache 的命中次数 |
+| cache | name="DataPartition", type="all" | Counter | DataPartition Cache 的访问次数 |
+| cache | name="SchemaCache", type="hit" | Counter | SchemaCache 的命中次数 |
+| cache | name="SchemaCache", type="all" | Counter | SchemaCache 的访问次数 |
#### 4.2.5. 内存统计
diff --git a/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmMemoryMetrics.java b/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmMemoryMetrics.java
index 4e5f549ea0..efef8aae98 100644
--- a/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmMemoryMetrics.java
+++ b/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/jvm/JvmMemoryMetrics.java
@@ -69,7 +69,7 @@ public class JvmMemoryMetrics implements IMetricSet {
"jvm_memory_used_bytes",
MetricLevel.CORE,
memoryPoolBean,
- (mem) -> (long) JvmUtils.getUsageValue(mem, MemoryUsage::getUsed),
+ (mem) -> JvmUtils.getUsageValue(mem, MemoryUsage::getUsed),
"id",
memoryPoolBean.getName(),
"area",
@@ -79,7 +79,7 @@ public class JvmMemoryMetrics implements IMetricSet {
"jvm_memory_committed_bytes",
MetricLevel.CORE,
memoryPoolBean,
- (mem) -> (long) JvmUtils.getUsageValue(mem, MemoryUsage::getCommitted),
+ (mem) -> JvmUtils.getUsageValue(mem, MemoryUsage::getCommitted),
"id",
memoryPoolBean.getName(),
"area",
@@ -89,7 +89,7 @@ public class JvmMemoryMetrics implements IMetricSet {
"jvm_memory_max_bytes",
MetricLevel.CORE,
memoryPoolBean,
- (mem) -> (long) JvmUtils.getUsageValue(mem, MemoryUsage::getMax),
+ (mem) -> JvmUtils.getUsageValue(mem, MemoryUsage::getMax),
"id",
memoryPoolBean.getName(),
"area",
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/cache/TimeSeriesMetadataCache.java b/server/src/main/java/org/apache/iotdb/db/engine/cache/TimeSeriesMetadataCache.java
index 89b7d52fa3..25a2a6b4f6 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/cache/TimeSeriesMetadataCache.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/cache/TimeSeriesMetadataCache.java
@@ -238,12 +238,11 @@ public class TimeSeriesMetadataCache {
return entryAverageSize.get();
}
- public long calculateBloomFilterHitRatio() {
+ public double calculateBloomFilterHitRatio() {
if (bloomFilterRequestCount.get() == 0L) {
- return 1L;
+ return 1.0d;
}
- return (long)
- ((double) bloomFilterPreventCount.get() / (double) bloomFilterRequestCount.get() * 100L);
+ return bloomFilterPreventCount.get() * 100.0d / bloomFilterRequestCount.get();
}
/** clear LRUCache. */
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCache.java b/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCache.java
index 62d661fd7b..b63fa02bbe 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCache.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCache.java
@@ -68,11 +68,13 @@ public class DataNodeSchemaCache {
MetricService.getInstance().addMetricSet(new DataNodeSchemaCacheMetrics(this));
}
- public double getHitRate() {
- return (deviceUsingTemplateSchemaCache.getHitCount() + timeSeriesSchemaCache.getHitCount())
- * 1.0
- / (deviceUsingTemplateSchemaCache.getRequestCount()
- + timeSeriesSchemaCache.getRequestCount());
+ public long getHitCount() {
+ return deviceUsingTemplateSchemaCache.getHitCount() + timeSeriesSchemaCache.getHitCount();
+ }
+
+ public long getRequestCount() {
+ return deviceUsingTemplateSchemaCache.getRequestCount()
+ + timeSeriesSchemaCache.getRequestCount();
}
public static DataNodeSchemaCache getInstance() {
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCacheMetrics.java b/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCacheMetrics.java
index 6af1216dd5..76661c4801 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCacheMetrics.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCacheMetrics.java
@@ -38,12 +38,23 @@ public class DataNodeSchemaCacheMetrics implements IMetricSet {
@Override
public void bindTo(AbstractMetricService metricService) {
metricService.createAutoGauge(
- Metric.CACHE_HIT.toString(),
+ Metric.CACHE.toString(),
MetricLevel.IMPORTANT,
dataNodeSchemaCache,
- o -> (long) o.getHitRate(),
+ DataNodeSchemaCache::getHitCount,
Tag.NAME.toString(),
- "schemaCache");
+ "SchemaCache",
+ Tag.TYPE.toString(),
+ "hit");
+ metricService.createAutoGauge(
+ Metric.CACHE.toString(),
+ MetricLevel.IMPORTANT,
+ dataNodeSchemaCache,
+ DataNodeSchemaCache::getRequestCount,
+ Tag.NAME.toString(),
+ "SchemaCache",
+ Tag.TYPE.toString(),
+ "all");
}
@Override