branch-4.0: pick #59776, #61318 - #61930
Conversation
…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 -->
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
There was a problem hiding this comment.
Pull request overview
Backport to branch-4.0 of two upstream fixes aimed at reducing FE memory overhead in cloud-mode tablet/table statistics and rebalancing, primarily by avoiding per-scrape recomputation and unnecessary object/collection retention.
Changes:
- Move Prometheus “top-N table stats” filtering and total table size computation into
CloudTabletStatMgr(computed once per stat cycle, reused across scrapes). - Reduce object/collection overhead in cloud rebalancing inflight tracking (remove unused
beToTabletsreference, avoidLongboxing for tablet ids). - Replace several boxed
Longstatistic fields/counters with primitivelongto reduce boxing/memory overhead.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
fe/fe-core/src/main/java/org/apache/doris/metric/PrometheusMetricVisitor.java |
Switch Prometheus table-stats output to consume pre-filtered stats + precomputed totals from CloudTabletStatMgr. |
fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTabletRebalancer.java |
Remove unused inflight task map reference; change inflight tablet id to primitive long. |
fe/fe-core/src/main/java/org/apache/doris/catalog/TabletStatMgr.java |
Use primitive long for local aggregation counters to reduce boxing. |
fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java |
Convert OlapTable.Statistics numeric fields/ctor params to primitive long. |
fe/fe-core/src/main/java/org/apache/doris/catalog/CloudTabletStatMgr.java |
Store only top-N table stats for Prometheus, expose total table size, and avoid building/storing a full per-table stats map. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| List<OlapTable.Statistics> newCloudTableStatsList = new ArrayList<>(); | ||
| for (Long dbId : dbIds) { |
There was a problem hiding this comment.
updateStatInfo() collects statistics for all tables into newCloudTableStatsList and only filters to the top-N at the end. If the number of tables is very large, this can still create a large temporary list/array each stat cycle. Consider maintaining the top-N PriorityQueue incrementally during the scan so you never retain references for every table at once.
| public List<OlapTable.Statistics> getCloudTableStats() { | ||
| return this.cloudTableStatsList; | ||
| } |
There was a problem hiding this comment.
getCloudTableStats() returns the internal mutable List instance. To prevent accidental external mutation (and potential ConcurrentModificationException during iteration), consider returning an unmodifiable view or a defensive copy, and/or storing an immutable list in the field.
|
run buildall |
pick: