Bug 1641737 - P7. Make the DLL and PPDC promises use direct task dispatch. r=mattwoodrow
☠☠ backed out by 0f4b97c32ba0 ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 09 Jun 2020 07:24:23 +0000
changeset 598695 7f7b983390650cbc7d736e92fd3e1f629a30ac02
parent 598694 32fba417ebd01dfb2c2a392cdb1fad7ef66e96e8
child 598696 b6b48c37ab0c3312af42c8fd165ff1510ac53842
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1641737
milestone79.0a1
first release with
nightly linux32
7f7b98339065 / 79.0a1 / 20200609151649 / files
nightly linux64
7f7b98339065 / 79.0a1 / 20200609151649 / files
nightly mac
7f7b98339065 / 79.0a1 / 20200609151649 / files
nightly win32
7f7b98339065 / 79.0a1 / 20200609151649 / files
nightly win64
7f7b98339065 / 79.0a1 / 20200609151649 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1641737 - P7. Make the DLL and PPDC promises use direct task dispatch. r=mattwoodrow We attempt to reduce the number of event loop iterations, which would bring us back to a similar behaviour to the pre-DocumentChannel days. This prevent some tests to have increase intermittent failures. While ideally, we would prefer to fix or re-write those tests properly, the extra work would block us for too long. All those increased intermittents already have bug logged about them; so we aren't hiding dust under the rust. Differential Revision: https://phabricator.services.mozilla.com/D78489
netwerk/ipc/DocumentLoadListener.cpp
netwerk/ipc/ParentProcessDocumentChannel.cpp
--- a/netwerk/ipc/DocumentLoadListener.cpp
+++ b/netwerk/ipc/DocumentLoadListener.cpp
@@ -522,16 +522,19 @@ auto DocumentLoadListener::Open(
   }
 
   if (auto* ctx = GetBrowsingContext()) {
     ctx->StartDocumentLoad(this);
   }
 
   *aRv = NS_OK;
   mOpenPromise = new OpenPromise::Private(__func__);
+  // We make the promise use direct task dispatch in order to reduce the number
+  // of event loops iterations.
+  mOpenPromise->UseDirectTaskDispatch(__func__);
   return mOpenPromise;
 }
 
 /* static */
 bool DocumentLoadListener::OpenFromParent(
     dom::CanonicalBrowsingContext* aBrowsingContext,
     nsDocShellLoadState* aLoadState, uint64_t aOuterWindowId,
     uint32_t* aOutIdent) {
--- a/netwerk/ipc/ParentProcessDocumentChannel.cpp
+++ b/netwerk/ipc/ParentProcessDocumentChannel.cpp
@@ -61,16 +61,19 @@ ParentProcessDocumentChannel::RedirectTo
       NS_ASSERTION(false, msg.get());
       return RedirectToRealChannelPromise::CreateAndResolve(
           NS_ERROR_CONTENT_BLOCKED, __func__);
     }
   }
   mStreamFilterEndpoints = std::move(aStreamFilterEndpoints);
 
   RefPtr<RedirectToRealChannelPromise> p = mPromise.Ensure(__func__);
+  // We make the promise use direct task dispatch in order to reduce the number
+  // of event loops iterations.
+  mPromise.UseDirectTaskDispatch(__func__);
 
   nsresult rv =
       gHttpHandler->AsyncOnChannelRedirect(this, channel, aRedirectFlags);
   if (NS_FAILED(rv)) {
     LOG(
         ("ParentProcessDocumentChannel RedirectToRealChannel "
          "AsyncOnChannelRedirect failed [this=%p "
          "aRv=%d]",
@@ -171,28 +174,32 @@ NS_IMETHODIMP ParentProcessDocumentChann
         // RedirectToRealChannelPromise given as parameter.
         RefPtr<RedirectToRealChannelPromise> p =
             self->RedirectToRealChannel(
                     std::move(aResolveValue.mStreamFilterEndpoints),
                     aResolveValue.mRedirectFlags, aResolveValue.mLoadFlags)
                 ->Then(
                     GetCurrentThreadSerialEventTarget(), __func__,
                     [self](RedirectToRealChannelPromise::ResolveOrRejectValue&&
-                               aValue) {
+                               aValue) -> RefPtr<RedirectToRealChannelPromise> {
                       MOZ_ASSERT(aValue.IsResolve());
                       nsresult rv = aValue.ResolveValue();
                       if (NS_FAILED(rv)) {
                         self->DisconnectChildListeners(rv, rv);
                       }
                       self->mLoadGroup = nullptr;
                       self->mListener = nullptr;
                       self->mCallbacks = nullptr;
                       self->RemoveObserver();
-                      return RedirectToRealChannelPromise::
-                          CreateAndResolveOrReject(std::move(aValue), __func__);
+                      auto p =
+                          MakeRefPtr<RedirectToRealChannelPromise::Private>(
+                              __func__);
+                      p->UseDirectTaskDispatch(__func__);
+                      p->ResolveOrReject(std::move(aValue), __func__);
+                      return p;
                     });
         // We chain the promise the DLL is waiting on to the one returned by
         // RedirectToRealChannel. As soon as the promise returned is
         // resolved or rejected, so will the DLL's promise.
         p->ChainTo(aResolveValue.mPromise.forget(), __func__);
       },
       [self](DocumentLoadListener::OpenPromiseFailedType&& aRejectValue) {
         self->DisconnectChildListeners(aRejectValue.mStatus,