Title: [229894] trunk/Source/WTF
- Revision
- 229894
- Author
- [email protected]
- Date
- 2018-03-23 05:41:44 -0700 (Fri, 23 Mar 2018)
Log Message
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: trunk/Source/WTF/ChangeLog (229893 => 229894)
--- trunk/Source/WTF/ChangeLog 2018-03-23 12:34:08 UTC (rev 229893)
+++ trunk/Source/WTF/ChangeLog 2018-03-23 12:41:44 UTC (rev 229894)
@@ -1,3 +1,25 @@
+2018-03-23 Carlos Alberto Lopez Perez <[email protected]>
+
+ 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-23 Yusuke Suzuki <[email protected]>
[WTF] Add standard containers with FastAllocator specialization
Modified: trunk/Source/WTF/wtf/MemoryPressureHandler.cpp (229893 => 229894)
--- trunk/Source/WTF/wtf/MemoryPressureHandler.cpp 2018-03-23 12:34:08 UTC (rev 229893)
+++ trunk/Source/WTF/wtf/MemoryPressureHandler.cpp 2018-03-23 12:41:44 UTC (rev 229894)
@@ -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
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes