Changeset 229894 in webkit


Ignore:
Timestamp:
Mar 23, 2018 5:41:44 AM (6 years ago)
Author:
clopez@igalia.com
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):

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r229893 r229894  
     12018-03-23  Carlos Alberto Lopez Perez  <clopez@igalia.com>
     2
     3        WebProcess memory monitor thresholds should be better tuned for embedded systems.
     4        https://bugs.webkit.org/show_bug.cgi?id=183773
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        Take into account the total system RAM for the thresholds calculation.
     9
     10        For systems with more than 3GB the conservative and strict thresholds remain as they are,
     11        but for systems with less RAM the thresholds are dynamically configured as follows:
     12
     13        - Conservative threshold (release non critical memory) if WebProcess using more than 33% of the total RAM.
     14        - Strict threshold (release all possible memory) if WebProcess using more than 50% of the total RAM.
     15
     16        The Kill threshold is also modified. Now it is capped at 90% of the total RAM.
     17
     18        * wtf/MemoryPressureHandler.cpp:
     19        (WTF::thresholdForMemoryKillWithProcessState):
     20        (WTF::thresholdForPolicy):
     21        (WTF::MemoryPressureHandler::shrinkOrDie):
     22
    1232018-03-23  Yusuke Suzuki  <utatane.tea@gmail.com>
    224
  • trunk/Source/WTF/wtf/MemoryPressureHandler.cpp

    r229195 r229894  
    2929#include <wtf/MemoryFootprint.h>
    3030#include <wtf/NeverDestroyed.h>
     31#include <wtf/RAMSize.h>
    3132
    3233#define LOG_CHANNEL_PREFIX Log
     
    8586static size_t thresholdForMemoryKillWithProcessState(WebsamProcessState processState, unsigned tabCount)
    8687{
     88    size_t baseThreshold = 2 * GB;
    8789#if CPU(X86_64) || CPU(ARM64)
    88     size_t baseThreshold;
    8990    if (processState == WebsamProcessState::Active)
    9091        baseThreshold = 4 * GB;
    91     else
    92         baseThreshold = 2 * GB;
    93     if (tabCount <= 1)
    94         return baseThreshold;
    95     return baseThreshold + (std::min(tabCount - 1, 4u) * 1 * GB);
     92    if (tabCount > 1)
     93        baseThreshold += std::min(tabCount - 1, 4u) * 1 * GB;
    9694#else
    97     UNUSED_PARAM(processState);
    98     UNUSED_PARAM(tabCount);
    99     return 3 * GB;
    100 #endif
     95    if ((tabCount > 1) || (processState == WebsamProcessState::Active))
     96        baseThreshold = 3 * GB;
     97#endif
     98    return std::min(baseThreshold, static_cast<size_t>(ramSize() * 0.9));
    10199}
    102100
     
    115113static size_t thresholdForPolicy(MemoryUsagePolicy policy)
    116114{
     115    const size_t baseThresholdForPolicy = std::min(3 * GB, ramSize());
    117116    switch (policy) {
    118117    case MemoryUsagePolicy::Conservative:
    119         return 1 * GB;
     118        return baseThresholdForPolicy / 3;
    120119    case MemoryUsagePolicy::Strict:
    121         return 1.5 * GB;
     120        return baseThresholdForPolicy / 2;
    122121    case MemoryUsagePolicy::Unrestricted:
    123122    default:
     
    151150    }
    152151
     152    WTFLogAlways("Unable to shrink memory footprint of process (%lu MB) below the kill thresold (%lu MB). Killed\n", footprint.value() / MB, thresholdForMemoryKill() / MB);
    153153    RELEASE_ASSERT(m_memoryKillCallback);
    154154    m_memoryKillCallback();
Note: See TracChangeset for help on using the changeset viewer.