зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1669214 - Part 1: Remove environment variable to disable TaskController. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D92450
This commit is contained in:
Родитель
bff9a869c8
Коммит
45e747487b
|
@ -39,79 +39,22 @@ void PrioritizedEventQueue::PutEvent(already_AddRefed<nsIRunnable>&& aEvent,
|
|||
mozilla::TimeDuration* aDelay) {
|
||||
RefPtr<nsIRunnable> event(aEvent);
|
||||
|
||||
if (UseTaskController()) {
|
||||
TaskController* tc = TaskController::Get();
|
||||
TaskController* tc = TaskController::Get();
|
||||
|
||||
TaskManager* manager = nullptr;
|
||||
if (aPriority == EventQueuePriority::InputHigh) {
|
||||
if (mInputTaskManager->State() == InputTaskManager::STATE_DISABLED) {
|
||||
aPriority = EventQueuePriority::Normal;
|
||||
} else {
|
||||
manager = mInputTaskManager;
|
||||
}
|
||||
} else if (aPriority == EventQueuePriority::DeferredTimers ||
|
||||
aPriority == EventQueuePriority::Idle) {
|
||||
manager = mIdleTaskManager;
|
||||
TaskManager* manager = nullptr;
|
||||
if (aPriority == EventQueuePriority::InputHigh) {
|
||||
if (mInputTaskManager->State() == InputTaskManager::STATE_DISABLED) {
|
||||
aPriority = EventQueuePriority::Normal;
|
||||
} else {
|
||||
manager = mInputTaskManager;
|
||||
}
|
||||
|
||||
tc->DispatchRunnable(event.forget(), static_cast<uint32_t>(aPriority),
|
||||
manager);
|
||||
return;
|
||||
} else if (aPriority == EventQueuePriority::DeferredTimers ||
|
||||
aPriority == EventQueuePriority::Idle) {
|
||||
manager = mIdleTaskManager;
|
||||
}
|
||||
|
||||
// Double check the priority with a QI.
|
||||
EventQueuePriority priority = aPriority;
|
||||
|
||||
if (priority == EventQueuePriority::InputHigh &&
|
||||
mInputTaskManager->State() == InputTaskManager::STATE_DISABLED) {
|
||||
priority = EventQueuePriority::Normal;
|
||||
} else if (priority == EventQueuePriority::MediumHigh &&
|
||||
!StaticPrefs::threads_medium_high_event_queue_enabled()) {
|
||||
priority = EventQueuePriority::Normal;
|
||||
}
|
||||
|
||||
switch (priority) {
|
||||
case EventQueuePriority::High:
|
||||
mHighQueue->PutEvent(event.forget(), priority, aProofOfLock, aDelay);
|
||||
break;
|
||||
case EventQueuePriority::InputHigh:
|
||||
mInputQueue->PutEvent(event.forget(), priority, aProofOfLock, aDelay);
|
||||
break;
|
||||
case EventQueuePriority::MediumHigh:
|
||||
mMediumHighQueue->PutEvent(event.forget(), priority, aProofOfLock,
|
||||
aDelay);
|
||||
break;
|
||||
case EventQueuePriority::Normal:
|
||||
mNormalQueue->PutEvent(event.forget(), priority, aProofOfLock, aDelay);
|
||||
break;
|
||||
case EventQueuePriority::InputLow:
|
||||
MOZ_ASSERT(false, "InputLow is a TaskController's internal priority!");
|
||||
break;
|
||||
case EventQueuePriority::DeferredTimers: {
|
||||
if (NS_IsMainThread()) {
|
||||
mDeferredTimersQueue->PutEvent(event.forget(), priority, aProofOfLock,
|
||||
aDelay);
|
||||
} else {
|
||||
// We don't want to touch our idle queues from off the main
|
||||
// thread. Queue it indirectly.
|
||||
IndirectlyQueueRunnable(event.forget(), priority, aProofOfLock, aDelay);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EventQueuePriority::Idle: {
|
||||
if (NS_IsMainThread()) {
|
||||
mIdleQueue->PutEvent(event.forget(), priority, aProofOfLock, aDelay);
|
||||
} else {
|
||||
// We don't want to touch our idle queues from off the main
|
||||
// thread. Queue it indirectly.
|
||||
IndirectlyQueueRunnable(event.forget(), priority, aProofOfLock, aDelay);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EventQueuePriority::Count:
|
||||
MOZ_CRASH("EventQueuePriority::Count isn't a valid priority");
|
||||
break;
|
||||
}
|
||||
tc->DispatchRunnable(event.forget(), static_cast<uint32_t>(aPriority),
|
||||
manager);
|
||||
}
|
||||
|
||||
EventQueuePriority PrioritizedEventQueue::SelectQueue(
|
||||
|
|
|
@ -53,7 +53,7 @@ ThreadEventQueue<InnerQueueT>::ThreadEventQueue(UniquePtr<InnerQueueT> aQueue,
|
|||
: mBaseQueue(std::move(aQueue)),
|
||||
mLock("ThreadEventQueue"),
|
||||
mEventsAvailable(mLock, "EventsAvail") {
|
||||
if (UseTaskController() && aIsMainThread) {
|
||||
if (aIsMainThread) {
|
||||
TaskController::Get()->SetConditionVariable(&mEventsAvailable);
|
||||
}
|
||||
static_assert(std::is_base_of<AbstractEventQueue, InnerQueueT>::value,
|
||||
|
@ -378,7 +378,7 @@ template <class InnerQueueT>
|
|||
void ThreadEventQueue<InnerQueueT>::SetObserver(nsIThreadObserver* aObserver) {
|
||||
MutexAutoLock lock(mLock);
|
||||
mObserver = aObserver;
|
||||
if (UseTaskController() && NS_IsMainThread()) {
|
||||
if (NS_IsMainThread()) {
|
||||
TaskController::Get()->SetThreadObserver(aObserver);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -598,7 +598,7 @@ nsThread::nsThread(NotNull<SynchronizedEventQueue*> aQueue,
|
|||
mLastWakeupCheckTime(TimeStamp::Now()),
|
||||
#endif
|
||||
mPerformanceCounterState(mNestedEventLoopDepth, mIsMainThread) {
|
||||
if (UseTaskController() && mIsMainThread) {
|
||||
if (mIsMainThread) {
|
||||
mozilla::TaskController::Get()->SetPerformanceCounterState(
|
||||
&mPerformanceCounterState);
|
||||
}
|
||||
|
@ -909,7 +909,7 @@ nsThread::HasPendingEvents(bool* aResult) {
|
|||
return NS_ERROR_NOT_SAME_THREAD;
|
||||
}
|
||||
|
||||
if (mIsMainThread && UseTaskController() && !mIsInLocalExecutionMode) {
|
||||
if (mIsMainThread && !mIsInLocalExecutionMode) {
|
||||
*aResult = TaskController::Get()->HasMainThreadPendingTasks();
|
||||
} else {
|
||||
*aResult = mEvents->HasPendingEvent();
|
||||
|
@ -1143,7 +1143,7 @@ nsThread::ProcessNextEvent(bool aMayWait, bool* aResult) {
|
|||
// default.
|
||||
EventQueuePriority priority = EventQueuePriority::Normal;
|
||||
nsCOMPtr<nsIRunnable> event;
|
||||
bool usingTaskController = mIsMainThread && UseTaskController();
|
||||
bool usingTaskController = mIsMainThread;
|
||||
if (usingTaskController) {
|
||||
event = TaskController::Get()->GetRunnableForMTTask(reallyWait);
|
||||
} else {
|
||||
|
|
|
@ -45,12 +45,6 @@ class nsThreadEnumerator;
|
|||
// See https://www.w3.org/TR/longtasks
|
||||
#define LONGTASK_BUSY_WINDOW_MS 50
|
||||
|
||||
static inline bool UseTaskController() {
|
||||
static const bool kUseTaskController =
|
||||
!PR_GetEnv("MOZ_DISABLE_TASKCONTROLLER");
|
||||
return kUseTaskController;
|
||||
}
|
||||
|
||||
// A class for managing performance counter state.
|
||||
namespace mozilla {
|
||||
class PerformanceCounterState {
|
||||
|
|
Загрузка…
Ссылка в новой задаче