Skip to content

Commit edc4db1

Browse files
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 fce8e2e commit edc4db1

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
@@ -53,8 +53,13 @@ namespace WTF {
5353
// we wait longer to try again (s_maximumHoldOffTime).
5454
// These value seems reasonable and testing verifies that it throttles frequent
5555
// low memory events, greatly reducing CPU usage.
56+
#if PLATFORM(WPE)
57+
static const Seconds s_minimumHoldOffTime { 1_s };
58+
static const Seconds s_maximumHoldOffTime { 1_s };
59+
#else
5660
static const Seconds s_minimumHoldOffTime { 5_s };
5761
static const Seconds s_maximumHoldOffTime { 30_s };
62+
#endif
5863
static const size_t s_minimumBytesFreedToUseMinimumHoldOffTime = 1 * MB;
5964
static const unsigned s_holdOffMultiplier = 20;
6065

@@ -69,7 +74,9 @@ void MemoryPressureHandler::triggerMemoryPressureEvent(bool isCritical)
6974
setMemoryPressureStatus(MemoryPressureStatus::SystemCritical);
7075

7176
ensureOnMainThread([this, isCritical] {
72-
respondToMemoryPressure(isCritical ? Critical::Yes : Critical::No);
77+
// When memory usage reaches the critical state, we may not release enough memory in time if we use the
78+
// async mode, so use synchrounous mode in such case
79+
respondToMemoryPressure(isCritical ? Critical::Yes : Critical::No, isCritical ? Synchronous::Yes : Synchronous::No);
7380
});
7481

7582
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)