You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2021/08/20 04:45:47 UTC

[iotdb] branch fix_tsm_cache created (now 75eb861)

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

qiaojialin pushed a change to branch fix_tsm_cache
in repository https://gitbox.apache.org/repos/asf/iotdb.git.


      at 75eb861  return current entry size directly in TimeseriesMetadataCache

This branch includes the following new commits:

     new 75eb861  return current entry size directly in TimeseriesMetadataCache

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[iotdb] 01/01: return current entry size directly in TimeseriesMetadataCache

Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch fix_tsm_cache
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 75eb861db68bb65d795646a6264376f043b4a661
Author: qiaojialin <64...@qq.com>
AuthorDate: Fri Aug 20 12:45:09 2021 +0800

    return current entry size directly in TimeseriesMetadataCache
---
 .../db/engine/cache/TimeSeriesMetadataCache.java   | 54 +++++-----------------
 1 file changed, 12 insertions(+), 42 deletions(-)

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 4fd205c..fa14776 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
@@ -80,50 +80,20 @@ public class TimeSeriesMetadataCache {
             .weigher(
                 new Weigher<TimeSeriesMetadataCacheKey, TimeseriesMetadata>() {
 
-                  int count = 0;
-                  int averageSize = 0;
-
                   @Override
                   public int weigh(TimeSeriesMetadataCacheKey key, TimeseriesMetadata value) {
-                    int currentSize;
-                    if (count < 10) {
-                      currentSize =
-                          (int)
-                              (RamUsageEstimator.shallowSizeOf(key)
-                                  + RamUsageEstimator.sizeOf(key.device)
-                                  + RamUsageEstimator.sizeOf(key.measurement)
-                                  + RamUsageEstimator.shallowSizeOf(value)
-                                  + RamUsageEstimator.sizeOf(value.getMeasurementId())
-                                  + RamUsageEstimator.shallowSizeOf(value.getStatistics())
-                                  + (((ChunkMetadata) value.getChunkMetadataList().get(0))
-                                              .calculateRamSize()
-                                          + RamUsageEstimator.NUM_BYTES_OBJECT_REF)
-                                      * value.getChunkMetadataList().size()
-                                  + RamUsageEstimator.shallowSizeOf(value.getChunkMetadataList()));
-                      averageSize = ((averageSize * count) + currentSize) / (++count);
-                      entryAverageSize.set(averageSize);
-                    } else if (count < 100000) {
-                      count++;
-                      currentSize = averageSize;
-                    } else {
-                      averageSize =
-                          (int)
-                              (RamUsageEstimator.shallowSizeOf(key)
-                                  + RamUsageEstimator.sizeOf(key.device)
-                                  + RamUsageEstimator.sizeOf(key.measurement)
-                                  + RamUsageEstimator.shallowSizeOf(value)
-                                  + RamUsageEstimator.sizeOf(value.getMeasurementId())
-                                  + RamUsageEstimator.shallowSizeOf(value.getStatistics())
-                                  + (((ChunkMetadata) value.getChunkMetadataList().get(0))
-                                              .calculateRamSize()
-                                          + RamUsageEstimator.NUM_BYTES_OBJECT_REF)
-                                      * value.getChunkMetadataList().size()
-                                  + RamUsageEstimator.shallowSizeOf(value.getChunkMetadataList()));
-                      count = 1;
-                      currentSize = averageSize;
-                      entryAverageSize.set(averageSize);
-                    }
-                    return currentSize;
+                    return (int)
+                        (RamUsageEstimator.shallowSizeOf(key)
+                            + RamUsageEstimator.sizeOf(key.device)
+                            + RamUsageEstimator.sizeOf(key.measurement)
+                            + RamUsageEstimator.shallowSizeOf(value)
+                            + RamUsageEstimator.sizeOf(value.getMeasurementId())
+                            + RamUsageEstimator.shallowSizeOf(value.getStatistics())
+                            + (((ChunkMetadata) value.getChunkMetadataList().get(0))
+                                        .calculateRamSize()
+                                    + RamUsageEstimator.NUM_BYTES_OBJECT_REF)
+                                * value.getChunkMetadataList().size()
+                            + RamUsageEstimator.shallowSizeOf(value.getChunkMetadataList()));
                   }
                 })
             .recordStats()