[GTK] Since the memory pressure relief has been activated, my disk has a high usage...
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jan 2017 13:54:17 +0000 (13:54 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jan 2017 13:54:17 +0000 (13:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164052

Reviewed by Michael Catanzaro.

Check how much memory is freed by the memory pressure handler and wait for a long time if we didn't free that
much.

* platform/linux/MemoryPressureHandlerLinux.cpp:
(WebCore::MemoryPressureHandler::EventFDPoller::EventFDPoller):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210223 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp

index 6ab4490..bf0ea56 100644 (file)
@@ -1,3 +1,16 @@
+2017-01-02  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Since the memory pressure relief has been activated, my disk has a high usage and the desktop stalls
+        https://bugs.webkit.org/show_bug.cgi?id=164052
+
+        Reviewed by Michael Catanzaro.
+
+        Check how much memory is freed by the memory pressure handler and wait for a long time if we didn't free that
+        much.
+
+        * platform/linux/MemoryPressureHandlerLinux.cpp:
+        (WebCore::MemoryPressureHandler::EventFDPoller::EventFDPoller):
+
 2017-01-02  Chris Fleizach  <cfleizach@apple.com>
 
         AX: Expose block quote level to iOS API
index 4d33abf..4cd1bdd 100644 (file)
@@ -53,9 +53,13 @@ namespace WebCore {
 // seconds after receiving an event. Don't let events fire any sooner than
 // s_holdOffMultiplier times the last cleanup processing time. Effectively
 // this is 1 / s_holdOffMultiplier percent of the time.
+// If after releasing the memory we don't free at least s_minimumBytesFreedToUseMinimumHoldOffTime,
+// we wait longer to try again (s_maximumHoldOffTime).
 // These value seems reasonable and testing verifies that it throttles frequent
 // low memory events, greatly reducing CPU usage.
 static const unsigned s_minimumHoldOffTime = 5;
+static const unsigned s_maximumHoldOffTime = 30;
+static const size_t s_minimumBytesFreedToUseMinimumHoldOffTime = 1 * MB;
 static const unsigned s_holdOffMultiplier = 20;
 
 static const char* s_cgroupMemoryPressureLevel = "/sys/fs/cgroup/memory/memory.pressure_level";
@@ -284,8 +288,12 @@ void MemoryPressureHandler::respondToMemoryPressure(Critical critical, Synchrono
     uninstall();
 
     double startTime = monotonicallyIncreasingTime();
+    int64_t processMemory = processMemoryUsage();
     releaseMemory(critical, synchronous);
-    unsigned holdOffTime = (monotonicallyIncreasingTime() - startTime) * s_holdOffMultiplier;
+    int64_t bytesFreed = processMemory - processMemoryUsage();
+    unsigned holdOffTime = s_maximumHoldOffTime;
+    if (bytesFreed > 0 && static_cast<size_t>(bytesFreed) >= s_minimumBytesFreedToUseMinimumHoldOffTime)
+        holdOffTime = (monotonicallyIncreasingTime() - startTime) * s_holdOffMultiplier;
     holdOff(std::max(holdOffTime, s_minimumHoldOffTime));
 }