summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--power-libperfmgr/adaptivecpu/AdaptiveCpu.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/power-libperfmgr/adaptivecpu/AdaptiveCpu.cpp b/power-libperfmgr/adaptivecpu/AdaptiveCpu.cpp
index 16b4028..0ad9639 100644
--- a/power-libperfmgr/adaptivecpu/AdaptiveCpu.cpp
+++ b/power-libperfmgr/adaptivecpu/AdaptiveCpu.cpp
@@ -177,22 +177,29 @@ void AdaptiveCpu::RunMainLoop() {
LOG(VERBOSE) << "Model decision: " << static_cast<uint32_t>(throttleDecision);
ATRACE_INT("AdaptiveCpu_throttleDecision", static_cast<uint32_t>(throttleDecision));
- const auto now = mTimeSource.GetTime();
- // Resend the throttle hints, even if they've not changed, if the previous send is close to
- // timing out. We define "close to" as half the hint timeout, as we can't guarantee we will
- // run again before the actual timeout.
- const bool throttleHintMayTimeout = now - mLastThrottleHintTime > mConfig.hintTimeout / 2;
- if (throttleDecision != previousThrottleDecision || throttleHintMayTimeout) {
- mLastThrottleHintTime = now;
+ {
ATRACE_NAME("sendHints");
- for (const auto &hintName : THROTTLE_DECISION_TO_HINT_NAMES.at(throttleDecision)) {
- HintManager::GetInstance()->DoHint(hintName, mConfig.hintTimeout);
+ const auto now = mTimeSource.GetTime();
+ // Resend the throttle hints, even if they've not changed, if the previous send is close
+ // to timing out. We define "close to" as half the hint timeout, as we can't guarantee
+ // we will run again before the actual timeout.
+ const bool throttleHintMayTimeout =
+ now - mLastThrottleHintTime > mConfig.hintTimeout / 2;
+ if (throttleDecision != previousThrottleDecision || throttleHintMayTimeout) {
+ ATRACE_NAME("sendNewHints");
+ mLastThrottleHintTime = now;
+ for (const auto &hintName : THROTTLE_DECISION_TO_HINT_NAMES.at(throttleDecision)) {
+ HintManager::GetInstance()->DoHint(hintName, mConfig.hintTimeout);
+ }
}
- for (const auto &hintName :
- THROTTLE_DECISION_TO_HINT_NAMES.at(previousThrottleDecision)) {
- HintManager::GetInstance()->EndHint(hintName);
+ if (throttleDecision != previousThrottleDecision) {
+ ATRACE_NAME("endOldHints");
+ for (const auto &hintName :
+ THROTTLE_DECISION_TO_HINT_NAMES.at(previousThrottleDecision)) {
+ HintManager::GetInstance()->EndHint(hintName);
+ }
+ previousThrottleDecision = throttleDecision;
}
- previousThrottleDecision = throttleDecision;
}
mAdaptiveCpuStats.RegisterSuccessfulRun(previousThrottleDecision, throttleDecision,