diff --git a/power-libperfmgr/aidl/PowerHintSession.cpp b/power-libperfmgr/aidl/PowerHintSession.cpp index cac641a6..1c78f91f 100644 --- a/power-libperfmgr/aidl/PowerHintSession.cpp +++ b/power-libperfmgr/aidl/PowerHintSession.cpp @@ -128,15 +128,8 @@ PowerHintSession::PowerHintSession(std::shared_ptr adaptiveCpu, int mDescriptor = new AppHintDesc(tgid, uid, threadIds); mDescriptor->duration = std::chrono::nanoseconds(durationNanos); mStaleTimerHandler = sp(new StaleTimerHandler(this)); - mEarlyBoostHandler = sp(new EarlyBoostHandler(this)); mPowerManagerHandler = PowerSessionManager::getInstance(); mLastUpdatedTime.store(std::chrono::steady_clock::now()); - mLastStartedTimeNs = - std::chrono::duration_cast( - (std::chrono::steady_clock::now() - mDescriptor->duration).time_since_epoch()) - .count(); - mLastDurationNs = durationNanos; - mWorkPeriodNs = durationNanos; if (ATRACE_ENABLED()) { const std::string idstr = getIdString(); @@ -271,7 +264,6 @@ ndk::ScopedAStatus PowerHintSession::close() { mSessionClosed.store(true); } mDescriptor->is_active.store(false); - mEarlyBoostHandler->setSessionDead(); mStaleTimerHandler->setSessionDead(); updateUniveralBoostMode(); return ndk::ScopedAStatus::ok(); @@ -355,10 +347,6 @@ ndk::ScopedAStatus PowerHintSession::reportActualWorkDuration( next_min = std::max(static_cast(adpfConfig->mUclampMinLow), next_min); setSessionUclampMin(next_min); mStaleTimerHandler->updateTimer(getStaleTime()); - if (HintManager::GetInstance()->GetAdpfProfile()->mEarlyBoostOn) { - updateWorkPeriod(actualDurations); - mEarlyBoostHandler->updateTimer(getEarlyBoostTime()); - } mAdaptiveCpu->ReportWorkDurations(actualDurations, mDescriptor->duration); @@ -435,38 +423,6 @@ void PowerHintSession::wakeup() { } } -void PowerHintSession::updateWorkPeriod(const std::vector &actualDurations) { - if (actualDurations.size() == 0) - return; - if (actualDurations.size() >= 2) { - const WorkDuration &last = actualDurations[actualDurations.size() - 2]; - mLastStartedTimeNs = last.timeStampNanos - last.durationNanos; - } - const WorkDuration ¤t = actualDurations.back(); - int64_t curr_start = current.timeStampNanos - current.durationNanos; - int64_t period = curr_start - mLastStartedTimeNs; - if (period > 0 && period < mDescriptor->duration.count() * 2) { - // Accounting workload period with moving average for the last 10 workload. - mWorkPeriodNs = 0.9 * mWorkPeriodNs + 0.1 * period; - if (ATRACE_ENABLED()) { - const std::string idstr = getIdString(); - std::string sz = StringPrintf("adpf.%s-timer.period", idstr.c_str()); - ATRACE_INT(sz.c_str(), mWorkPeriodNs); - } - } - mLastStartedTimeNs = curr_start; - mLastDurationNs = current.durationNanos; -} - -time_point PowerHintSession::getEarlyBoostTime() { - std::shared_ptr adpfConfig = HintManager::GetInstance()->GetAdpfProfile(); - int64_t earlyBoostTimeoutNs = - (int64_t)mDescriptor->duration.count() * adpfConfig->mEarlyBoostTimeFactor; - time_point nextStartTime = - mLastUpdatedTime.load() + nanoseconds(mWorkPeriodNs - mLastDurationNs); - return nextStartTime + nanoseconds(earlyBoostTimeoutNs); -} - time_point PowerHintSession::getStaleTime() { return mLastUpdatedTime.load() + nanoseconds(static_cast( @@ -515,11 +471,6 @@ void PowerHintSession::StaleTimerHandler::handleMessage(const Message &) { } else { mSession->setStale(); mIsMonitoring.store(false); - if (ATRACE_ENABLED()) { - const std::string idstr = mSession->getIdString(); - std::string sz = StringPrintf("adpf.%s-timer.earlyboost", idstr.c_str()); - ATRACE_INT(sz.c_str(), 0); - } } if (ATRACE_ENABLED()) { const std::string idstr = mSession->getIdString(); @@ -534,60 +485,6 @@ void PowerHintSession::StaleTimerHandler::setSessionDead() { PowerHintMonitor::getInstance()->getLooper()->removeMessages(mSession->mStaleTimerHandler); } -void PowerHintSession::EarlyBoostHandler::updateTimer(time_point boostTime) { - mBoostTime.store(boostTime); - { - std::lock_guard guard(mMessageLock); - PowerHintMonitor::getInstance()->getLooper()->removeMessages(mSession->mEarlyBoostHandler); - PowerHintMonitor::getInstance()->getLooper()->sendMessage(mSession->mEarlyBoostHandler, - NULL); - } - mIsMonitoring.store(true); - if (ATRACE_ENABLED()) { - const std::string idstr = mSession->getIdString(); - std::string sz = StringPrintf("adpf.%s-timer.earlyboost", idstr.c_str()); - ATRACE_INT(sz.c_str(), 1); - } -} - -void PowerHintSession::EarlyBoostHandler::handleMessage(const Message &) { - std::lock_guard guard(mBoostLock); - if (mIsSessionDead) { - return; - } - auto now = std::chrono::steady_clock::now(); - int64_t next = - static_cast(duration_cast(mBoostTime.load() - now).count()); - if (next > 0) { - if (ATRACE_ENABLED()) { - const std::string idstr = mSession->getIdString(); - std::string sz = StringPrintf("adpf.%s-timer.earlyboost", idstr.c_str()); - ATRACE_INT(sz.c_str(), 1); - } - std::lock_guard guard(mMessageLock); - PowerHintMonitor::getInstance()->getLooper()->removeMessages(mSession->mEarlyBoostHandler); - PowerHintMonitor::getInstance()->getLooper()->sendMessageDelayed( - next, mSession->mEarlyBoostHandler, NULL); - } else { - std::shared_ptr adpfConfig = HintManager::GetInstance()->GetAdpfProfile(); - PowerSessionManager::getInstance()->setUclampMin(mSession, adpfConfig->mUclampMinHigh); - mIsMonitoring.store(false); - if (ATRACE_ENABLED()) { - const std::string idstr = mSession->getIdString(); - std::string sz = StringPrintf("adpf.%s-min", idstr.c_str()); - ATRACE_INT(sz.c_str(), adpfConfig->mUclampMinHigh); - sz = StringPrintf("adpf.%s-timer.earlyboost", idstr.c_str()); - ATRACE_INT(sz.c_str(), 2); - } - } -} - -void PowerHintSession::EarlyBoostHandler::setSessionDead() { - std::lock_guard guard(mBoostLock); - mIsSessionDead = true; - PowerHintMonitor::getInstance()->getLooper()->removeMessages(mSession->mEarlyBoostHandler); -} - } // namespace pixel } // namespace impl } // namespace power diff --git a/power-libperfmgr/aidl/PowerHintSession.h b/power-libperfmgr/aidl/PowerHintSession.h index 96b445ed..edd80f1c 100644 --- a/power-libperfmgr/aidl/PowerHintSession.h +++ b/power-libperfmgr/aidl/PowerHintSession.h @@ -89,8 +89,6 @@ class PowerHintSession : public BnPowerHintSession { int getUclampMin(); void dumpToStream(std::ostream &stream); - void updateWorkPeriod(const std::vector &actualDurations); - time_point getEarlyBoostTime(); time_point getStaleTime(); private: @@ -112,23 +110,6 @@ class PowerHintSession : public BnPowerHintSession { bool mIsSessionDead; }; - class EarlyBoostHandler : public MessageHandler { - public: - EarlyBoostHandler(PowerHintSession *session) - : mSession(session), mIsMonitoring(false), mIsSessionDead(false) {} - void updateTimer(time_point boostTime); - void handleMessage(const Message &message) override; - void setSessionDead(); - - private: - PowerHintSession *mSession; - std::mutex mBoostLock; - std::mutex mMessageLock; - std::atomic> mBoostTime; - std::atomic mIsMonitoring; - bool mIsSessionDead; - }; - private: void updateUniveralBoostMode(); int setSessionUclampMin(int32_t min); @@ -136,15 +117,10 @@ class PowerHintSession : public BnPowerHintSession { const std::shared_ptr mAdaptiveCpu; AppHintDesc *mDescriptor = nullptr; sp mStaleTimerHandler; - sp mEarlyBoostHandler; std::atomic> mLastUpdatedTime; sp mPowerManagerHandler; std::mutex mSessionLock; std::atomic mSessionClosed = false; - // These 3 variables are for earlyboost work period estimation. - int64_t mLastStartedTimeNs; - int64_t mLastDurationNs; - int64_t mWorkPeriodNs; }; } // namespace pixel