shuwenwei commented on code in PR #15257:
URL: https://github.com/apache/iotdb/pull/15257#discussion_r2050488580
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/selector/estimator/AbstractCompactionEstimator.java:
##########
@@ -54,14 +58,42 @@
*/
public abstract class AbstractCompactionEstimator {
- private static final Map<File, FileInfo>
globalFileInfoCacheForFailedCompaction =
- Collections.synchronizedMap(
- new LRUMap<>(
-
IoTDBDescriptor.getInstance().getConfig().getGlobalCompactionFileInfoCacheSize()));
+ /** The size of global compaction estimation file info cahce. */
+ private static int globalCompactionFileInfoCacheSize = 1000;
+
+ /** The size of global compaction estimation rough file info cahce. */
+ private static int globalCompactionRoughFileInfoCacheSize = 100000;
+
+ private static final double maxRatioToAllocateFileInfoCache = 0.1;
+ private static boolean isCacheMemoryCostAllocated;
+ private static Map<TsFileID, FileInfo>
globalFileInfoCacheForFailedCompaction;
+ private static Map<TsFileID, FileInfo.RoughFileInfo>
globalRoughInfoCacheForCompaction;
+
+ protected IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+
+ public static long allocateMemoryCostForFileInfoCache(long
compactionMemorySize) {
+ long fixedMemoryCost =
+ globalCompactionFileInfoCacheSize *
FileInfo.MEMORY_COST_OF_FILE_INFO_ENTRY_IN_CACHE
+ + globalCompactionRoughFileInfoCacheSize
+ * FileInfo.MEMORY_COST_OF_ROUGH_FILE_INFO_ENTRY_IN_CACHE;
+ isCacheMemoryCostAllocated =
+ compactionMemorySize * maxRatioToAllocateFileInfoCache >
fixedMemoryCost;
Review Comment:
It is possible, but we still need to calculate the max size because we don't
want it too large or too small.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]