jt2594838 commented on code in PR #14710:
URL: https://github.com/apache/iotdb/pull/14710#discussion_r1974833423
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java:
##########
@@ -2358,50 +2402,140 @@ private void initSchemaMemoryAllocate(TrimProperties
properties) {
}
if (loadedProportionSum != 0) {
- conf.setSchemaMemoryProportion(
- new int[] {
- Integer.parseInt(proportions[0].trim()),
- Integer.parseInt(proportions[1].trim()),
- Integer.parseInt(proportions[2].trim())
- });
+ for (int i = 0; i < schemaMemoryProportion.length; i++) {
+ schemaMemoryProportion[i] = Integer.parseInt(proportions[i].trim());
+ }
}
+ }
- } else {
- schemaMemoryPortionInput =
properties.getProperty("schema_memory_allocate_proportion");
- if (schemaMemoryPortionInput != null) {
- String[] proportions = schemaMemoryPortionInput.split(":");
- int loadedProportionSum = 0;
- for (String proportion : proportions) {
- loadedProportionSum += Integer.parseInt(proportion.trim());
- }
+ int proportionSum = 0;
+ for (int proportion : schemaMemoryProportion) {
+ proportionSum += proportion;
+ }
+
+ MemoryManager schemaRegionMemoryManager =
+ schemaEngineMemoryManager.getOrCreateMemoryManager(
+ "SchemaRegion", schemaMemoryTotal * schemaMemoryProportion[0] /
proportionSum);
+ conf.setSchemaRegionMemoryManager(schemaRegionMemoryManager);
+ LOGGER.info(
+ "allocateMemoryForSchemaRegion = {}",
+ conf.getSchemaRegionMemoryManager().getTotalMemorySizeInBytes());
+
+ MemoryManager schemaCacheMemoryManager =
+ schemaEngineMemoryManager.getOrCreateMemoryManager(
+ "SchemaCache", schemaMemoryTotal * schemaMemoryProportion[1] /
proportionSum);
+ conf.setSchemaCacheMemoryManager(schemaCacheMemoryManager);
+ LOGGER.info(
+ "allocateMemoryForSchemaCache = {}",
+ conf.getSchemaCacheMemoryManager().getTotalMemorySizeInBytes());
+
+ MemoryManager partitionCacheMemoryManager =
+ schemaEngineMemoryManager.getOrCreateMemoryManager(
+ "PartitionCache", schemaMemoryTotal * schemaMemoryProportion[2] /
proportionSum);
+ conf.setPartitionCacheMemoryManager(partitionCacheMemoryManager);
+ LOGGER.info(
+ "allocateMemoryForPartitionCache = {}",
+ conf.getPartitionCacheMemoryManager().getTotalMemorySizeInBytes());
+ }
+
+ @SuppressWarnings("squid:S3518")
+ private void initQueryEngineMemoryAllocate(
+ MemoryManager queryEngineMemoryManager, TrimProperties properties) {
+ conf.setEnableQueryMemoryEstimation(
+ Boolean.parseBoolean(
+ properties.getProperty(
+ "enable_query_memory_estimation",
+ Boolean.toString(conf.isEnableQueryMemoryEstimation()))));
- if (loadedProportionSum != 0) {
- conf.setSchemaMemoryProportion(
- new int[] {
- Integer.parseInt(proportions[0].trim()),
- Integer.parseInt(proportions[1].trim()) +
Integer.parseInt(proportions[3].trim()),
- Integer.parseInt(proportions[2].trim())
- });
+ String queryMemoryAllocateProportion =
+ properties.getProperty("chunk_timeseriesmeta_free_memory_proportion");
+ long maxMemoryAvailable =
queryEngineMemoryManager.getTotalMemorySizeInBytes();
+
+ long bloomFilterCacheMemorySize = maxMemoryAvailable / 1001;
+ long chunkCacheMemorySize = maxMemoryAvailable * 100 / 1001;
+ long timeSeriesMetaDataCacheMemorySize = maxMemoryAvailable * 200 / 1001;
+ long coordinatorMemorySize = maxMemoryAvailable * 50 / 1001;
+ long operatorsMemorySize = maxMemoryAvailable * 200 / 1001;
+ long dataExchangeMemorySize = maxMemoryAvailable * 200 / 1001;
+ long timeIndexMemorySize = maxMemoryAvailable * 200 / 1001;
+ if (queryMemoryAllocateProportion != null) {
+ String[] proportions = queryMemoryAllocateProportion.split(":");
+ int proportionSum = 0;
+ for (String proportion : proportions) {
+ proportionSum += Integer.parseInt(proportion.trim());
+ }
+ if (proportionSum != 0) {
+ try {
+ bloomFilterCacheMemorySize =
+ maxMemoryAvailable * Integer.parseInt(proportions[0].trim()) /
proportionSum;
+ chunkCacheMemorySize =
+ maxMemoryAvailable * Integer.parseInt(proportions[1].trim()) /
proportionSum;
+ timeSeriesMetaDataCacheMemorySize =
+ maxMemoryAvailable * Integer.parseInt(proportions[2].trim()) /
proportionSum;
+ coordinatorMemorySize =
+ maxMemoryAvailable * Integer.parseInt(proportions[3].trim()) /
proportionSum;
+ operatorsMemorySize =
+ maxMemoryAvailable * Integer.parseInt(proportions[4].trim()) /
proportionSum;
+ dataExchangeMemorySize =
+ maxMemoryAvailable * Integer.parseInt(proportions[5].trim()) /
proportionSum;
+ timeIndexMemorySize =
+ maxMemoryAvailable * Integer.parseInt(proportions[6].trim()) /
proportionSum;
+ } catch (Exception e) {
+ throw new RuntimeException(
Review Comment:
I mean throwing an IllegaArgumentException.
--
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]