@@ -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 ¤t = 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-
479435time_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
0 commit comments