Title: [133765] trunk/Source/WebCore
Revision
133765
Author
[email protected]
Date
2012-11-07 09:12:17 -0800 (Wed, 07 Nov 2012)

Log Message

[V8] WebKit sends unnecessary low memory notification when running memory benchmarks
https://bugs.webkit.org/show_bug.cgi?id=101474

Patch by Ulan Degenbaev <[email protected]> on 2012-11-07
Reviewed by Kentaro Hara.

Do not send low memory notification to V8 when most of memory usage
comes from V8 heap and not DOM objects. In this case V8 can schedule GC
itself more optimally.

* bindings/v8/V8GCController.cpp:
(WebCore::V8GCController::checkMemoryUsage):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (133764 => 133765)


--- trunk/Source/WebCore/ChangeLog	2012-11-07 16:28:38 UTC (rev 133764)
+++ trunk/Source/WebCore/ChangeLog	2012-11-07 17:12:17 UTC (rev 133765)
@@ -1,3 +1,17 @@
+2012-11-07  Ulan Degenbaev  <[email protected]>
+
+        [V8] WebKit sends unnecessary low memory notification when running memory benchmarks
+        https://bugs.webkit.org/show_bug.cgi?id=101474
+
+        Reviewed by Kentaro Hara.
+
+        Do not send low memory notification to V8 when most of memory usage
+        comes from V8 heap and not DOM objects. In this case V8 can schedule GC
+        itself more optimally.
+
+        * bindings/v8/V8GCController.cpp:
+        (WebCore::V8GCController::checkMemoryUsage):
+
 2012-11-07  Allan Sandfeld Jensen  <[email protected]>
 
         [Qt] Open link in this window action

Modified: trunk/Source/WebCore/bindings/v8/V8GCController.cpp (133764 => 133765)


--- trunk/Source/WebCore/bindings/v8/V8GCController.cpp	2012-11-07 16:28:38 UTC (rev 133764)
+++ trunk/Source/WebCore/bindings/v8/V8GCController.cpp	2012-11-07 17:12:17 UTC (rev 133765)
@@ -306,9 +306,20 @@
         MutexLocker locker(workingSetEstimateMBMutex());
         workingSetEstimateMBCopy = workingSetEstimateMB;
     }
-
-    if ((memoryUsageMB > lowMemoryUsageMB && memoryUsageMB > 2 * workingSetEstimateMBCopy) || (memoryUsageMB > highMemoryUsageMB && memoryUsageMB > workingSetEstimateMBCopy + highUsageDeltaMB))
+    if (memoryUsageMB > lowMemoryUsageMB && memoryUsageMB > 2 * workingSetEstimateMBCopy) {
+        // Memory usage is large and doubled since the last GC.
+        // Check if we need to send low memory notification.
+        v8::HeapStatistics heapStatistics;
+        v8::V8::GetHeapStatistics(&heapStatistics);
+        int heapSizeMB = heapStatistics.total_heap_size() >> 20;
+        // Do not send low memory notification if V8 heap size is more than 7/8
+        // of total memory usage. Let V8 to schedule GC itself in this case.
+        if (heapSizeMB < memoryUsageMB / 8 * 7)
+            v8::V8::LowMemoryNotification();
+    } else if (memoryUsageMB > highMemoryUsageMB && memoryUsageMB > workingSetEstimateMBCopy + highUsageDeltaMB) {
+        // We are approaching OOM and memory usage increased by highUsageDeltaMB since the last GC.
         v8::V8::LowMemoryNotification();
+    }
 #endif
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to