sdm660-common: power-libperfmgr: ADPF: remove unused EarlyBoostHandler
Bug: 256515601 Test: build Change-Id: I9b63c6ee3decaa4c70f38bcc66a0e9e1de464ad6
This commit is contained in:
parent
2da49e3b97
commit
255babc340
2 changed files with 0 additions and 127 deletions
|
@ -128,15 +128,8 @@ PowerHintSession::PowerHintSession(std::shared_ptr<AdaptiveCpu> adaptiveCpu, int
|
||||||
mDescriptor = new AppHintDesc(tgid, uid, threadIds);
|
mDescriptor = new AppHintDesc(tgid, uid, threadIds);
|
||||||
mDescriptor->duration = std::chrono::nanoseconds(durationNanos);
|
mDescriptor->duration = std::chrono::nanoseconds(durationNanos);
|
||||||
mStaleTimerHandler = sp<StaleTimerHandler>(new StaleTimerHandler(this));
|
mStaleTimerHandler = sp<StaleTimerHandler>(new StaleTimerHandler(this));
|
||||||
mEarlyBoostHandler = sp<EarlyBoostHandler>(new EarlyBoostHandler(this));
|
|
||||||
mPowerManagerHandler = PowerSessionManager::getInstance();
|
mPowerManagerHandler = PowerSessionManager::getInstance();
|
||||||
mLastUpdatedTime.store(std::chrono::steady_clock::now());
|
mLastUpdatedTime.store(std::chrono::steady_clock::now());
|
||||||
mLastStartedTimeNs =
|
|
||||||
std::chrono::duration_cast<std::chrono::nanoseconds>(
|
|
||||||
(std::chrono::steady_clock::now() - mDescriptor->duration).time_since_epoch())
|
|
||||||
.count();
|
|
||||||
mLastDurationNs = durationNanos;
|
|
||||||
mWorkPeriodNs = durationNanos;
|
|
||||||
|
|
||||||
if (ATRACE_ENABLED()) {
|
if (ATRACE_ENABLED()) {
|
||||||
const std::string idstr = getIdString();
|
const std::string idstr = getIdString();
|
||||||
|
@ -271,7 +264,6 @@ ndk::ScopedAStatus PowerHintSession::close() {
|
||||||
mSessionClosed.store(true);
|
mSessionClosed.store(true);
|
||||||
}
|
}
|
||||||
mDescriptor->is_active.store(false);
|
mDescriptor->is_active.store(false);
|
||||||
mEarlyBoostHandler->setSessionDead();
|
|
||||||
mStaleTimerHandler->setSessionDead();
|
mStaleTimerHandler->setSessionDead();
|
||||||
updateUniveralBoostMode();
|
updateUniveralBoostMode();
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
|
@ -355,10 +347,6 @@ ndk::ScopedAStatus PowerHintSession::reportActualWorkDuration(
|
||||||
next_min = std::max(static_cast<int>(adpfConfig->mUclampMinLow), next_min);
|
next_min = std::max(static_cast<int>(adpfConfig->mUclampMinLow), next_min);
|
||||||
setSessionUclampMin(next_min);
|
setSessionUclampMin(next_min);
|
||||||
mStaleTimerHandler->updateTimer(getStaleTime());
|
mStaleTimerHandler->updateTimer(getStaleTime());
|
||||||
if (HintManager::GetInstance()->GetAdpfProfile()->mEarlyBoostOn) {
|
|
||||||
updateWorkPeriod(actualDurations);
|
|
||||||
mEarlyBoostHandler->updateTimer(getEarlyBoostTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
mAdaptiveCpu->ReportWorkDurations(actualDurations, mDescriptor->duration);
|
mAdaptiveCpu->ReportWorkDurations(actualDurations, mDescriptor->duration);
|
||||||
|
|
||||||
|
@ -435,38 +423,6 @@ void PowerHintSession::wakeup() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerHintSession::updateWorkPeriod(const std::vector<WorkDuration> &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<steady_clock> PowerHintSession::getEarlyBoostTime() {
|
|
||||||
std::shared_ptr<AdpfConfig> adpfConfig = HintManager::GetInstance()->GetAdpfProfile();
|
|
||||||
int64_t earlyBoostTimeoutNs =
|
|
||||||
(int64_t)mDescriptor->duration.count() * adpfConfig->mEarlyBoostTimeFactor;
|
|
||||||
time_point<steady_clock> nextStartTime =
|
|
||||||
mLastUpdatedTime.load() + nanoseconds(mWorkPeriodNs - mLastDurationNs);
|
|
||||||
return nextStartTime + nanoseconds(earlyBoostTimeoutNs);
|
|
||||||
}
|
|
||||||
|
|
||||||
time_point<steady_clock> PowerHintSession::getStaleTime() {
|
time_point<steady_clock> PowerHintSession::getStaleTime() {
|
||||||
return mLastUpdatedTime.load() +
|
return mLastUpdatedTime.load() +
|
||||||
nanoseconds(static_cast<int64_t>(
|
nanoseconds(static_cast<int64_t>(
|
||||||
|
@ -515,11 +471,6 @@ void PowerHintSession::StaleTimerHandler::handleMessage(const Message &) {
|
||||||
} else {
|
} else {
|
||||||
mSession->setStale();
|
mSession->setStale();
|
||||||
mIsMonitoring.store(false);
|
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()) {
|
if (ATRACE_ENABLED()) {
|
||||||
const std::string idstr = mSession->getIdString();
|
const std::string idstr = mSession->getIdString();
|
||||||
|
@ -534,60 +485,6 @@ void PowerHintSession::StaleTimerHandler::setSessionDead() {
|
||||||
PowerHintMonitor::getInstance()->getLooper()->removeMessages(mSession->mStaleTimerHandler);
|
PowerHintMonitor::getInstance()->getLooper()->removeMessages(mSession->mStaleTimerHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerHintSession::EarlyBoostHandler::updateTimer(time_point<steady_clock> boostTime) {
|
|
||||||
mBoostTime.store(boostTime);
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> 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<std::mutex> guard(mBoostLock);
|
|
||||||
if (mIsSessionDead) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto now = std::chrono::steady_clock::now();
|
|
||||||
int64_t next =
|
|
||||||
static_cast<int64_t>(duration_cast<nanoseconds>(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<std::mutex> guard(mMessageLock);
|
|
||||||
PowerHintMonitor::getInstance()->getLooper()->removeMessages(mSession->mEarlyBoostHandler);
|
|
||||||
PowerHintMonitor::getInstance()->getLooper()->sendMessageDelayed(
|
|
||||||
next, mSession->mEarlyBoostHandler, NULL);
|
|
||||||
} else {
|
|
||||||
std::shared_ptr<AdpfConfig> 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<std::mutex> guard(mBoostLock);
|
|
||||||
mIsSessionDead = true;
|
|
||||||
PowerHintMonitor::getInstance()->getLooper()->removeMessages(mSession->mEarlyBoostHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace pixel
|
} // namespace pixel
|
||||||
} // namespace impl
|
} // namespace impl
|
||||||
} // namespace power
|
} // namespace power
|
||||||
|
|
|
@ -89,8 +89,6 @@ class PowerHintSession : public BnPowerHintSession {
|
||||||
int getUclampMin();
|
int getUclampMin();
|
||||||
void dumpToStream(std::ostream &stream);
|
void dumpToStream(std::ostream &stream);
|
||||||
|
|
||||||
void updateWorkPeriod(const std::vector<WorkDuration> &actualDurations);
|
|
||||||
time_point<steady_clock> getEarlyBoostTime();
|
|
||||||
time_point<steady_clock> getStaleTime();
|
time_point<steady_clock> getStaleTime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -112,23 +110,6 @@ class PowerHintSession : public BnPowerHintSession {
|
||||||
bool mIsSessionDead;
|
bool mIsSessionDead;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EarlyBoostHandler : public MessageHandler {
|
|
||||||
public:
|
|
||||||
EarlyBoostHandler(PowerHintSession *session)
|
|
||||||
: mSession(session), mIsMonitoring(false), mIsSessionDead(false) {}
|
|
||||||
void updateTimer(time_point<steady_clock> boostTime);
|
|
||||||
void handleMessage(const Message &message) override;
|
|
||||||
void setSessionDead();
|
|
||||||
|
|
||||||
private:
|
|
||||||
PowerHintSession *mSession;
|
|
||||||
std::mutex mBoostLock;
|
|
||||||
std::mutex mMessageLock;
|
|
||||||
std::atomic<time_point<steady_clock>> mBoostTime;
|
|
||||||
std::atomic<bool> mIsMonitoring;
|
|
||||||
bool mIsSessionDead;
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateUniveralBoostMode();
|
void updateUniveralBoostMode();
|
||||||
int setSessionUclampMin(int32_t min);
|
int setSessionUclampMin(int32_t min);
|
||||||
|
@ -136,15 +117,10 @@ class PowerHintSession : public BnPowerHintSession {
|
||||||
const std::shared_ptr<AdaptiveCpu> mAdaptiveCpu;
|
const std::shared_ptr<AdaptiveCpu> mAdaptiveCpu;
|
||||||
AppHintDesc *mDescriptor = nullptr;
|
AppHintDesc *mDescriptor = nullptr;
|
||||||
sp<StaleTimerHandler> mStaleTimerHandler;
|
sp<StaleTimerHandler> mStaleTimerHandler;
|
||||||
sp<EarlyBoostHandler> mEarlyBoostHandler;
|
|
||||||
std::atomic<time_point<steady_clock>> mLastUpdatedTime;
|
std::atomic<time_point<steady_clock>> mLastUpdatedTime;
|
||||||
sp<MessageHandler> mPowerManagerHandler;
|
sp<MessageHandler> mPowerManagerHandler;
|
||||||
std::mutex mSessionLock;
|
std::mutex mSessionLock;
|
||||||
std::atomic<bool> mSessionClosed = false;
|
std::atomic<bool> mSessionClosed = false;
|
||||||
// These 3 variables are for earlyboost work period estimation.
|
|
||||||
int64_t mLastStartedTimeNs;
|
|
||||||
int64_t mLastDurationNs;
|
|
||||||
int64_t mWorkPeriodNs;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace pixel
|
} // namespace pixel
|
||||||
|
|
Loading…
Reference in a new issue