Re: [PR] [Load] Isolate reused TsFile parser memory from Pipe pool [iotdb]
jt2594838 merged PR #18419: URL: https://github.com/apache/iotdb/pull/18419 -- 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]
Re: [PR] [Load] Isolate reused TsFile parser memory from Pipe pool [iotdb]
Caideyipi commented on code in PR #18419:
URL: https://github.com/apache/iotdb/pull/18419#discussion_r3734758363
##
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileParserMemoryManager.java:
##
@@ -0,0 +1,120 @@
+/*
+ * 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.storageengine.load.memory;
+
+import org.apache.iotdb.db.i18n.StorageEngineMessages;
+import
org.apache.iotdb.db.pipe.event.common.tsfile.parser.TsFileInsertionEventParserMemoryBlock;
+import
org.apache.iotdb.db.pipe.event.common.tsfile.parser.TsFileInsertionEventParserMemoryManager;
+
+/**
+ * Allocates the working memory of TsFile parsers reused by Load from the
query engine memory pool.
+ */
+public class LoadTsFileParserMemoryManager implements
TsFileInsertionEventParserMemoryManager {
+
+ private static final LoadTsFileMemoryManager LOAD_MEMORY_MANAGER =
+ LoadTsFileMemoryManager.getInstance();
+
+ private LoadTsFileParserMemoryManager() {}
+
+ public static LoadTsFileParserMemoryManager getInstance() {
+return LoadTsFileParserMemoryManagerHolder.INSTANCE;
+ }
+
+ @Override
+ public TsFileInsertionEventParserMemoryBlock forceAllocateForTabletWithRetry(
+ final long sizeInBytes) {
+return new LoadParserMemoryBlock(sizeInBytes);
+ }
+
+ @Override
+ public TsFileInsertionEventParserMemoryBlock forceAllocate(final long
sizeInBytes) {
+return new LoadParserMemoryBlock(sizeInBytes);
+ }
+
+ private static class LoadParserMemoryBlock implements
TsFileInsertionEventParserMemoryBlock {
+
+private LoadTsFileMemoryBlock delegate;
+private long memoryUsageInBytes;
+private boolean isClosed;
+
+private LoadParserMemoryBlock(final long sizeInBytes) {
+ checkNonNegative(sizeInBytes);
+ if (sizeInBytes > 0) {
+delegate = LOAD_MEMORY_MANAGER.allocateMemoryBlock(sizeInBytes);
+ }
+ memoryUsageInBytes = sizeInBytes;
+}
+
+@Override
+public synchronized long getMemoryUsageInBytes() {
+ return memoryUsageInBytes;
+}
+
+@Override
+public synchronized void forceResize(final long newSizeInBytes) {
+ checkNonNegative(newSizeInBytes);
+ if (isClosed || memoryUsageInBytes == newSizeInBytes) {
+return;
+ }
+
+ resizeDelegate(newSizeInBytes);
+ memoryUsageInBytes = newSizeInBytes;
+}
+
+private void resizeDelegate(final long newSizeInBytes) {
+ if (newSizeInBytes == 0) {
+delegate.close();
+delegate = null;
Review Comment:
Thanks for checking. The first resize to 0 closes the delegate and sets the
tracked usage to 0; a second resize to 0 returns before dereferencing the null
delegate because the usage is unchanged. I added a regression assertion for the
repeated zero-size resize in 277e61e1ac3.
--
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]
Re: [PR] [Load] Isolate reused TsFile parser memory from Pipe pool [iotdb]
sonarqubecloud[bot] commented on PR #18419: URL: https://github.com/apache/iotdb/pull/18419#issuecomment-5215223031 ## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=18419) **Quality Gate passed** Issues  [29 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=18419&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=18419&issueStatuses=ACCEPTED) Measures  [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=18419&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=18419&metric=new_coverage&view=list)  [1.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=18419&metric=new_duplicated_lines_density&view=list) [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=18419) -- 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]
Re: [PR] [Load] Isolate reused TsFile parser memory from Pipe pool [iotdb]
jt2594838 commented on code in PR #18419:
URL: https://github.com/apache/iotdb/pull/18419#discussion_r3734208137
##
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/memory/LoadTsFileParserMemoryManager.java:
##
@@ -0,0 +1,120 @@
+/*
+ * 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.storageengine.load.memory;
+
+import org.apache.iotdb.db.i18n.StorageEngineMessages;
+import
org.apache.iotdb.db.pipe.event.common.tsfile.parser.TsFileInsertionEventParserMemoryBlock;
+import
org.apache.iotdb.db.pipe.event.common.tsfile.parser.TsFileInsertionEventParserMemoryManager;
+
+/**
+ * Allocates the working memory of TsFile parsers reused by Load from the
query engine memory pool.
+ */
+public class LoadTsFileParserMemoryManager implements
TsFileInsertionEventParserMemoryManager {
+
+ private static final LoadTsFileMemoryManager LOAD_MEMORY_MANAGER =
+ LoadTsFileMemoryManager.getInstance();
+
+ private LoadTsFileParserMemoryManager() {}
+
+ public static LoadTsFileParserMemoryManager getInstance() {
+return LoadTsFileParserMemoryManagerHolder.INSTANCE;
+ }
+
+ @Override
+ public TsFileInsertionEventParserMemoryBlock forceAllocateForTabletWithRetry(
+ final long sizeInBytes) {
+return new LoadParserMemoryBlock(sizeInBytes);
+ }
+
+ @Override
+ public TsFileInsertionEventParserMemoryBlock forceAllocate(final long
sizeInBytes) {
+return new LoadParserMemoryBlock(sizeInBytes);
+ }
+
+ private static class LoadParserMemoryBlock implements
TsFileInsertionEventParserMemoryBlock {
+
+private LoadTsFileMemoryBlock delegate;
+private long memoryUsageInBytes;
+private boolean isClosed;
+
+private LoadParserMemoryBlock(final long sizeInBytes) {
+ checkNonNegative(sizeInBytes);
+ if (sizeInBytes > 0) {
+delegate = LOAD_MEMORY_MANAGER.allocateMemoryBlock(sizeInBytes);
+ }
+ memoryUsageInBytes = sizeInBytes;
+}
+
+@Override
+public synchronized long getMemoryUsageInBytes() {
+ return memoryUsageInBytes;
+}
+
+@Override
+public synchronized void forceResize(final long newSizeInBytes) {
+ checkNonNegative(newSizeInBytes);
+ if (isClosed || memoryUsageInBytes == newSizeInBytes) {
+return;
+ }
+
+ resizeDelegate(newSizeInBytes);
+ memoryUsageInBytes = newSizeInBytes;
+}
+
+private void resizeDelegate(final long newSizeInBytes) {
+ if (newSizeInBytes == 0) {
+delegate.close();
+delegate = null;
Review Comment:
If resized twice with size 0, will an NPE be triggered?
--
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]
Re: [PR] [Load] Isolate reused TsFile parser memory from Pipe pool [iotdb]
codecov[bot] commented on PR #18419: URL: https://github.com/apache/iotdb/pull/18419#issuecomment-521655 ## [Codecov](https://app.codecov.io/gh/apache/iotdb/pull/18419?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report :x: Patch coverage is `83.48624%` with `18 lines` in your changes missing coverage. Please review. :white_check_mark: Project coverage is 43.62%. Comparing base ([`7e2c453`](https://app.codecov.io/gh/apache/iotdb/commit/7e2c453fbd1880e977c4da50395881a36edc1898?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`a35e8a4`](https://app.codecov.io/gh/apache/iotdb/commit/a35e8a42a6e324fad9111a327cf4bda52655eec6?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)). | [Files with missing lines](https://app.codecov.io/gh/apache/iotdb/pull/18419?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines | |---|---|---| | [...ine/load/memory/LoadTsFileParserMemoryManager.java](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&filepath=iotdb-core%2Fdatanode%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fdb%2Fstorageengine%2Fload%2Fmemory%2FLoadTsFileParserMemoryManager.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY29yZS9kYXRhbm9kZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvZGIvc3RvcmFnZWVuZ2luZS9sb2FkL21lbW9yeS9Mb2FkVHNGaWxlUGFyc2VyTWVtb3J5TWFuYWdlci5qYXZh) | 89.74% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | | [...mmon/tsfile/parser/TsFileInsertionEventParser.java](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&filepath=iotdb-core%2Fdatanode%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fdb%2Fpipe%2Fevent%2Fcommon%2Ftsfile%2Fparser%2FTsFileInsertionEventParser.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY29yZS9kYXRhbm9kZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvZGIvcGlwZS9ldmVudC9jb21tb24vdHNmaWxlL3BhcnNlci9Uc0ZpbGVJbnNlcnRpb25FdmVudFBhcnNlci5qYXZh) | 57.14% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | | [.../parser/query/TsFileInsertionEventQueryParser.java](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&filepath=iotdb-core%2Fdatanode%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fdb%2Fpipe%2Fevent%2Fcommon%2Ftsfile%2Fparser%2Fquery%2FTsFileInsertionEventQueryParser.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY29yZS9kYXRhbm9kZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvZGIvcGlwZS9ldmVudC9jb21tb24vdHNmaWxlL3BhcnNlci9xdWVyeS9Uc0ZpbGVJbnNlcnRpb25FdmVudFF1ZXJ5UGFyc2VyLmphdmE=) | 62.50% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | | [.../parser/table/TsFileInsertionEventTableParser.java](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&filepath=iotdb-core%2Fdatanode%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fdb%2Fpipe%2Fevent%2Fcommon%2Ftsfile%2Fparser%2Ftable%2FTsFileInsertionEventTableParser.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY29yZS9kYXRhbm9kZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvZGIvcGlwZS9ldmVudC9jb21tb24vdHNmaWxlL3BhcnNlci90YWJsZS9Uc0ZpbGVJbnNlcnRpb25FdmVudFRhYmxlUGFyc2VyLmphdmE=) | 72.72% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | | [...e/load/converter/LoadTreeTsFileTabletIterator.java](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&filepath=iotdb-core%2Fdatanode%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fiotdb%2Fdb%2Fstorageengine%2Fload%2Fconverter%2FLoadTreeTsFileTabletIterator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aW90ZGItY29yZS9kYXRhbm9kZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaW90ZGIvZGIvc3RvcmFnZWVuZ2luZS9sb2FkL2NvbnZlcnRlci9Mb2FkVHJlZVRzRmlsZVRhYmxldEl0ZXJhdG9yLmphdmE=) | 50.00% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/iotdb/pull/18419?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
Re: [PR] [Load] Isolate reused TsFile parser memory from Pipe pool [iotdb]
sonarqubecloud[bot] commented on PR #18419: URL: https://github.com/apache/iotdb/pull/18419#issuecomment-5211828408 ## [](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=18419) **Quality Gate passed** Issues  [29 New issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=18419&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_iotdb&pullRequest=18419&issueStatuses=ACCEPTED) Measures  [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_iotdb&pullRequest=18419&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=18419&metric=new_coverage&view=list)  [1.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=18419&metric=new_duplicated_lines_density&view=list) [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=18419) -- 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]
