Skip to content

Commit 4c795ba

Browse files
Jimmy Shiulifehackerhansol
authored andcommitted
ADPF: remove unused EarlyBoostHandler
Bug: 256515601 Test: build Change-Id: I9b63c6ee3decaa4c70f38bcc66a0e9e1de464ad6
1 parent 5d93e4b commit 4c795ba

File tree

2 files changed

+0
-128
lines changed

2 files changed

+0
-128
lines changed

power-libperfmgr/aidl/PowerHintSession.cpp

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,8 @@ PowerHintSession::PowerHintSession(int32_t tgid, int32_t uid, const std::vector<
126126
mDescriptor = new AppHintDesc(tgid, uid, threadIds);
127127
mDescriptor->duration = std::chrono::nanoseconds(durationNanos);
128128
mStaleTimerHandler = sp<StaleTimerHandler>(new StaleTimerHandler(this));
129-
mEarlyBoostHandler = sp<EarlyBoostHandler>(new EarlyBoostHandler(this));
130129
mPowerManagerHandler = PowerSessionManager::getInstance();
131130
mLastUpdatedTime.store(std::chrono::steady_clock::now());
132-
mLastStartedTimeNs =
133-
std::chrono::duration_cast<std::chrono::nanoseconds>(
134-
(std::chrono::steady_clock::now() - mDescriptor->duration).time_since_epoch())
135-
.count();
136-
mLastDurationNs = durationNanos;
137-
mWorkPeriodNs = durationNanos;
138131

139132
if (ATRACE_ENABLED()) {
140133
const std::string idstr = getIdString();
@@ -272,7 +265,6 @@ ndk::ScopedAStatus PowerHintSession::close() {
272265
}
273266
// Remove the session from PowerSessionManager first to avoid racing.
274267
PowerSessionManager::getInstance()->removePowerSession(this);
275-
mEarlyBoostHandler->setSessionDead();
276268
mStaleTimerHandler->setSessionDead();
277269
setSessionUclampMin(0);
278270
mDescriptor->is_active.store(false);
@@ -361,10 +353,6 @@ ndk::ScopedAStatus PowerHintSession::reportActualWorkDuration(
361353
next_min = std::max(static_cast<int>(adpfConfig->mUclampMinLow), next_min);
362354
setSessionUclampMin(next_min);
363355
mStaleTimerHandler->updateTimer(getStaleTime());
364-
if (HintManager::GetInstance()->GetAdpfProfile()->mEarlyBoostOn) {
365-
updateWorkPeriod(actualDurations);
366-
mEarlyBoostHandler->updateTimer(getEarlyBoostTime());
367-
}
368356

369357
return ndk::ScopedAStatus::ok();
370358
}
@@ -444,38 +432,6 @@ void PowerHintSession::wakeup() {
444432
}
445433
}
446434

447-
void PowerHintSession::updateWorkPeriod(const std::vector<WorkDuration> &actualDurations) {
448-
if (actualDurations.size() == 0)
449-
return;
450-
if (actualDurations.size() >= 2) {
451-
const WorkDuration &last = actualDurations[actualDurations.size() - 2];
452-
mLastStartedTimeNs = last.timeStampNanos - last.durationNanos;
453-
}
454-
const WorkDuration &current = actualDurations.back();
455-
int64_t curr_start = current.timeStampNanos - current.durationNanos;
456-
int64_t period = curr_start - mLastStartedTimeNs;
457-
if (period > 0 && period < mDescriptor->duration.count() * 2) {
458-
// Accounting workload period with moving average for the last 10 workload.
459-
mWorkPeriodNs = 0.9 * mWorkPeriodNs + 0.1 * period;
460-
if (ATRACE_ENABLED()) {
461-
const std::string idstr = getIdString();
462-
std::string sz = StringPrintf("adpf.%s-timer.period", idstr.c_str());
463-
ATRACE_INT(sz.c_str(), mWorkPeriodNs);
464-
}
465-
}
466-
mLastStartedTimeNs = curr_start;
467-
mLastDurationNs = current.durationNanos;
468-
}
469-
470-
time_point<steady_clock> PowerHintSession::getEarlyBoostTime() {
471-
std::shared_ptr<AdpfConfig> adpfConfig = HintManager::GetInstance()->GetAdpfProfile();
472-
int64_t earlyBoostTimeoutNs =
473-
(int64_t)mDescriptor->duration.count() * adpfConfig->mEarlyBoostTimeFactor;
474-
time_point<steady_clock> nextStartTime =
475-
mLastUpdatedTime.load() + nanoseconds(mWorkPeriodNs - mLastDurationNs);
476-
return nextStartTime + nanoseconds(earlyBoostTimeoutNs);
477-
}
478-
479435
time_point<steady_clock> PowerHintSession::getStaleTime() {
480436
return mLastUpdatedTime.load() +
481437
nanoseconds(static_cast<int64_t>(
@@ -525,11 +481,6 @@ void PowerHintSession::StaleTimerHandler::handleMessage(const Message &) {
525481
} else {
526482
mSession->setStale();
527483
mIsMonitoring.store(false);
528-
if (ATRACE_ENABLED()) {
529-
const std::string idstr = mSession->getIdString();
530-
std::string sz = StringPrintf("adpf.%s-timer.earlyboost", idstr.c_str());
531-
ATRACE_INT(sz.c_str(), 0);
532-
}
533484
}
534485
if (ATRACE_ENABLED()) {
535486
const std::string idstr = mSession->getIdString();
@@ -544,60 +495,6 @@ void PowerHintSession::StaleTimerHandler::setSessionDead() {
544495
PowerHintMonitor::getInstance()->getLooper()->removeMessages(mSession->mStaleTimerHandler);
545496
}
546497

547-
void PowerHintSession::EarlyBoostHandler::updateTimer(time_point<steady_clock> boostTime) {
548-
mBoostTime.store(boostTime);
549-
{
550-
std::lock_guard<std::mutex> guard(mMessageLock);
551-
PowerHintMonitor::getInstance()->getLooper()->removeMessages(mSession->mEarlyBoostHandler);
552-
PowerHintMonitor::getInstance()->getLooper()->sendMessage(mSession->mEarlyBoostHandler,
553-
NULL);
554-
}
555-
mIsMonitoring.store(true);
556-
if (ATRACE_ENABLED()) {
557-
const std::string idstr = mSession->getIdString();
558-
std::string sz = StringPrintf("adpf.%s-timer.earlyboost", idstr.c_str());
559-
ATRACE_INT(sz.c_str(), 1);
560-
}
561-
}
562-
563-
void PowerHintSession::EarlyBoostHandler::handleMessage(const Message &) {
564-
std::lock_guard<std::mutex> guard(mBoostLock);
565-
if (mIsSessionDead) {
566-
return;
567-
}
568-
auto now = std::chrono::steady_clock::now();
569-
int64_t next =
570-
static_cast<int64_t>(duration_cast<nanoseconds>(mBoostTime.load() - now).count());
571-
if (next > 0) {
572-
if (ATRACE_ENABLED()) {
573-
const std::string idstr = mSession->getIdString();
574-
std::string sz = StringPrintf("adpf.%s-timer.earlyboost", idstr.c_str());
575-
ATRACE_INT(sz.c_str(), 1);
576-
}
577-
std::lock_guard<std::mutex> guard(mMessageLock);
578-
PowerHintMonitor::getInstance()->getLooper()->removeMessages(mSession->mEarlyBoostHandler);
579-
PowerHintMonitor::getInstance()->getLooper()->sendMessageDelayed(
580-
next, mSession->mEarlyBoostHandler, NULL);
581-
} else {
582-
std::shared_ptr<AdpfConfig> adpfConfig = HintManager::GetInstance()->GetAdpfProfile();
583-
PowerSessionManager::getInstance()->setUclampMin(mSession, adpfConfig->mUclampMinHigh);
584-
mIsMonitoring.store(false);
585-
if (ATRACE_ENABLED()) {
586-
const std::string idstr = mSession->getIdString();
587-
std::string sz = StringPrintf("adpf.%s-min", idstr.c_str());
588-
ATRACE_INT(sz.c_str(), adpfConfig->mUclampMinHigh);
589-
sz = StringPrintf("adpf.%s-timer.earlyboost", idstr.c_str());
590-
ATRACE_INT(sz.c_str(), 2);
591-
}
592-
}
593-
}
594-
595-
void PowerHintSession::EarlyBoostHandler::setSessionDead() {
596-
std::lock_guard<std::mutex> guard(mBoostLock);
597-
mIsSessionDead = true;
598-
PowerHintMonitor::getInstance()->getLooper()->removeMessages(mSession->mEarlyBoostHandler);
599-
}
600-
601498
} // namespace pixel
602499
} // namespace impl
603500
} // namespace power

power-libperfmgr/aidl/PowerHintSession.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ class PowerHintSession : public BnPowerHintSession {
8787
int getUclampMin();
8888
void dumpToStream(std::ostream &stream);
8989

90-
void updateWorkPeriod(const std::vector<WorkDuration> &actualDurations);
91-
time_point<steady_clock> getEarlyBoostTime();
9290
time_point<steady_clock> getStaleTime();
9391

9492
private:
@@ -110,40 +108,17 @@ class PowerHintSession : public BnPowerHintSession {
110108
bool mIsSessionDead;
111109
};
112110

113-
class EarlyBoostHandler : public MessageHandler {
114-
public:
115-
EarlyBoostHandler(PowerHintSession *session)
116-
: mSession(session), mIsMonitoring(false), mIsSessionDead(false) {}
117-
void updateTimer(time_point<steady_clock> boostTime);
118-
void handleMessage(const Message &message) override;
119-
void setSessionDead();
120-
121-
private:
122-
PowerHintSession *mSession;
123-
std::mutex mBoostLock;
124-
std::mutex mMessageLock;
125-
std::atomic<time_point<steady_clock>> mBoostTime;
126-
std::atomic<bool> mIsMonitoring;
127-
bool mIsSessionDead;
128-
};
129-
130111
private:
131112
void updateUniveralBoostMode();
132113
int setSessionUclampMin(int32_t min);
133114
void tryToSendPowerHint(std::string hint);
134115
std::string getIdString() const;
135116
AppHintDesc *mDescriptor = nullptr;
136117
sp<StaleTimerHandler> mStaleTimerHandler;
137-
sp<EarlyBoostHandler> mEarlyBoostHandler;
138118
std::atomic<time_point<steady_clock>> mLastUpdatedTime;
139119
sp<MessageHandler> mPowerManagerHandler;
140120
std::mutex mSessionLock;
141121
std::atomic<bool> mSessionClosed = false;
142-
// These 3 variables are for earlyboost work period estimation.
143-
int64_t mLastStartedTimeNs;
144-
int64_t mLastDurationNs;
145-
int64_t mWorkPeriodNs;
146-
147122
// To cache the status of whether ADPF hints are supported.
148123
std::unordered_map<std::string, std::optional<bool>> mSupportedHints;
149124
};

0 commit comments

Comments
 (0)