Caideyipi commented on code in PR #15534:
URL: https://github.com/apache/iotdb/pull/15534#discussion_r2102018013
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryManager.java:
##########
@@ -100,6 +101,18 @@ private double allowedMaxMemorySizeInBytesOfTsTiles() {
* getTotalNonFloatingMemorySizeInBytes();
}
+ public long getAllocatedMemorySizeInBytesOfWAL() {
+ return (long)
+ (PipeConfig.getInstance().getPipeDataStructureWalMemoryProportion()
+ * getTotalNonFloatingMemorySizeInBytes());
+ }
+
+ public long getAllocatedMemorySizeInBytesOfBatch() {
+ return (long)
+ (PipeConfig.getInstance().getPipeDataStructureBatchMemoryProportion()
Review Comment:
Better use "PIPE_CONFIG" directly
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeDynamicMemoryBlock.java:
##########
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.pipe.resource.memory;
+
+import org.apache.tsfile.utils.Pair;
+
+import javax.validation.constraints.NotNull;
+
+import java.util.function.Consumer;
+import java.util.stream.Stream;
+
+public class PipeDynamicMemoryBlock {
+
+ private final PipeModelFixedMemoryBlock fixedMemoryBlock;
+
+ private boolean isExpandable = true;
+
+ private Consumer<PipeDynamicMemoryBlock> expand = null;
+
+ private volatile boolean released = false;
+
+ private volatile long memoryUsageInBytes;
+
+ private volatile double historyMemoryEfficiency;
+
+ private volatile double currentMemoryEfficiency;
+
+ PipeDynamicMemoryBlock(
+ final @NotNull PipeModelFixedMemoryBlock fixedMemoryBlock, final long
memoryUsageInBytes) {
+ this.memoryUsageInBytes = Math.min(memoryUsageInBytes, 0);
+ this.fixedMemoryBlock = fixedMemoryBlock;
+ }
+
+ public long getMemoryUsageInBytes() {
+ return memoryUsageInBytes;
+ }
+
+ public void setMemoryUsageInBytes(final long memoryUsageInBytes) {
+ this.memoryUsageInBytes = memoryUsageInBytes;
+ }
+
+ public Pair<Double, Double> getMemoryEfficiency() {
+ synchronized (fixedMemoryBlock) {
+ return new Pair<>(historyMemoryEfficiency, currentMemoryEfficiency);
+ }
+ }
+
+ public void setExpandable(boolean expandable) {
+ isExpandable = expandable;
+ }
+
+ public void setExpand(Consumer<PipeDynamicMemoryBlock> expand) {
+ this.expand = expand;
+ }
+
+ public double getMemoryBlockUsageRatio() {
+ return (double) memoryUsageInBytes /
fixedMemoryBlock.getMemoryAllocatedInBytes();
+ }
+
+ public double getFixedMemoryBlockUsageRatio() {
+ return (double) fixedMemoryBlock.getMemoryUsageInBytes()
+ / fixedMemoryBlock.getMemoryAllocatedInBytes();
Review Comment:
Seemingly in the contrary?
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryManager.java:
##########
@@ -100,6 +101,18 @@ private double allowedMaxMemorySizeInBytesOfTsTiles() {
* getTotalNonFloatingMemorySizeInBytes();
}
+ public long getAllocatedMemorySizeInBytesOfWAL() {
+ return (long)
+ (PipeConfig.getInstance().getPipeDataStructureWalMemoryProportion()
Review Comment:
Better use "PIPE_CONFIG" directly
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeDynamicMemoryBlock.java:
##########
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.pipe.resource.memory;
+
+import org.apache.tsfile.utils.Pair;
+
+import javax.validation.constraints.NotNull;
+
+import java.util.function.Consumer;
+import java.util.stream.Stream;
+
+public class PipeDynamicMemoryBlock {
+
+ private final PipeModelFixedMemoryBlock fixedMemoryBlock;
+
+ private boolean isExpandable = true;
+
+ private Consumer<PipeDynamicMemoryBlock> expand = null;
+
+ private volatile boolean released = false;
+
+ private volatile long memoryUsageInBytes;
+
+ private volatile double historyMemoryEfficiency;
+
+ private volatile double currentMemoryEfficiency;
+
+ PipeDynamicMemoryBlock(
+ final @NotNull PipeModelFixedMemoryBlock fixedMemoryBlock, final long
memoryUsageInBytes) {
+ this.memoryUsageInBytes = Math.min(memoryUsageInBytes, 0);
+ this.fixedMemoryBlock = fixedMemoryBlock;
+ }
+
+ public long getMemoryUsageInBytes() {
+ return memoryUsageInBytes;
+ }
+
+ public void setMemoryUsageInBytes(final long memoryUsageInBytes) {
+ this.memoryUsageInBytes = memoryUsageInBytes;
+ }
+
+ public Pair<Double, Double> getMemoryEfficiency() {
+ synchronized (fixedMemoryBlock) {
+ return new Pair<>(historyMemoryEfficiency, currentMemoryEfficiency);
+ }
+ }
+
+ public void setExpandable(boolean expandable) {
+ isExpandable = expandable;
+ }
+
+ public void setExpand(Consumer<PipeDynamicMemoryBlock> expand) {
+ this.expand = expand;
+ }
+
+ public double getMemoryBlockUsageRatio() {
+ return (double) memoryUsageInBytes /
fixedMemoryBlock.getMemoryAllocatedInBytes();
+ }
+
+ public double getFixedMemoryBlockUsageRatio() {
+ return (double) fixedMemoryBlock.getMemoryUsageInBytes()
+ / fixedMemoryBlock.getMemoryAllocatedInBytes();
+ }
+
+ public long canAllocateMemorySize() {
+ return fixedMemoryBlock.getMemoryAllocatedInBytes() -
fixedMemoryBlock.getMemoryUsageInBytes();
Review Comment:
Seemingly in the contrary?
--
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]