ADPF: remove unused EarlyBoostHandler

Bug: 256515601
Test: build
Change-Id: I9b63c6ee3decaa4c70f38bcc66a0e9e1de464ad6
This commit is contained in:
Jimmy Shiu 2022-10-28 11:38:28 +08:00 committed by Bruno Martins
parent e5a9512985
commit 773630adc8
2 changed files with 0 additions and 128 deletions

View File

@ -126,15 +126,8 @@ PowerHintSession::PowerHintSession(int32_t tgid, int32_t uid, const std::vector<
mDescriptor = new AppHintDesc(tgid, uid, threadIds);
mDescriptor->duration = std::chrono::nanoseconds(durationNanos);
mStaleTimerHandler = sp<StaleTimerHandler>(new StaleTimerHandler(this));
mEarlyBoostHandler = sp<EarlyBoostHandler>(new EarlyBoostHandler(this));
mPowerManagerHandler = PowerSessionManager::getInstance();
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()) {
const std::string idstr = getIdString();
@ -272,7 +265,6 @@ ndk::ScopedAStatus PowerHintSession::close() {
}
// Remove the session from PowerSessionManager first to avoid racing.
PowerSessionManager::getInstance()->removePowerSession(this);
mEarlyBoostHandler->setSessionDead();
mStaleTimerHandler->setSessionDead();
setSessionUclampMin(0);
mDescriptor->is_active.store(false);
@ -361,10 +353,6 @@ ndk::ScopedAStatus PowerHintSession::reportActualWorkDuration(
next_min = std::max(static_cast<int>(adpfConfig->mUclampMinLow), next_min);
setSessionUclampMin(next_min);
mStaleTimerHandler->updateTimer(getStaleTime());
if (HintManager::GetInstance()->GetAdpfProfile()->mEarlyBoostOn) {
updateWorkPeriod(actualDurations);
mEarlyBoostHandler->updateTimer(getEarlyBoostTime());
}
return ndk::ScopedAStatus::ok();
}
@ -444,38 +432,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 &current = 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() {
return mLastUpdatedTime.load() +
nanoseconds(static_cast<int64_t>(
@ -525,11 +481,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();
@ -544,60 +495,6 @@ void PowerHintSession::StaleTimerHandler::setSessionDead() {
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 impl
} // namespace power

View File

@ -87,8 +87,6 @@ class PowerHintSession : public BnPowerHintSession {
int getUclampMin();
void dumpToStream(std::ostream &stream);
void updateWorkPeriod(const std::vector<WorkDuration> &actualDurations);
time_point<steady_clock> getEarlyBoostTime();
time_point<steady_clock> getStaleTime();
private:
@ -110,23 +108,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<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:
void updateUniveralBoostMode();
int setSessionUclampMin(int32_t min);
@ -134,16 +115,10 @@ class PowerHintSession : public BnPowerHintSession {
std::string getIdString() const;
AppHintDesc *mDescriptor = nullptr;
sp<StaleTimerHandler> mStaleTimerHandler;
sp<EarlyBoostHandler> mEarlyBoostHandler;
std::atomic<time_point<steady_clock>> mLastUpdatedTime;
sp<MessageHandler> mPowerManagerHandler;
std::mutex mSessionLock;
std::atomic<bool> mSessionClosed = false;
// These 3 variables are for earlyboost work period estimation.
int64_t mLastStartedTimeNs;
int64_t mLastDurationNs;
int64_t mWorkPeriodNs;
// To cache the status of whether ADPF hints are supported.
std::unordered_map<std::string, std::optional<bool>> mSupportedHints;
};