Title: [276305] trunk/Source
Revision
276305
Author
[email protected]
Date
2021-04-20 08:45:09 -0700 (Tue, 20 Apr 2021)

Log Message

Make sure we don't exit the GPUProcess too frequently while under memory pressure
https://bugs.webkit.org/show_bug.cgi?id=224798

Reviewed by Darin Adler.

Source/WebKit:

We've recently started to exit the GPUProcess if idle and under memory pressure, in order
to save memory. This is great but we wouldn't want to repeatedly exit and relaunch the
GPUProcess while under memory pressure either. To address this, I am adding a condition to
GPUProcess::canExitUnderMemoryPressure() to make sure we don't exit the GPUProcess if it's
been running for less than 5 seconds.

To avoid generating flakiness in our benchmarks and API tests, I am disabling this condition
if the memory pressure is simulated (via `notifyutil -p org.WebKit.lowMemory`).

* GPUProcess/GPUProcess.cpp:
(WebKit::GPUProcess::canExitUnderMemoryPressure const):
* GPUProcess/GPUProcess.h:

Source/WTF:

Add member function to the MemoryPressureHandler to indicate if we're currently simulating memory
pressure or not.

* wtf/MemoryPressureHandler.h:
(WTF::MemoryPressureHandler::isSimulatingMemoryPressure const):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (276304 => 276305)


--- trunk/Source/WTF/ChangeLog	2021-04-20 14:51:52 UTC (rev 276304)
+++ trunk/Source/WTF/ChangeLog	2021-04-20 15:45:09 UTC (rev 276305)
@@ -1,3 +1,16 @@
+2021-04-20  Chris Dumez  <[email protected]>
+
+        Make sure we don't exit the GPUProcess too frequently while under memory pressure
+        https://bugs.webkit.org/show_bug.cgi?id=224798
+
+        Reviewed by Darin Adler.
+
+        Add member function to the MemoryPressureHandler to indicate if we're currently simulating memory
+        pressure or not.
+
+        * wtf/MemoryPressureHandler.h:
+        (WTF::MemoryPressureHandler::isSimulatingMemoryPressure const):
+
 2021-04-19  Darin Adler  <[email protected]>
 
         Refactor sorted array mapping machinery in LocaleToScriptMapping.cpp for reuse elsewhere

Modified: trunk/Source/WTF/wtf/MemoryPressureHandler.h (276304 => 276305)


--- trunk/Source/WTF/wtf/MemoryPressureHandler.h	2021-04-20 14:51:52 UTC (rev 276304)
+++ trunk/Source/WTF/wtf/MemoryPressureHandler.h	2021-04-20 15:45:09 UTC (rev 276305)
@@ -91,6 +91,7 @@
 #endif
             || m_isSimulatingMemoryPressure;
     }
+    bool isSimulatingMemoryPressure() const { return m_isSimulatingMemoryPressure; }
     void setUnderMemoryPressure(bool);
 
     WTF_EXPORT_PRIVATE static MemoryUsagePolicy currentMemoryUsagePolicy();

Modified: trunk/Source/WebKit/ChangeLog (276304 => 276305)


--- trunk/Source/WebKit/ChangeLog	2021-04-20 14:51:52 UTC (rev 276304)
+++ trunk/Source/WebKit/ChangeLog	2021-04-20 15:45:09 UTC (rev 276305)
@@ -1,5 +1,25 @@
 2021-04-20  Chris Dumez  <[email protected]>
 
+        Make sure we don't exit the GPUProcess too frequently while under memory pressure
+        https://bugs.webkit.org/show_bug.cgi?id=224798
+
+        Reviewed by Darin Adler.
+
+        We've recently started to exit the GPUProcess if idle and under memory pressure, in order
+        to save memory. This is great but we wouldn't want to repeatedly exit and relaunch the
+        GPUProcess while under memory pressure either. To address this, I am adding a condition to
+        GPUProcess::canExitUnderMemoryPressure() to make sure we don't exit the GPUProcess if it's
+        been running for less than 5 seconds.
+
+        To avoid generating flakiness in our benchmarks and API tests, I am disabling this condition
+        if the memory pressure is simulated (via `notifyutil -p org.WebKit.lowMemory`).
+
+        * GPUProcess/GPUProcess.cpp:
+        (WebKit::GPUProcess::canExitUnderMemoryPressure const):
+        * GPUProcess/GPUProcess.h:
+
+2021-04-20  Chris Dumez  <[email protected]>
+
         Unreviewed, reverting r276271.
 
         It did not fix the Canvas-Arcs subtest on the bots

Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.cpp (276304 => 276305)


--- trunk/Source/WebKit/GPUProcess/GPUProcess.cpp	2021-04-20 14:51:52 UTC (rev 276304)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.cpp	2021-04-20 15:45:09 UTC (rev 276305)
@@ -129,6 +129,12 @@
 bool GPUProcess::canExitUnderMemoryPressure() const
 {
     ASSERT(isMainRunLoop());
+    // To avoid exiting the GPUProcess too aggressively while under memory pressure, we don't exit if we've been running
+    // for less than 5 seconds. In case of simulated memory pressure, we ignore this rule to avoid generating flakiness
+    // in our benchmarks and tests.
+    if ((MonotonicTime::now() - m_creationTime) < 5_s && !MemoryPressureHandler::singleton().isSimulatingMemoryPressure())
+        return false;
+
     for (auto& webProcessConnection : m_webProcessConnections.values()) {
         if (!webProcessConnection->allowsExitUnderMemoryPressure())
             return false;

Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.h (276304 => 276305)


--- trunk/Source/WebKit/GPUProcess/GPUProcess.h	2021-04-20 14:51:52 UTC (rev 276304)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.h	2021-04-20 15:45:09 UTC (rev 276305)
@@ -33,6 +33,7 @@
 #include <pal/SessionID.h>
 #include <wtf/Function.h>
 #include <wtf/MemoryPressureHandler.h>
+#include <wtf/MonotonicTime.h>
 #include <wtf/WeakPtr.h>
 
 #if PLATFORM(MAC)
@@ -149,6 +150,7 @@
 
     // Connections to WebProcesses.
     HashMap<WebCore::ProcessIdentifier, Ref<GPUConnectionToWebProcess>> m_webProcessConnections;
+    MonotonicTime m_creationTime { MonotonicTime::now() };
 
 #if ENABLE(MEDIA_STREAM)
     struct MediaCaptureAccess {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to