You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "sollhui (via GitHub)" <gi...@apache.org> on 2026/04/23 06:55:18 UTC
[PR] [fix](memtable) use CPU metrics delta for CPU pressure detection in adaptive flush controller [doris]
sollhui opened a new pull request, #62744:
URL: https://github.com/apache/doris/pull/62744
### What problem does this PR solve?
Related PR: https://github.com/apache/doris/issues/60617
Problem Summary:
`AdaptiveThreadPoolController::is_cpu_busy()` previously used normalized 1-minute load average as a proxy for CPU usage. This could misclassify IO wait pressure as CPU pressure and make adaptive flush thread shrinking too aggressive.
This PR changes CPU pressure detection to use deltas of the existing `doris_be_cpu` metrics from `SystemMetrics`. It aggregates the existing CPU counters, computes CPU busy ratio from consecutive samples, and treats `iowait` as idle time for this decision path.
### Release note
None
### Check List (For Author)
- 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: https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](memtable) use CPU metrics delta for CPU pressure detection in adaptive flush controller [doris]
Posted by "sollhui (via GitHub)" <gi...@apache.org>.
sollhui commented on PR #62744:
URL: https://github.com/apache/doris/pull/62744#issuecomment-4323973323
/review
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](memtable) use CPU metrics delta for CPU pressure detection in adaptive flush controller [doris]
Posted by "sollhui (via GitHub)" <gi...@apache.org>.
sollhui commented on PR #62744:
URL: https://github.com/apache/doris/pull/62744#issuecomment-4302309859
run buildall
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](memtable) use CPU metrics delta for CPU pressure detection in adaptive flush controller [doris]
Posted by "Thearas (via GitHub)" <gi...@apache.org>.
Thearas commented on PR #62744:
URL: https://github.com/apache/doris/pull/62744#issuecomment-4302309633
Thank you for your contribution to Apache Doris.
Don't know what should be done next? See [How to process your PR](https://cwiki.apache.org/confluence/display/DORIS/How+to+process+your+PR).
Please clearly describe your PR:
1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
3. What features were added. Why was this function added?
4. Which code was refactored and why was this part of the code refactored?
5. Which functions were optimized and what is the difference before and after the optimization?
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](memtable) use CPU metrics delta for CPU pressure detection in adaptive flush controller [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on code in PR #62744:
URL: https://github.com/apache/doris/pull/62744#discussion_r3144706714
##########
be/src/storage/adaptive_thread_pool_controller.cpp:
##########
@@ -277,12 +277,32 @@ bool AdaptiveThreadPoolController::is_io_busy() {
bool AdaptiveThreadPoolController::is_cpu_busy() {
if (_system_metrics == nullptr) return false;
- double load_avg = _system_metrics->get_load_average_1_min();
- int num_cpus = std::thread::hardware_concurrency();
- if (num_cpus <= 0) return false;
+ int64_t total_time = 0;
+ int64_t idle_time = 0;
+ if (!_system_metrics->get_aggregate_cpu_time(&total_time, &idle_time)) {
+ return _last_cpu_busy;
+ }
+
+ if (_last_cpu_total_time < 0) {
+ _last_cpu_total_time = total_time;
+ _last_cpu_idle_time = idle_time;
+ _last_cpu_busy = false;
+ return false;
+ }
+
+ int64_t total_time_delta = total_time - _last_cpu_total_time;
+ int64_t idle_time_delta = idle_time - _last_cpu_idle_time;
+ _last_cpu_total_time = total_time;
Review Comment:
`SystemMetrics::update()` writes the `cpu_*` counters one by one, while `get_aggregate_cpu_time()` builds this sample from 8 independent atomic loads. If the adaptive timer overlaps the metric-calculator thread, `total_time`/`idle_time` can come from a mixed old/new `/proc/stat` row. Because `_last_cpu_total_time` / `_last_cpu_idle_time` are stored before the delta is validated, one torn read can also poison the next interval. For example, a previous baseline of `1000/800`, a real next sample of `1270/820`, and a torn read of `1250/800` make the following full sample look like `20/20` (0% busy) instead of `270/20` (>90% busy). This path needs a consistent CPU snapshot before switching the adaptive decision to delta-based CPU pressure.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](memtable) use CPU metrics delta for CPU pressure detection in adaptive flush controller [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #62744:
URL: https://github.com/apache/doris/pull/62744#issuecomment-4325343539
# BE Regression && UT Coverage Report
Increment line coverage `90.91% (40/44)` :tada:
[Increment coverage report](http://coverage.selectdb-in.cc/coverage/62744_57ff1e6cf99c861f425dcaaed03c009fa5343c41_merge/increment_report/index.html)
[Complete coverage report](http://coverage.selectdb-in.cc/coverage/62744_57ff1e6cf99c861f425dcaaed03c009fa5343c41_merge/report/index.html)
| Category | Coverage |
|-------------------|--------------------|
| Function Coverage | 73.86% (27685/37485) |
| Line Coverage | 57.63% (299635/519970) |
| Region Coverage | 54.87% (249626/454957) |
| Branch Coverage | 56.41% (107941/191355) |
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](memtable) use CPU metrics delta for CPU pressure detection in adaptive flush controller [doris]
Posted by "liaoxin01 (via GitHub)" <gi...@apache.org>.
liaoxin01 merged PR #62744:
URL: https://github.com/apache/doris/pull/62744
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](memtable) use CPU metrics delta for CPU pressure detection in adaptive flush controller [doris]
Posted by "sollhui (via GitHub)" <gi...@apache.org>.
sollhui commented on PR #62744:
URL: https://github.com/apache/doris/pull/62744#issuecomment-4302322603
/review
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](memtable) use CPU metrics delta for CPU pressure detection in adaptive flush controller [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #62744:
URL: https://github.com/apache/doris/pull/62744#issuecomment-4342212231
PR approved by at least one committer and no changes requested.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](memtable) use CPU metrics delta for CPU pressure detection in adaptive flush controller [doris]
Posted by "sollhui (via GitHub)" <gi...@apache.org>.
sollhui commented on PR #62744:
URL: https://github.com/apache/doris/pull/62744#issuecomment-4323813131
/review
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](memtable) use CPU metrics delta for CPU pressure detection in adaptive flush controller [doris]
Posted by "sollhui (via GitHub)" <gi...@apache.org>.
sollhui commented on PR #62744:
URL: https://github.com/apache/doris/pull/62744#issuecomment-4324008393
run buildall
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](memtable) use CPU metrics delta for CPU pressure detection in adaptive flush controller [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #62744:
URL: https://github.com/apache/doris/pull/62744#issuecomment-4303682985
# BE Regression && UT Coverage Report
Increment line coverage `89.19% (33/37)` :tada:
[Increment coverage report](http://coverage.selectdb-in.cc/coverage/62744_3e8e971469ee6b5e1df4417e5428cc3e95779606_merge/increment_report/index.html)
[Complete coverage report](http://coverage.selectdb-in.cc/coverage/62744_3e8e971469ee6b5e1df4417e5428cc3e95779606_merge/report/index.html)
| Category | Coverage |
|-------------------|--------------------|
| Function Coverage | 73.58% (27523/37407) |
| Line Coverage | 57.34% (297541/518950) |
| Region Coverage | 54.54% (247559/453902) |
| Branch Coverage | 56.06% (107026/190923) |
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org