Title: [194057] trunk/Source
Revision
194057
Author
[email protected]
Date
2015-12-14 13:36:27 -0800 (Mon, 14 Dec 2015)

Log Message

ResourceUsageOverlay should show GC timers.
<https://webkit.org/b/152151>

Reviewed by Darin Adler.

Source/_javascript_Core:

Expose the next fire time (in WTF timestamp style) of a GCActivityCallback.

* heap/GCActivityCallback.cpp:
(JSC::GCActivityCallback::scheduleTimer):
(JSC::GCActivityCallback::cancelTimer):
* heap/GCActivityCallback.h:

Source/WebCore:

Add countdowns until next Eden and Full GC to the overlay. It also shows if there
is no garbage collection scheduled. This will be helpful in understanding why GC
sometimes takes a very long time to happen.

* page/ResourceUsageOverlay.h:
* page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::formatByteNumber): Drive-by silly math fix. :|
(WebCore::gcTimerString):
(WebCore::ResourceUsageOverlay::platformDraw):
(WebCore::nextFireTimeForGCTimer):
(WebCore::runSamplerThread):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (194056 => 194057)


--- trunk/Source/_javascript_Core/ChangeLog	2015-12-14 21:30:31 UTC (rev 194056)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-12-14 21:36:27 UTC (rev 194057)
@@ -1,3 +1,17 @@
+2015-12-14  Andreas Kling  <[email protected]>
+
+        ResourceUsageOverlay should show GC timers.
+        <https://webkit.org/b/152151>
+
+        Reviewed by Darin Adler.
+
+        Expose the next fire time (in WTF timestamp style) of a GCActivityCallback.
+
+        * heap/GCActivityCallback.cpp:
+        (JSC::GCActivityCallback::scheduleTimer):
+        (JSC::GCActivityCallback::cancelTimer):
+        * heap/GCActivityCallback.h:
+
 2015-12-14  Filip Pizlo  <[email protected]>
 
         Unreviewed, fix merge issue in a test.

Modified: trunk/Source/_javascript_Core/heap/GCActivityCallback.cpp (194056 => 194057)


--- trunk/Source/_javascript_Core/heap/GCActivityCallback.cpp	2015-12-14 21:30:31 UTC (rev 194056)
+++ trunk/Source/_javascript_Core/heap/GCActivityCallback.cpp	2015-12-14 21:36:27 UTC (rev 194057)
@@ -95,12 +95,14 @@
         return;
     double delta = m_delay - newDelay;
     m_delay = newDelay;
+    m_nextFireTime = WTF::currentTime() + newDelay;
     CFRunLoopTimerSetNextFireDate(m_timer.get(), CFRunLoopTimerGetNextFireDate(m_timer.get()) - delta);
 }
 
 void GCActivityCallback::cancelTimer()
 {
     m_delay = s_decade;
+    m_nextFireTime = 0;
     CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + s_decade);
 }
 #elif PLATFORM(EFL)

Modified: trunk/Source/_javascript_Core/heap/GCActivityCallback.h (194056 => 194057)


--- trunk/Source/_javascript_Core/heap/GCActivityCallback.h	2015-12-14 21:30:31 UTC (rev 194056)
+++ trunk/Source/_javascript_Core/heap/GCActivityCallback.h	2015-12-14 21:36:27 UTC (rev 194057)
@@ -61,6 +61,10 @@
 
     static bool s_shouldCreateGCTimer;
 
+#if USE(CF) || PLATFORM(EFL)
+    double nextFireTime() const { return m_nextFireTime; }
+#endif
+
 protected:
     virtual double lastGCLength() = 0;
     virtual double gcTimeSlice(size_t bytes) = 0;
@@ -109,6 +113,7 @@
 
 private:
     double m_delay;
+    double m_nextFireTime { 0 };
 #endif
 };
 

Modified: trunk/Source/WebCore/ChangeLog (194056 => 194057)


--- trunk/Source/WebCore/ChangeLog	2015-12-14 21:30:31 UTC (rev 194056)
+++ trunk/Source/WebCore/ChangeLog	2015-12-14 21:36:27 UTC (rev 194057)
@@ -1,3 +1,22 @@
+2015-12-14  Andreas Kling  <[email protected]>
+
+        ResourceUsageOverlay should show GC timers.
+        <https://webkit.org/b/152151>
+
+        Reviewed by Darin Adler.
+
+        Add countdowns until next Eden and Full GC to the overlay. It also shows if there
+        is no garbage collection scheduled. This will be helpful in understanding why GC
+        sometimes takes a very long time to happen.
+
+        * page/ResourceUsageOverlay.h:
+        * page/cocoa/ResourceUsageOverlayCocoa.mm:
+        (WebCore::formatByteNumber): Drive-by silly math fix. :|
+        (WebCore::gcTimerString):
+        (WebCore::ResourceUsageOverlay::platformDraw):
+        (WebCore::nextFireTimeForGCTimer):
+        (WebCore::runSamplerThread):
+
 2015-12-14  Chris Fleizach  <[email protected]>
 
         AX: iOS: Text field variations do not have the correct traits

Modified: trunk/Source/WebCore/page/ResourceUsageOverlay.h (194056 => 194057)


--- trunk/Source/WebCore/page/ResourceUsageOverlay.h	2015-12-14 21:30:31 UTC (rev 194056)
+++ trunk/Source/WebCore/page/ResourceUsageOverlay.h	2015-12-14 21:36:27 UTC (rev 194057)
@@ -59,7 +59,7 @@
 #endif
 
     static const int normalWidth = 570;
-    static const int normalHeight = 130;
+    static const int normalHeight = 160;
 
 private:
     void pageOverlayDestroyed(PageOverlay&) override { }

Modified: trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm (194056 => 194057)


--- trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm	2015-12-14 21:30:31 UTC (rev 194056)
+++ trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm	2015-12-14 21:36:27 UTC (rev 194057)
@@ -32,6 +32,7 @@
 #include "MachVMSPI.h"
 #include "PlatformCALayer.h"
 #include <CoreGraphics/CGContext.h>
+#include <_javascript_Core/GCActivityCallback.h>
 #include <QuartzCore/CALayer.h>
 #include <QuartzCore/CATransaction.h>
 #include <array>
@@ -185,6 +186,9 @@
 
     HashSet<CALayer *> overlayLayers;
     JSC::VM* vm { nullptr };
+
+    double timeOfNextEdenCollection { 0 };
+    double timeOfNextFullCollection { 0 };
 };
 
 ResourceUsageData::ResourceUsageData()
@@ -421,7 +425,7 @@
 static String formatByteNumber(size_t number)
 {
     if (number >= 1024 * 1048576)
-        return String::format("%.3f GB", static_cast<double>(number) / 1024 * 1048576);
+        return String::format("%.3f GB", static_cast<double>(number) / (1024 * 1048576));
     if (number >= 1048576)
         return String::format("%.2f MB", static_cast<double>(number) / 1048576);
     if (number >= 1024)
@@ -429,6 +433,13 @@
     return String::format("%lu", number);
 }
 
+static String gcTimerString(double timerFireDate, double now)
+{
+    if (!timerFireDate)
+        return ASCIILiteral("[not scheduled]");
+    return String::format("%g", timerFireDate - now);
+}
+
 void ResourceUsageOverlay::platformDraw(CGContextRef context)
 {
     auto& data = ""
@@ -461,6 +472,10 @@
         y += 10;
     }
 
+    double now = WTF::currentTime();
+    showText(context, 10, y + 10, colorForLabels, String::format("    Eden GC: %s", gcTimerString(data.timeOfNextEdenCollection, now).ascii().data()));
+    showText(context, 10, y + 20, colorForLabels, String::format("    Full GC: %s", gcTimerString(data.timeOfNextFullCollection, now).ascii().data()));
+
     drawCpuHistory(context, viewBounds.size.width - 70, 0, viewBounds.size.height, data.cpuHistory);
     drawGCHistory(context, viewBounds.size.width - 140, 0, viewBounds.size.height, data.gcHeapSizeHistory, data.categories[MemoryCategory::GCHeap].history);
     drawMemHistory(context, viewBounds.size.width - 210, 0, viewBounds.size.height, data);
@@ -609,6 +624,9 @@
             // Subtract known subchunks from the bmalloc bucket.
             // FIXME: Handle running with bmalloc disabled.
             data.categories[MemoryCategory::bmalloc].history.last() -= currentGCHeapCapacity + currentGCOwned;
+
+            data.timeOfNextEdenCollection = data.vm->heap.edenActivityCallback()->nextFireTime();
+            data.timeOfNextFullCollection = data.vm->heap.fullActivityCallback()->nextFireTime();
         }
 
         [CATransaction begin];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to