Title: [218669] trunk/Source
- Revision
- 218669
- Author
- [email protected]
- Date
- 2017-06-21 18:09:26 -0700 (Wed, 21 Jun 2017)
Log Message
Increase memory kill limits for WebContent processes that manage multiple tabs.
https://bugs.webkit.org/show_bug.cgi?id=173674
Reviewed by Geoffrey Garen.
Source/WebCore:
Plumb the non-utility Page count down to WTF::MemoryPressureHandler.
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::~Page):
Source/WTF:
When opening <a target=_blank> links, we currently have to use the same WebContent
process for the new tab, to support scripting the window.opener object.
This means that some WebContent processes end up hosting multiple tabs, making it
more likely that those processes will hit the memory limits.
Address this by adding some additional allowance for multi-tab processes:
For each additional tab, up to 4 tabs, add 1GB to the memory kill limit.
* wtf/MemoryPressureHandler.cpp:
(WTF::thresholdForMemoryKillWithProcessState):
(WTF::MemoryPressureHandler::setTabCount):
(WTF::MemoryPressureHandler::thresholdForMemoryKill):
(WTF::MemoryPressureHandler::measurementTimerFired):
* wtf/MemoryPressureHandler.h:
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (218668 => 218669)
--- trunk/Source/WTF/ChangeLog 2017-06-22 00:56:02 UTC (rev 218668)
+++ trunk/Source/WTF/ChangeLog 2017-06-22 01:09:26 UTC (rev 218669)
@@ -1,3 +1,26 @@
+2017-06-21 Andreas Kling <[email protected]>
+
+ Increase memory kill limits for WebContent processes that manage multiple tabs.
+ https://bugs.webkit.org/show_bug.cgi?id=173674
+
+ Reviewed by Geoffrey Garen.
+
+ When opening <a target=_blank> links, we currently have to use the same WebContent
+ process for the new tab, to support scripting the window.opener object.
+ This means that some WebContent processes end up hosting multiple tabs, making it
+ more likely that those processes will hit the memory limits.
+
+ Address this by adding some additional allowance for multi-tab processes:
+
+ For each additional tab, up to 4 tabs, add 1GB to the memory kill limit.
+
+ * wtf/MemoryPressureHandler.cpp:
+ (WTF::thresholdForMemoryKillWithProcessState):
+ (WTF::MemoryPressureHandler::setTabCount):
+ (WTF::MemoryPressureHandler::thresholdForMemoryKill):
+ (WTF::MemoryPressureHandler::measurementTimerFired):
+ * wtf/MemoryPressureHandler.h:
+
2017-06-21 Chris Dumez <[email protected]>
Allow constructing a WTF:Function from a function pointer
Modified: trunk/Source/WTF/wtf/MemoryPressureHandler.cpp (218668 => 218669)
--- trunk/Source/WTF/wtf/MemoryPressureHandler.cpp 2017-06-22 00:56:02 UTC (rev 218668)
+++ trunk/Source/WTF/wtf/MemoryPressureHandler.cpp 2017-06-22 01:09:26 UTC (rev 218669)
@@ -81,21 +81,34 @@
}
#endif
-static size_t thresholdForMemoryKillWithProcessState(WebsamProcessState processState)
+static size_t thresholdForMemoryKillWithProcessState(WebsamProcessState processState, unsigned tabCount)
{
#if CPU(X86_64) || CPU(ARM64)
+ size_t baseThreshold;
if (processState == WebsamProcessState::Active)
- return 4 * GB;
- return 2 * GB;
+ baseThreshold = 4 * GB;
+ else
+ baseThreshold = 2 * GB;
+ if (tabCount <= 1)
+ return baseThreshold;
+ return baseThreshold + (std::min(tabCount - 1, 4u) * 1 * GB);
#else
UNUSED_PARAM(processState);
+ UNUSED_PARAM(tabCount);
return 3 * GB;
#endif
}
+void MemoryPressureHandler::setTabCount(unsigned tabCount)
+{
+ if (singleton().m_tabCount == tabCount)
+ return;
+ singleton().m_tabCount = tabCount;
+}
+
size_t MemoryPressureHandler::thresholdForMemoryKill()
{
- return thresholdForMemoryKillWithProcessState(m_processState);
+ return thresholdForMemoryKillWithProcessState(m_processState, m_tabCount);
}
static size_t thresholdForPolicy(MemoryUsagePolicy policy)
@@ -176,7 +189,7 @@
break;
}
- if (processState() == WebsamProcessState::Active && footprint.value() > thresholdForMemoryKillWithProcessState(WebsamProcessState::Inactive))
+ if (processState() == WebsamProcessState::Active && footprint.value() > thresholdForMemoryKillWithProcessState(WebsamProcessState::Inactive, m_tabCount))
doesExceedInactiveLimitWhileActive();
else
doesNotExceedInactiveLimitWhileActive();
Modified: trunk/Source/WTF/wtf/MemoryPressureHandler.h (218668 => 218669)
--- trunk/Source/WTF/wtf/MemoryPressureHandler.h 2017-06-22 00:56:02 UTC (rev 218668)
+++ trunk/Source/WTF/wtf/MemoryPressureHandler.h 2017-06-22 01:09:26 UTC (rev 218669)
@@ -147,6 +147,8 @@
WTF_EXPORT_PRIVATE void setProcessState(WebsamProcessState);
WebsamProcessState processState() const { return m_processState; }
+ WTF_EXPORT_PRIVATE static void setTabCount(unsigned);
+
private:
size_t thresholdForMemoryKill();
void memoryPressureStatusChanged();
@@ -190,6 +192,8 @@
WebsamProcessState m_processState { WebsamProcessState::Inactive };
+ unsigned m_tabCount { 0 };
+
bool m_installed { false };
LowMemoryHandler m_lowMemoryHandler;
Modified: trunk/Source/WebCore/ChangeLog (218668 => 218669)
--- trunk/Source/WebCore/ChangeLog 2017-06-22 00:56:02 UTC (rev 218668)
+++ trunk/Source/WebCore/ChangeLog 2017-06-22 01:09:26 UTC (rev 218669)
@@ -1,3 +1,16 @@
+2017-06-21 Andreas Kling <[email protected]>
+
+ Increase memory kill limits for WebContent processes that manage multiple tabs.
+ https://bugs.webkit.org/show_bug.cgi?id=173674
+
+ Reviewed by Geoffrey Garen.
+
+ Plumb the non-utility Page count down to WTF::MemoryPressureHandler.
+
+ * page/Page.cpp:
+ (WebCore::Page::Page):
+ (WebCore::Page::~Page):
+
2017-06-21 Jiewen Tan <[email protected]>
[WebCrypto] Restore ordering of CryptoAlgorithmIdentifier in SerializedScriptValue
Modified: trunk/Source/WebCore/page/Page.cpp (218668 => 218669)
--- trunk/Source/WebCore/page/Page.cpp 2017-06-22 00:56:02 UTC (rev 218668)
+++ trunk/Source/WebCore/page/Page.cpp 2017-06-22 01:09:26 UTC (rev 218669)
@@ -287,8 +287,10 @@
ASSERT(!allPages->contains(this));
allPages->add(this);
- if (!isUtilityPage())
+ if (!isUtilityPage()) {
++nonUtilityPageCount;
+ MemoryPressureHandler::setTabCount(nonUtilityPageCount);
+ }
#ifndef NDEBUG
pageCounter.increment();
@@ -314,8 +316,10 @@
m_mainFrame->setView(nullptr);
setGroupName(String());
allPages->remove(this);
- if (!isUtilityPage())
+ if (!isUtilityPage()) {
--nonUtilityPageCount;
+ MemoryPressureHandler::setTabCount(nonUtilityPageCount);
+ }
m_settings->pageDestroyed();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes