Title: [230413] releases/WebKitGTK/webkit-2.20/Source/WTF
Revision
230413
Author
carlo...@webkit.org
Date
2018-04-09 05:59:23 -0700 (Mon, 09 Apr 2018)

Log Message

Merge r229894 - WebProcess memory monitor thresholds should be better tuned for embedded systems.
https://bugs.webkit.org/show_bug.cgi?id=183773

Reviewed by Yusuke Suzuki.

Take into account the total system RAM for the thresholds calculation.

For systems with more than 3GB the conservative and strict thresholds remain as they are,
but for systems with less RAM the thresholds are dynamically configured as follows:

- Conservative threshold (release non critical memory) if WebProcess using more than 33% of the total RAM.
- Strict threshold (release all possible memory) if WebProcess using more than 50% of the total RAM.

The Kill threshold is also modified. Now it is capped at 90% of the total RAM.

* wtf/MemoryPressureHandler.cpp:
(WTF::thresholdForMemoryKillWithProcessState):
(WTF::thresholdForPolicy):
(WTF::MemoryPressureHandler::shrinkOrDie):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.20/Source/WTF/ChangeLog (230412 => 230413)


--- releases/WebKitGTK/webkit-2.20/Source/WTF/ChangeLog	2018-04-09 12:59:18 UTC (rev 230412)
+++ releases/WebKitGTK/webkit-2.20/Source/WTF/ChangeLog	2018-04-09 12:59:23 UTC (rev 230413)
@@ -1,3 +1,25 @@
+2018-03-23  Carlos Alberto Lopez Perez  <clo...@igalia.com>
+
+        WebProcess memory monitor thresholds should be better tuned for embedded systems.
+        https://bugs.webkit.org/show_bug.cgi?id=183773
+
+        Reviewed by Yusuke Suzuki.
+
+        Take into account the total system RAM for the thresholds calculation.
+
+        For systems with more than 3GB the conservative and strict thresholds remain as they are,
+        but for systems with less RAM the thresholds are dynamically configured as follows:
+
+        - Conservative threshold (release non critical memory) if WebProcess using more than 33% of the total RAM.
+        - Strict threshold (release all possible memory) if WebProcess using more than 50% of the total RAM.
+
+        The Kill threshold is also modified. Now it is capped at 90% of the total RAM.
+
+        * wtf/MemoryPressureHandler.cpp:
+        (WTF::thresholdForMemoryKillWithProcessState):
+        (WTF::thresholdForPolicy):
+        (WTF::MemoryPressureHandler::shrinkOrDie):
+
 2018-03-08  Zan Dobersek  <zdober...@igalia.com>
 
         [GLib] RunLoop::wakeUp(): use a zero value instead of the monotonic time

Modified: releases/WebKitGTK/webkit-2.20/Source/WTF/wtf/MemoryPressureHandler.cpp (230412 => 230413)


--- releases/WebKitGTK/webkit-2.20/Source/WTF/wtf/MemoryPressureHandler.cpp	2018-04-09 12:59:18 UTC (rev 230412)
+++ releases/WebKitGTK/webkit-2.20/Source/WTF/wtf/MemoryPressureHandler.cpp	2018-04-09 12:59:23 UTC (rev 230413)
@@ -28,6 +28,7 @@
 
 #include <wtf/MemoryFootprint.h>
 #include <wtf/NeverDestroyed.h>
+#include <wtf/RAMSize.h>
 
 #define LOG_CHANNEL_PREFIX Log
 
@@ -84,20 +85,17 @@
 
 static size_t thresholdForMemoryKillWithProcessState(WebsamProcessState processState, unsigned tabCount)
 {
+    size_t baseThreshold = 2 * GB;
 #if CPU(X86_64) || CPU(ARM64)
-    size_t baseThreshold;
     if (processState == WebsamProcessState::Active)
         baseThreshold = 4 * GB;
-    else
-        baseThreshold = 2 * GB;
-    if (tabCount <= 1)
-        return baseThreshold;
-    return baseThreshold + (std::min(tabCount - 1, 4u) * 1 * GB);
+    if (tabCount > 1)
+        baseThreshold += std::min(tabCount - 1, 4u) * 1 * GB;
 #else
-    UNUSED_PARAM(processState);
-    UNUSED_PARAM(tabCount);
-    return 3 * GB;
+    if ((tabCount > 1) || (processState == WebsamProcessState::Active))
+        baseThreshold = 3 * GB;
 #endif
+    return std::min(baseThreshold, static_cast<size_t>(ramSize() * 0.9));
 }
 
 void MemoryPressureHandler::setPageCount(unsigned pageCount)
@@ -114,11 +112,12 @@
 
 static size_t thresholdForPolicy(MemoryUsagePolicy policy)
 {
+    const size_t baseThresholdForPolicy = std::min(3 * GB, ramSize());
     switch (policy) {
     case MemoryUsagePolicy::Conservative:
-        return 1 * GB;
+        return baseThresholdForPolicy / 3;
     case MemoryUsagePolicy::Strict:
-        return 1.5 * GB;
+        return baseThresholdForPolicy / 2;
     case MemoryUsagePolicy::Unrestricted:
     default:
         ASSERT_NOT_REACHED();
@@ -150,6 +149,7 @@
         return;
     }
 
+    WTFLogAlways("Unable to shrink memory footprint of process (%lu MB) below the kill thresold (%lu MB). Killed\n", footprint.value() / MB, thresholdForMemoryKill() / MB);
     RELEASE_ASSERT(m_memoryKillCallback);
     m_memoryKillCallback();
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to