You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/08/23 04:28:00 UTC

[GitHub] [iotdb] qiaojialin commented on a change in pull request #3806: [To rel/0.12] [ISSUE-3805] OOM caused by Chunk cache

qiaojialin commented on a change in pull request #3806:
URL: https://github.com/apache/iotdb/pull/3806#discussion_r693643978



##########
File path: server/src/main/java/org/apache/iotdb/db/engine/cache/ChunkCache.java
##########
@@ -63,50 +62,28 @@ private ChunkCache() {
         Caffeine.newBuilder()
             .maximumWeight(MEMORY_THRESHOLD_IN_CHUNK_CACHE)
             .weigher(
-                new Weigher<ChunkMetadata, Chunk>() {
-
-                  int count = 0;
-                  int averageSize = 0;
-
-                  @Override
-                  public int weigh(ChunkMetadata chunkMetadata, Chunk chunk) {
-                    int currentSize;
-                    if (count < 10) {
-                      currentSize =
-                          (int)
-                              (RamUsageEstimator.NUM_BYTES_OBJECT_REF
-                                  + RamUsageEstimator.sizeOf(chunk));
-                      averageSize = ((averageSize * count) + currentSize) / (++count);
-                      entryAverageSize.set(averageSize);
-                    } else if (count < 100000) {
-                      count++;
-                      currentSize = averageSize;
-                    } else {
-                      averageSize =
+                (Weigher<ChunkMetadata, Chunk>)
+                    (chunkMetadata, chunk) -> {
+                      int entrySize =
                           (int)
                               (RamUsageEstimator.NUM_BYTES_OBJECT_REF
                                   + RamUsageEstimator.sizeOf(chunk));
-                      count = 1;
-                      currentSize = averageSize;
-                      entryAverageSize.set(averageSize);
-                    }
-                    return currentSize;
-                  }
-                })
+                      if (entrySize > 1024 * 1024 * 10) {
+                        logger.warn(String.format("Chunk size is %d over 10M", entrySize));
+                      }

Review comment:
       ```suggestion
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org