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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]