Skip to content

Commit 9a12fb5

Browse files
filipe-norte-redmagomez
authored andcommitted
MemoryPressure: tune memory pressure settings for rapid mem usage changes
When playing an asset with video, frequent seek/jump operations within a short period may cause rapid memory increases. The current pressure settings may not allow (enough) memory release in time to avoid an app running in a container to be killed due it reaching the memory limits. To allow sufficient, in time, memory release, the release needs to happen with the "synchrounous" flag set to true, allowing full garbage collection cycle when reaching critical limits. Furthermore, the critical threshold needs to be lowered as well considering that the release is not instantaneous and on embedded devices the 95% original threshold does not allow enough room for mem release on apps with lower allowed memory usage limits.
1 parent 6706256 commit 9a12fb5

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

Source/WTF/wtf/unix/MemoryPressureHandlerUnix.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,13 @@ namespace WTF {
5656
// we wait longer to try again (s_maximumHoldOffTime).
5757
// These value seems reasonable and testing verifies that it throttles frequent
5858
// low memory events, greatly reducing CPU usage.
59+
#if PLATFORM(WPE)
60+
static const Seconds s_minimumHoldOffTime { 1_s };
61+
static const Seconds s_maximumHoldOffTime { 1_s };
62+
#else
5963
static const Seconds s_minimumHoldOffTime { 5_s };
6064
static const Seconds s_maximumHoldOffTime { 30_s };
65+
#endif
6166
static const size_t s_minimumBytesFreedToUseMinimumHoldOffTime = 1 * MB;
6267
static const unsigned s_holdOffMultiplier = 20;
6368

@@ -72,7 +77,9 @@ void MemoryPressureHandler::triggerMemoryPressureEvent(bool isCritical)
7277
setMemoryPressureStatus(SystemMemoryPressureStatus::Critical);
7378

7479
ensureOnMainThread([this, isCritical] {
75-
respondToMemoryPressure(isCritical ? Critical::Yes : Critical::No);
80+
// When memory usage reaches the critical state, we may not release enough memory in time if we use the
81+
// async mode, so use synchrounous mode in such case
82+
respondToMemoryPressure(isCritical ? Critical::Yes : Critical::No, isCritical ? Synchronous::Yes : Synchronous::No);
7683
});
7784

7885
if (ReliefLogger::loggingEnabled() && isUnderMemoryPressure())

Source/WebKit/UIProcess/linux/MemoryPressureMonitor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ static const Seconds s_minPollingInterval { 1_s };
4848
static const Seconds s_maxPollingInterval { 5_s };
4949
static const double s_minUsedMemoryPercentageForPolling = 50;
5050
static const double s_maxUsedMemoryPercentageForPolling = 85;
51+
#if PLATFORM(WPE)
52+
static const int s_memoryPresurePercentageThreshold = 80;
53+
static const int s_memoryPresurePercentageThresholdCritical = 85;
54+
#else
5155
static const int s_memoryPresurePercentageThreshold = 90;
5256
static const int s_memoryPresurePercentageThresholdCritical = 95;
57+
#endif
5358
// cgroups.7: The usual place for such mounts is under a tmpfs(5)
5459
// filesystem mounted at /sys/fs/cgroup.
5560
static const char* s_cgroupMemoryPath = "/sys/fs/cgroup/%s/%s/%s";

0 commit comments

Comments
 (0)