Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing a memory control mechanism during the query planning stage #12573

Merged
merged 8 commits into from
May 24, 2024

Conversation

lancelly
Copy link
Contributor

@lancelly lancelly commented May 22, 2024

This PR mainly introduces a memory control mechanism during the query planning stage. Currently, the IoTDB query engine does not implement memory control at the FE (Frontend) stage. In scenarios with massive series queries (e.g., select * from root.**), the query plans generated at the FE stage can become excessively large. Roughly estimating, the size of a single SeriesScanNode is about 1/2 KB, which means that two million series corresponding to two million SeriesScanNodes would occupy 1 GB, posing a potential risk of Out-Of-Memory (OOM). In high concurrency scenarios, even if a single query plan is not large, the total memory occupied by multiple query plans can still lead to OOM.
Therefore, it is now desired to introduce memory size control for FE query plans within the query engine.
Related docs:https://apache-iotdb.feishu.cn/docx/F7nidsysKofhO4xTi35cuDhynCh

Copy link

codecov bot commented May 22, 2024

Codecov Report

Attention: Patch coverage is 74.92795% with 87 lines in your changes are missing coverage. Please review.

Project coverage is 43.37%. Comparing base (44ed961) to head (fdb3f1b).
Report is 32 commits behind head on master.

Files Patch % Lines
...e/iotdb/db/queryengine/common/MPPQueryContext.java 38.46% 16 Missing ⚠️
...ueryengine/plan/planner/LocalExecutionPlanner.java 0.00% 10 Missing ⚠️
.../plan/expression/other/CaseWhenThenExpression.java 22.22% 7 Missing ⚠️
...db/db/queryengine/plan/analyze/AnalyzeVisitor.java 87.50% 4 Missing ⚠️
.../db/queryengine/plan/analyze/TemplatedAnalyze.java 0.00% 4 Missing ⚠️
...ine/plan/expression/ternary/BetweenExpression.java 33.33% 4 Missing ⚠️
...b/queryengine/plan/planner/LogicalPlanBuilder.java 77.77% 4 Missing ⚠️
...b/db/queryengine/plan/analyze/ExpressionUtils.java 82.35% 3 Missing ⚠️
...gine/plan/expression/multi/FunctionExpression.java 84.21% 3 Missing ⚠️
...ueryengine/plan/expression/unary/InExpression.java 40.00% 3 Missing ⚠️
... and 15 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #12573      +/-   ##
============================================
- Coverage     43.50%   43.37%   -0.14%     
  Complexity       69       69              
============================================
  Files          3125     3164      +39     
  Lines        194301   196674    +2373     
  Branches      23168    23425     +257     
============================================
+ Hits          84536    85308     +772     
- Misses       109765   111366    +1601     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@JackieTien97 JackieTien97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think about the query retry logic and the last remaining memory(less than 1MB), you can reserve that before dispatch.

Comment on lines 323 to 324
LOCAL_EXECUTION_PLANNER.releaseToFreeMemoryForOperators(reservedBytesInTotalForFrontEnd);
reservedBytesInTotalForFrontEnd = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOCAL_EXECUTION_PLANNER.releaseToFreeMemoryForOperators(reservedBytesInTotalForFrontEnd);
reservedBytesInTotalForFrontEnd = 0;
if (reservedBytesInTotalForFrontEnd != 0) {
LOCAL_EXECUTION_PLANNER.releaseToFreeMemoryForOperators(reservedBytesInTotalForFrontEnd);
reservedBytesInTotalForFrontEnd = 0;
}

lancelly added 5 commits May 23, 2024 15:09
…re retry of QueryExectuion & reserverMemoryImmediately after dispatching the FIs for the last batch of memory occupied by the FE.
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@JackieTien97 JackieTien97 merged commit 462c900 into master May 24, 2024
55 of 59 checks passed
@JackieTien97 JackieTien97 deleted the fe_memory_control branch May 24, 2024 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants