Changeset 238525 in webkit


Ignore:
Timestamp:
Nov 26, 2018 2:54:48 PM (5 years ago)
Author:
Chris Dumez
Message:

[PSON] process pre-warming should not be on for everyone
https://bugs.webkit.org/show_bug.cgi?id=191966
<rdar://problem/46138499>

Reviewed by Ryosuke Niwa.

If automatic process-prewarming is not explicitly turned on/off by the client, then we now only
turn it on automatically after the first process swap. Previously, it was always enabled if
process-swap on cross-site navigation was enabled (which is the case by default for all apps).

This is important because some apps do not actually browse (only display static content) or never
browse cross-site, and thus would not benefit from process prewarming and yet pay a memory cost.

  • UIProcess/API/APIProcessPoolConfiguration.h:

Add m_clientWouldBenefitFromAutomaticProcessPrewarming flag which is false by default and is used
as a fallback if the client did not call setIsAutomaticProcessWarmingEnabled().

  • UIProcess/API/C/WKContextConfigurationRef.cpp:

(WKContextConfigurationPrewarmsProcessesAutomatically):
(WKContextConfigurationSetPrewarmsProcessesAutomatically):
Add C API to toggle automatic process prewarming. It is needed for Safari to turn on this feature
by default for browsing. This way Safari does not have to wait for the first process swap to
start prewarming.

  • UIProcess/API/C/WKContextConfigurationRef.h:
  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::didReachGoodTimeToPrewarm):
Only do automatic process prewarming if process-swap on cross-site navigation is also enabled.
This is needed for clients like Safari that explicitly enable automatic process prewarming but
only want to have it enabled if PSON is also enabled via experimental features.

(WebKit::WebProcessPool::processForNavigation):
On first process swap, if the client did not explicitly turn on or off automatic process prewarming
then we enable it then. This avoids paying the cost of process prewarming in apps that would not
benefit from it.

Location:
trunk/Source/WebKit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r238515 r238525  
     12018-11-26  Chris Dumez  <cdumez@apple.com>
     2
     3        [PSON] process pre-warming should not be on for everyone
     4        https://bugs.webkit.org/show_bug.cgi?id=191966
     5        <rdar://problem/46138499>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        If automatic process-prewarming is not explicitly turned on/off by the client, then we now only
     10        turn it on automatically after the first process swap. Previously, it was always enabled if
     11        process-swap on cross-site navigation was enabled (which is the case by default for all apps).
     12
     13        This is important because some apps do not actually browse (only display static content) or never
     14        browse cross-site, and thus would not benefit from process prewarming and yet pay a memory cost.
     15
     16        * UIProcess/API/APIProcessPoolConfiguration.h:
     17        Add m_clientWouldBenefitFromAutomaticProcessPrewarming flag which is false by default and is used
     18        as a fallback if the client did not call setIsAutomaticProcessWarmingEnabled().
     19
     20        * UIProcess/API/C/WKContextConfigurationRef.cpp:
     21        (WKContextConfigurationPrewarmsProcessesAutomatically):
     22        (WKContextConfigurationSetPrewarmsProcessesAutomatically):
     23        Add C API to toggle automatic process prewarming. It is needed for Safari to turn on this feature
     24        by default for browsing. This way Safari does not have to wait for the first process swap to
     25        start prewarming.
     26
     27        * UIProcess/API/C/WKContextConfigurationRef.h:
     28        * UIProcess/WebProcessPool.cpp:
     29        (WebKit::WebProcessPool::didReachGoodTimeToPrewarm):
     30        Only do automatic process prewarming if process-swap on cross-site navigation is also enabled.
     31        This is needed for clients like Safari that explicitly enable automatic process prewarming but
     32        only want to have it enabled if PSON is also enabled via experimental features.
     33
     34        (WebKit::WebProcessPool::processForNavigation):
     35        On first process swap, if the client did not explicitly turn on or off automatic process prewarming
     36        then we enable it then. This avoids paying the cost of process prewarming in apps that would not
     37        benefit from it.
     38
    1392018-11-26  Andy Estes  <aestes@apple.com>
    240
  • trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h

    r238388 r238525  
    6262    bool isAutomaticProcessWarmingEnabled() const
    6363    {
    64         // FIXME: For now, turning on PSON from the experimental features menu also turns on
    65         // automatic process warming until clients can be updated.
    66         return m_isAutomaticProcessWarmingEnabledByClient.value_or(m_processSwapsOnNavigationFromExperimentalFeatures);
     64        return m_isAutomaticProcessWarmingEnabledByClient.value_or(m_clientWouldBenefitFromAutomaticProcessPrewarming);
    6765    }
     66
     67    bool wasAutomaticProcessWarmingSetByClient() const { return !!m_isAutomaticProcessWarmingEnabledByClient; }
    6868    void setIsAutomaticProcessWarmingEnabled(bool value) { m_isAutomaticProcessWarmingEnabledByClient = value; }
     69
     70    bool clientWouldBenefitFromAutomaticProcessPrewarming() const { return m_clientWouldBenefitFromAutomaticProcessPrewarming; }
     71    void setClientWouldBenefitFromAutomaticProcessPrewarming(bool value) { m_clientWouldBenefitFromAutomaticProcessPrewarming = value; }
    6972
    7073    bool diskCacheSpeculativeValidationEnabled() const { return m_diskCacheSpeculativeValidationEnabled; }
     
    223226    bool m_processSwapsOnWindowOpenWithOpener { false };
    224227    std::optional<bool> m_isAutomaticProcessWarmingEnabledByClient;
     228    bool m_clientWouldBenefitFromAutomaticProcessPrewarming { false };
    225229    WTF::String m_customWebContentServiceBundleIdentifier;
    226230    bool m_isJITEnabled { true };
  • trunk/Source/WebKit/UIProcess/API/C/WKContextConfigurationRef.cpp

    r232531 r238525  
    169169}
    170170
     171bool WKContextConfigurationPrewarmsProcessesAutomatically(WKContextConfigurationRef configuration)
     172{
     173    return toImpl(configuration)->isAutomaticProcessWarmingEnabled();
     174}
     175
     176void WKContextConfigurationSetPrewarmsProcessesAutomatically(WKContextConfigurationRef configuration, bool prewarms)
     177{
     178    toImpl(configuration)->setIsAutomaticProcessWarmingEnabled(prewarms);
     179}
     180
    171181bool WKContextConfigurationAlwaysKeepAndReuseSwappedProcesses(WKContextConfigurationRef configuration)
    172182{
  • trunk/Source/WebKit/UIProcess/API/C/WKContextConfigurationRef.h

    r232531 r238525  
    7272WK_EXPORT void WKContextConfigurationSetProcessSwapsOnNavigation(WKContextConfigurationRef configuration, bool swaps);
    7373
     74WK_EXPORT bool WKContextConfigurationPrewarmsProcessesAutomatically(WKContextConfigurationRef configuration);
     75WK_EXPORT void WKContextConfigurationSetPrewarmsProcessesAutomatically(WKContextConfigurationRef configuration, bool prewarms);
     76
    7477WK_EXPORT bool WKContextConfigurationAlwaysKeepAndReuseSwappedProcesses(WKContextConfigurationRef configuration);
    7578WK_EXPORT void WKContextConfigurationSetAlwaysKeepAndReuseSwappedProcesses(WKContextConfigurationRef configuration, bool keepAndReuse);
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r238330 r238525  
    12861286void WebProcessPool::didReachGoodTimeToPrewarm()
    12871287{
    1288     if (!configuration().isAutomaticProcessWarmingEnabled())
     1288    if (!configuration().isAutomaticProcessWarmingEnabled() || !configuration().processSwapsOnNavigation())
    12891289        return;
    12901290
     
    21142114    auto process = processForNavigationInternal(page, navigation, processSwapRequestedByClient, reason);
    21152115
     2116    // We are process-swapping so automatic process prewarming would be beneficial if the client has not explicitly enabled / disabled it.
     2117    bool doingAnAutomaticProcessSwap = processSwapRequestedByClient == ProcessSwapRequestedByClient::No && process.ptr() != &page.process();
     2118    if (doingAnAutomaticProcessSwap && !configuration().wasAutomaticProcessWarmingSetByClient() && !configuration().clientWouldBenefitFromAutomaticProcessPrewarming()) {
     2119        RELEASE_LOG(PerformanceLogging, "Automatically turning on process prewarming because the client would benefit from it");
     2120        configuration().setClientWouldBenefitFromAutomaticProcessPrewarming(true);
     2121    }
     2122
    21162123    if (m_configuration->alwaysKeepAndReuseSwappedProcesses() && process.ptr() != &page.process()) {
    21172124        static std::once_flag onceFlag;
Note: See TracChangeset for help on using the changeset viewer.