Title: [112930] trunk/Source/WebCore
Revision
112930
Author
msab...@apple.com
Date
2012-04-02 13:34:59 -0700 (Mon, 02 Apr 2012)

Log Message

WebKit should throttle memory pressure notifications in proportion to handler time
https://bugs.webkit.org/show_bug.cgi?id=82674

Rubber-stamped by Darin Adler.

Updated r112910: <http://trac.webkit.org/changeset/112910> to address
post checkin concerns raised in original bug.

No additional tests. This passes existing test and was verified using
manual tests on a small memory system with many websites open.

* platform/mac/MemoryPressureHandlerMac.mm:
(WebCore):
(WebCore::MemoryPressureHandler::respondToMemoryPressure):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (112929 => 112930)


--- trunk/Source/WebCore/ChangeLog	2012-04-02 20:34:55 UTC (rev 112929)
+++ trunk/Source/WebCore/ChangeLog	2012-04-02 20:34:59 UTC (rev 112930)
@@ -1,3 +1,20 @@
+2012-04-02  Michael Saboff  <msab...@apple.com>
+
+        WebKit should throttle memory pressure notifications in proportion to handler time
+        https://bugs.webkit.org/show_bug.cgi?id=82674
+
+        Rubber-stamped by Darin Adler.
+
+        Updated r112910: <http://trac.webkit.org/changeset/112910> to address
+        post checkin concerns raised in original bug.
+
+        No additional tests. This passes existing test and was verified using
+        manual tests on a small memory system with many websites open.
+
+        * platform/mac/MemoryPressureHandlerMac.mm:
+        (WebCore):
+        (WebCore::MemoryPressureHandler::respondToMemoryPressure):
+
 2012-04-02  Darin Fisher  <da...@chromium.org>
 
         HistoryItem not updated properly when a form submission begins before a

Modified: trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm (112929 => 112930)


--- trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm	2012-04-02 20:34:55 UTC (rev 112929)
+++ trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm	2012-04-02 20:34:59 UTC (rev 112930)
@@ -38,6 +38,8 @@
 #import <notify.h>
 #endif
 
+using std::max;
+
 namespace WebCore {
 
 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
@@ -53,8 +55,8 @@
 // this is 1 / s_holdOffMultiplier percent of the time.
 // These value seems reasonable and testing verifies that it throttles frequent
 // low memory events, greatly reducing CPU usage.
-static const time_t s_minimumHoldOffTime = 5;
-static const time_t s_holdOffMultiplier = 20;
+static const unsigned s_minimumHoldOffTime = 5;
+static const unsigned s_holdOffMultiplier = 20;
 
 void MemoryPressureHandler::install()
 {
@@ -116,23 +118,15 @@
 
 void MemoryPressureHandler::respondToMemoryPressure()
 {
-    double startTime, endTime;
-    unsigned holdOffTime;
-
     uninstall();
 
-    startTime = monotonicallyIncreasingTime();
+    double startTime = monotonicallyIncreasingTime();
 
     releaseMemory(false);
 
-    endTime = monotonicallyIncreasingTime();
+    unsigned holdOffTime = (monotonicallyIncreasingTime() - startTime) * s_holdOffMultiplier;
 
-    holdOffTime = (unsigned)((endTime - startTime) * (double)s_holdOffMultiplier);
-
-    if (holdOffTime < s_minimumHoldOffTime)
-        holdOffTime = s_minimumHoldOffTime;
-
-    holdOff(holdOffTime);
+    holdOff(max(holdOffTime, s_minimumHoldOffTime));
 }
 #endif // !PLATFORM(IOS)
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to