Skip to content

Commit

Permalink
Fix performance regression after 271209@main
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=265826
rdar://118948980

Reviewed by Per Arne Vollan.

271209@main introduced a CompletionHandler to SpeculativeLoad::willSendRedirectedRequest.
Before that change, we would just destroy the NetworkLoad and be done.
After that change, we call the redirect completion handler with an empty ResourceRequest
before destroying the NetworkLoad, which calls updateRequest and didCompleteWithError.
This PR changes calling the completion handler to after the call to SpeculativeLoad::didComplete
which destroys the NetworkLoad.  That way, the lambda at the end of the function
NetworkLoad::willPerformHTTPRedirection just finds a null weakThis and does none of this
unnecessary work.  I verified that this is what is going on on the sites in the radar
that showed a performance regression, and I verified that this change removes that unnecessary
work when not following redirects.

* Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp:
(WebKit::NetworkCache::SpeculativeLoad::willSendRedirectedRequest):

Canonical link: https://commits.webkit.org/271526@main
  • Loading branch information
achristensen07 committed Dec 5, 2023
1 parent db9ae69 commit bbe1fd0
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ void SpeculativeLoad::willSendRedirectedRequest(ResourceRequest&& request, Resou
m_cacheEntry = m_cache->makeRedirectEntry(request, redirectResponse, redirectRequest);

// Don't follow the redirect. The redirect target will be registered for speculative load when it is loaded.
completionHandler({ });
didComplete();
completionHandler({ });
}

void SpeculativeLoad::didReceiveResponse(ResourceResponse&& receivedResponse, PrivateRelayed privateRelayed, ResponseCompletionHandler&& completionHandler)
Expand Down

0 comments on commit bbe1fd0

Please sign in to comment.