[fix](cloud) modify CloudTabletRebalancer and CloudTabletStatMgr to reduce memory - #61318
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors how cloud table statistics are prepared for Prometheus output by moving aggregation/filtering responsibilities from the Prometheus visitor into CloudTabletStatMgr, and includes a small cleanup in the cloud tablet rebalancer.
Changes:
- Move “top-N by data size” filtering for per-table metrics from
PrometheusMetricVisitorintoCloudTabletStatMgr. - Add
totalTableSizetracking + getter inCloudTabletStatMgrso Prometheus can emit a total even when per-table stats are filtered. - Simplify
CloudTabletRebalancerinflight tracking by switchingtabletIdto primitivelongand removing an unused task field/parameter.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
fe/fe-core/src/main/java/org/apache/doris/metric/PrometheusMetricVisitor.java |
Uses CloudTabletStatMgr’s pre-filtered table stats and new total size getter instead of computing/filtering locally. |
fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTabletRebalancer.java |
Removes unnecessary boxing for tabletId and drops an unused beToTablets field/arg from inflight task handling. |
fe/fe-core/src/main/java/org/apache/doris/catalog/CloudTabletStatMgr.java |
Adds total table size state and implements top-N filtering during stats update to support Prometheus output efficiently. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| filterTopTableStatsByDataSize(newCloudTableStatsList); | ||
| this.totalTableSize = totalTableSize; |
8f18a44 to
98d541e
Compare
|
/review |
There was a problem hiding this comment.
Code Review Summary
PR Goal: Reduce FE memory by (1) moving top-N table stats filtering from PrometheusMetricVisitor into CloudTabletStatMgr so it's computed once per stat cycle instead of per Prometheus scrape, (2) removing the unused beToTablets field from InfightTask to avoid retaining a large map reference, and (3) changing InfightTablet.tabletId from Long to long to avoid boxing overhead.
Critical Checkpoint Conclusions
-
Does the code accomplish its goal? Is there a test that proves it? The code accomplishes the goal. The filtering logic is correctly moved,
beToTabletsis confirmed unused and safely removed, and theLong-to-longchange is correct (includingequals/hashCodeadjustments). However, no tests are added or referenced -- none of the test checkboxes in the PR template are checked. -
Is the modification minimal and focused? Yes -- three small, related memory-reduction changes across three files.
-
Concurrency? Both
totalTableSizeandcloudTableStatsListarevolatileand written by a single daemon thread. The reference-swap pattern is safe. Minor note: a Prometheus scrape can observe the new filtered list with the oldtotalTableSize(or vice versa), but this is benign staleness. -
Lifecycle / static init? No issues.
-
Configuration items? No new configs. Uses existing
prom_output_table_metrics_limit. -
Incompatible changes? None.
-
Parallel code paths? The filtering was in
PrometheusMetricVisitorand is now inCloudTabletStatMgr. The move is complete -- old code is fully removed. -
Special conditional checks? See inline comment about
PriorityQueuewithlimit <= 0. -
Test coverage? No tests added. A unit test for
filterTopTableStatsByDataSizewith various edge cases (empty list, list smaller than limit, list larger than limit, limit=0) would be valuable. -
Observability? No regression -- same Prometheus metrics are output.
-
Performance? Good improvements: avoids
Longboxing, drops unnecessaryMapreference from in-flight tasks, and pre-filters the stats list once per cycle instead of per scrape. -
Other issues? One edge-case bug found -- see inline comment.
98d541e to
6b6dbfa
Compare
|
run buildall |
TPC-H: Total hot run time: 27302 ms |
TPC-DS: Total hot run time: 167620 ms |
FE UT Coverage ReportIncrement line coverage |
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
…educe memory (apache#61318) Issue Number: close #xxx Related PR: #xxx Problem Summary: Reduce FE memory by 1. moving top-N table stats filtering from PrometheusMetricVisitor into CloudTabletStatMgr so it's computed once per stat cycle instead of per Prometheus scrape, 2. removing the unused beToTablets field from InfightTask to avoid retaining a large map reference 3. changing InfightTablet.tabletId from Long to long to avoid boxing overhead. None - Test <!-- At least one of them must be included. --> - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [ ] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [ ] No. - [ ] Yes. <!-- Add document PR link here. eg: apache/doris-website#1214 --> - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
…educe memory (apache#61318) Issue Number: close #xxx Related PR: #xxx Problem Summary: Reduce FE memory by 1. moving top-N table stats filtering from PrometheusMetricVisitor into CloudTabletStatMgr so it's computed once per stat cycle instead of per Prometheus scrape, 2. removing the unused beToTablets field from InfightTask to avoid retaining a large map reference 3. changing InfightTablet.tabletId from Long to long to avoid boxing overhead. None - Test <!-- At least one of them must be included. --> - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [ ] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [ ] No. - [ ] Yes. <!-- Add document PR link here. eg: apache/doris-website#1214 --> - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
### What problem does this PR solve? Issue Number: None Related PR: apache#61318 Problem Summary: Cloud tablet route rebuilding repeatedly boxes primitive backend, table, partition, index, and tablet IDs while inserting the same logical IDs into current and future global, table, and partition indexes. Hoist boxing to traversal callers and preserve selected boxed tablet IDs through direct transfers, warmup moves, and warmup rollbacks so all route index families reuse immutable Long references without changing routing or scheduling semantics. A single-threaded JDK 17 allocation model that keeps eager container candidates in both variants estimates that 4 million tablets across 4 clusters reduce cumulative allocation from 25.47 GiB to 19.76 GiB (22.42%) and approximate post-full-GC retained heap from 6.80 GiB to 4.94 GiB (27.37%). For IDs outside the Long cache, each direct incremental move additionally avoids two tablet wrapper allocations and one duplicate retained tablet wrapper; warmup and rollback each avoid one tablet wrapper allocation. These are path-level model and identity-test results, not production RSS measurements. ### Release note None ### Check List (For Author) - Test: Unit Test and Manual test\n - ./run-fe-ut.sh --run org.apache.doris.cloud.catalog.CloudTabletRebalancerTest (13 tests passed)\n - mvn checkstyle:check -pl fe-core (0 violations)\n - Multi-scale JDK 17 eager-container allocation model at 0.2M, 0.4M, 0.8M, and 3.2M tablet-cluster pairs, three runs per scale\n- Behavior changed: No\n- Does this need documentation: No
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
Reduce FE memory by
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)