[webkit-changes] [WebKit/WebKit] 572ff9: Suspend processes aggressively on critical memory ...
bnham
noreply at github.com
Fri Oct 18 12:53:27 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 572ff90b0bbd4ec0a5be3e7e2c3664907de70d5f
https://github.com/WebKit/WebKit/commit/572ff90b0bbd4ec0a5be3e7e2c3664907de70d5f
Author: Ben Nham <nham at apple.com>
Date: 2024-10-18 (Fri, 18 Oct 2024)
Changed paths:
M Source/WTF/wtf/MemoryPressureHandler.h
M Source/WTF/wtf/PlatformEnableCocoa.h
M Source/WTF/wtf/WeakHashSet.h
M Source/WebKit/Scripts/webkit/messages.py
M Source/WebKit/Shared/WTFArgumentCoders.serialization.in
M Source/WebKit/UIProcess/API/APIPageConfiguration.h
M Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp
M Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h
M Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm
M Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h
M Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h
M Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm
M Source/WebKit/UIProcess/ProcessThrottler.cpp
M Source/WebKit/UIProcess/ProcessThrottler.h
M Source/WebKit/UIProcess/WebPageProxy.cpp
M Source/WebKit/UIProcess/WebPageProxy.h
M Source/WebKit/UIProcess/WebProcessActivityState.cpp
M Source/WebKit/UIProcess/WebProcessActivityState.h
M Source/WebKit/UIProcess/WebProcessPool.cpp
M Source/WebKit/UIProcess/WebProcessPool.h
M Source/WebKit/UIProcess/WebProcessProxy.cpp
M Source/WebKit/UIProcess/WebProcessProxy.h
M Source/WebKit/UIProcess/WebProcessProxy.messages.in
M Source/WebKit/WebProcess/WebProcess.cpp
Log Message:
-----------
Suspend processes aggressively on critical memory pressure
https://bugs.webkit.org/show_bug.cgi?id=281702
rdar://problem/138150321
Reviewed by Chris Dumez.
When the system is under critical memory pressure, we should lower the suspension interval of
WebContent processes for some period of time to help alleviate pressure on the system. In this patch
we lower the suspension interval to 10 seconds for 30 minutes after critical memory pressure is
detected, although those values might have to be tuned. This is disabled by default and enabled by a
process pool configuration preference.
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebProcessActivityState.cpp:
(WebKit::webProcessSuspensionDelay):
(WebKit::WebProcessActivityState::updateWebProcessSuspensionDelay):
* Source/WebKit/UIProcess/WebProcessActivityState.h:
* Source/WebKit/UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::memoryPressureStatusChanged):
(WebKit::WebProcessProxy::updateWebProcessSuspensionDelay):
(WebKit::operator<<):
* Source/WebKit/UIProcess/WebProcessProxy.h:
* Source/WebKit/UIProcess/WebProcessProxy.messages.in:
* Source/WebKit/WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::m_checkMemoryPressureStatusTimer):
(WebKit::criticalMemoryPressureCheckInterval):
(WebKit::WebProcessPool::checkMemoryPressureStatus):
(WebKit::WebProcessPool::defaultWebProcessSuspensionDelay):
(WebKit::WebProcessPool::webProcessSuspensionDelay const):
(WebKit::WebProcessPool::memoryPressureStatusChangedForProcess):
(WebKit::WebProcessPool::updateWebProcessSuspensionDelay):
(WebKit::WebProcessPool::updateWebProcessSuspensionDelayWithPacing):
* Source/WebKit/UIProcess/WebProcessPool.h:
When a WebProcess gets a critical memory pressure notification, forward it to the associated
WebProcessPool in UIProcess. The WebProcessPool will then ask all WebProcesses to suspend quickly
until 30 minutes have elapsed with the system in a non-critical pressure state.
We detect the pressure change in WebProcess rather than in UIProcess (e.g. via MemoryPressureHandler
in UIProcess) because the kernel paces memory pressure notifications. Due to the high jetsam
priority of the UIProcess, a long period can elapse between the system experiencing critical pressure
and the UIProcess learning about the issue.
* Source/WTF/wtf/WeakHashSet.h:
Add a cast to the templated type for takeAny. We already have a similar cast in the iterator. This
is necessary for WeakHashSet<WebProcessProxy>::takeAny to work, since WebProcessProxy defines a
custom WeakValueType.
* Source/WebKit/UIProcess/API/APIPageConfiguration.h:
(API::PageConfiguration::webProcessSuspensionDelay const): Deleted.
(API::PageConfiguration::setWebProcessSuspensionDelay): Deleted.
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration _webProcessSuspensionDelay]): Deleted.
(-[WKWebViewConfiguration _setWebProcessSuspensionDelay:]): Deleted.
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
Remove webProcessSuspensionDelay as a per-page preference as that was only used for debugging
purposes. We just read these values directly in WebProcessPool via CFPreferences instead. That is
sufficient for debugging purposes without exposing this API surface. This doesn't break any clients
since only Safari was using it behind a -respondsToSelector: check.
* Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp:
(API::ProcessPoolConfiguration::copy):
* Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
(-[_WKProcessPoolConfiguration suspendsWebProcessesAggressivelyOnCriticalMemoryPressure]):
(-[_WKProcessPoolConfiguration setSuspendsWebProcessesAggressivelyOnCriticalMemoryPressure:]):
Allow clients to enable aggressive suspension on critical memory pressure via a process pool config
value, which defaults to false.
* Source/WebKit/UIProcess/ProcessThrottler.cpp:
(WebKit::ProcessThrottlerTimedActivity::ProcessThrottlerTimedActivity):
(WebKit::ProcessThrottlerTimedActivity::activityTimedOut):
(WebKit::ProcessThrottlerTimedActivity::setTimeout):
* Source/WebKit/UIProcess/ProcessThrottler.h:
Allow clients to change the timeout for a timed activity after it is created.
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::updateWebProcessSuspensionDelay):
(WebKit::WebPageProxy::resetStateAfterProcessTermination):
Stop logging the diagnostic key that depended on WebProcessProxy::isUnderMemoryPressure as it's not
used anymore. If we want something like this, then we should log this using the memory limit logging
that we added in 275198 at main (which is only enabled on Mac for now.)
* Source/WTF/wtf/MemoryPressureHandler.h:
(WTF::MemoryPressureHandler::memoryPressureStatus const):
* Source/WTF/wtf/PlatformEnableCocoa.h:
* Source/WebKit/Scripts/webkit/messages.py:
(headers_for_type):
* Source/WebKit/Shared/WTFArgumentCoders.serialization.in:
Canonical link: https://commits.webkit.org/285426@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list