Bug 1431272 - Set the process priority for the preallocated process when it becomes active. r=jimm draft
authorBlake Kaplan <mrbkap@gmail.com>
Wed, 17 Jan 2018 17:37:20 -0800
changeset 721895 4231824029bc011e1a64cdd36b4ff777437fbd58
parent 721208 b2cb61e83ac50115a28f04aaa8a32d4db90aad23
child 746473 ae9046f25c5a7481f24c3f30bc2ff7b8c3ef259b
push id95988
push userbmo:mrbkap@mozilla.com
push dateThu, 18 Jan 2018 01:38:58 +0000
reviewersjimm
bugs1431272
milestone59.0a1
Bug 1431272 - Set the process priority for the preallocated process when it becomes active. r=jimm This is currently a no-op, but the idea here is to make sure to set the process to "active" when we're about to use it for something. MozReview-Commit-ID: 2QUlALhfD4k
dom/ipc/ContentParent.cpp
dom/ipc/PreallocatedProcessManager.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -2750,16 +2750,20 @@ NS_INTERFACE_MAP_END
 
 NS_IMETHODIMP
 ContentParent::Observe(nsISupports* aSubject,
                        const char* aTopic,
                        const char16_t* aData)
 {
   if (mSubprocess && (!strcmp(aTopic, "profile-before-change") ||
                       !strcmp(aTopic, "xpcom-shutdown"))) {
+    // Make sure that our process will get scheduled.
+    ProcessPriorityManager::SetProcessPriority(this,
+                                               PROCESS_PRIORITY_FOREGROUND);
+
     // Okay to call ShutDownProcess multiple times.
     ShutDownProcess(SEND_SHUTDOWN_MESSAGE);
 
     // Wait for shutdown to complete, so that we receive any shutdown
     // data (e.g. telemetry) from the child before we quit.
     // This loop terminate prematurely based on mForceKillTimer.
     SpinEventLoopUntil([&]() { return !mIPCOpen || mCalledKillHard; });
     NS_ASSERTION(!mSubprocess, "Close should have nulled mSubprocess");
--- a/dom/ipc/PreallocatedProcessManager.cpp
+++ b/dom/ipc/PreallocatedProcessManager.cpp
@@ -163,16 +163,18 @@ already_AddRefed<ContentParent>
 PreallocatedProcessManagerImpl::Take()
 {
   if (!mEnabled || mShutdown) {
     return nullptr;
   }
 
   if (mPreallocatedProcess) {
     // The preallocated process is taken. Let's try to start up a new one soon.
+    ProcessPriorityManager::SetProcessPriority(mPreallocatedProcess,
+                                               PROCESS_PRIORITY_FOREGROUND);
     AllocateOnIdle();
   }
 
   return mPreallocatedProcess.forget();
 }
 
 bool
 PreallocatedProcessManagerImpl::Provide(ContentParent* aParent)