Title: [285077] trunk/Source/WebKit
Revision
285077
Author
lmo...@igalia.com
Date
2021-10-29 23:28:57 -0700 (Fri, 29 Oct 2021)

Log Message

[GLIB][SOUP] Unify memoryPressureMonitorDisabled implementation
https://bugs.webkit.org/show_bug.cgi?id=232519

Reviewed by Carlos Garcia Campos.

Covered by existing tests.

Follow up the fix of r285062, to avoid having two copies of
the same function around.

* UIProcess/glib/WebProcessPoolGLib.cpp:
(WebKit::WebProcessPool::platformInitialize):
(WebKit::WebProcessPool::platformInitializeWebProcess):
(WebKit::memoryPressureMonitorDisabled): Deleted.
* UIProcess/linux/MemoryPressureMonitor.cpp:
(WebKit::MemoryPressureMonitor::disabled):
* UIProcess/linux/MemoryPressureMonitor.h:
* UIProcess/soup/WebProcessPoolSoup.cpp:
(WebKit::WebProcessPool::platformInitializeNetworkProcess):
(WebKit::memoryPressureMonitorDisabledSoup): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (285076 => 285077)


--- trunk/Source/WebKit/ChangeLog	2021-10-30 05:25:59 UTC (rev 285076)
+++ trunk/Source/WebKit/ChangeLog	2021-10-30 06:28:57 UTC (rev 285077)
@@ -1,3 +1,26 @@
+2021-10-29  Lauro Moura  <lmo...@igalia.com>
+
+        [GLIB][SOUP] Unify memoryPressureMonitorDisabled implementation
+        https://bugs.webkit.org/show_bug.cgi?id=232519
+
+        Reviewed by Carlos Garcia Campos.
+
+        Covered by existing tests.
+
+        Follow up the fix of r285062, to avoid having two copies of
+        the same function around.
+
+        * UIProcess/glib/WebProcessPoolGLib.cpp:
+        (WebKit::WebProcessPool::platformInitialize):
+        (WebKit::WebProcessPool::platformInitializeWebProcess):
+        (WebKit::memoryPressureMonitorDisabled): Deleted.
+        * UIProcess/linux/MemoryPressureMonitor.cpp:
+        (WebKit::MemoryPressureMonitor::disabled):
+        * UIProcess/linux/MemoryPressureMonitor.h:
+        * UIProcess/soup/WebProcessPoolSoup.cpp:
+        (WebKit::WebProcessPool::platformInitializeNetworkProcess):
+        (WebKit::memoryPressureMonitorDisabledSoup): Deleted.
+
 2021-10-29  Tim Horton  <timothy_hor...@apple.com>
 
         Add release logging of display list size to CGDisplayListImageBufferBackend

Modified: trunk/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp (285076 => 285077)


--- trunk/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp	2021-10-30 05:25:59 UTC (rev 285076)
+++ trunk/Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp	2021-10-30 06:28:57 UTC (rev 285077)
@@ -29,6 +29,7 @@
 #include "WebProcessPool.h"
 
 #include "LegacyGlobalSettings.h"
+#include "MemoryPressureMonitor.h"
 #include "WebMemoryPressureHandler.h"
 #include "WebProcessCreationParameters.h"
 #include <WebCore/PlatformDisplay.h>
@@ -52,12 +53,6 @@
 
 namespace WebKit {
 
-static bool memoryPressureMonitorDisabled()
-{
-    static const char* disableMemoryPressureMonitor = getenv("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR");
-    return disableMemoryPressureMonitor && !strcmp(disableMemoryPressureMonitor, "1");
-}
-
 void WebProcessPool::platformInitialize()
 {
 #if PLATFORM(GTK)
@@ -66,7 +61,7 @@
     if (const char* forceComplexText = getenv("WEBKIT_FORCE_COMPLEX_TEXT"))
         m_alwaysUsesComplexTextCodePath = !strcmp(forceComplexText, "1");
 
-    if (!memoryPressureMonitorDisabled())
+    if (!MemoryPressureMonitor::disabled())
         installMemoryPressureHandler();
 }
 
@@ -97,7 +92,7 @@
 
     parameters.memoryCacheDisabled = m_memoryCacheDisabled || LegacyGlobalSettings::singleton().cacheModel() == CacheModel::DocumentViewer;
 
-    if (memoryPressureMonitorDisabled())
+    if (MemoryPressureMonitor::disabled())
         parameters.shouldSuppressMemoryPressureHandler = true;
 
 #if USE(GSTREAMER)

Modified: trunk/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.cpp (285076 => 285077)


--- trunk/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.cpp	2021-10-30 05:25:59 UTC (rev 285076)
+++ trunk/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.cpp	2021-10-30 06:28:57 UTC (rev 285077)
@@ -29,6 +29,7 @@
 #if OS(LINUX)
 
 #include "WebProcessPool.h"
+#include <mutex>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -389,6 +390,18 @@
     })->detach();
 }
 
+bool MemoryPressureMonitor::s_disabled = false;
+
+bool MemoryPressureMonitor::disabled()
+{
+    static std::once_flag flag;
+    std::call_once(flag, []() {
+        auto envvar = getenv("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR");
+        s_disabled = envvar && !strcmp(envvar, "1");
+    });
+    return s_disabled;
+}
+
 void CGroupMemoryController::setMemoryControllerPath(CString memoryControllerPath)
 {
     if (memoryControllerPath == m_cgroupMemoryControllerPath)

Modified: trunk/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.h (285076 => 285077)


--- trunk/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.h	2021-10-30 05:25:59 UTC (rev 285076)
+++ trunk/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.h	2021-10-30 06:28:57 UTC (rev 285077)
@@ -43,6 +43,7 @@
 public:
     static MemoryPressureMonitor& singleton();
     void start();
+    static bool disabled();
 
     ~MemoryPressureMonitor();
 
@@ -49,6 +50,7 @@
 private:
     MemoryPressureMonitor() = default;
     bool m_started { false };
+    static bool s_disabled;
 };
 
 class CGroupMemoryController {

Modified: trunk/Source/WebKit/UIProcess/soup/WebProcessPoolSoup.cpp (285076 => 285077)


--- trunk/Source/WebKit/UIProcess/soup/WebProcessPoolSoup.cpp	2021-10-30 05:25:59 UTC (rev 285076)
+++ trunk/Source/WebKit/UIProcess/soup/WebProcessPoolSoup.cpp	2021-10-30 06:28:57 UTC (rev 285077)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "WebProcessPool.h"
 
+#include "MemoryPressureMonitor.h"
 #include "NetworkProcessCreationParameters.h"
 #include "NetworkProcessMessages.h"
 #include "WebCookieManagerProxy.h"
@@ -37,20 +38,12 @@
 
 std::optional<MemoryPressureHandler::Configuration> WebProcessPool::s_networkProcessMemoryPressureHandlerConfiguration;
 
-// This is duplicate code with memoryPressureMonitorDisabled.
-// FIXME: Put a declaration in a header and make one definition.
-static bool memoryPressureMonitorDisabledSoup()
-{
-    static const char* disableMemoryPressureMonitor = getenv("WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR");
-    return disableMemoryPressureMonitor && !strcmp(disableMemoryPressureMonitor, "1");
-}
-
 void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationParameters& parameters)
 {
     parameters.languages = userPreferredLanguages();
     parameters.memoryPressureHandlerConfiguration = s_networkProcessMemoryPressureHandlerConfiguration;
 
-    if (memoryPressureMonitorDisabledSoup())
+    if (MemoryPressureMonitor::disabled())
         parameters.shouldSuppressMemoryPressureHandler = true;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to