Changeset 194057 in webkit


Ignore:
Timestamp:
Dec 14, 2015 1:36:27 PM (8 years ago)
Author:
akling@apple.com
Message:

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

Reviewed by Darin Adler.

Source/JavaScriptCore:

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

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r194050 r194057  
     12015-12-14  Andreas Kling  <akling@apple.com>
     2
     3        ResourceUsageOverlay should show GC timers.
     4        <https://webkit.org/b/152151>
     5
     6        Reviewed by Darin Adler.
     7
     8        Expose the next fire time (in WTF timestamp style) of a GCActivityCallback.
     9
     10        * heap/GCActivityCallback.cpp:
     11        (JSC::GCActivityCallback::scheduleTimer):
     12        (JSC::GCActivityCallback::cancelTimer):
     13        * heap/GCActivityCallback.h:
     14
    1152015-12-14  Filip Pizlo  <fpizlo@apple.com>
    216
  • trunk/Source/JavaScriptCore/heap/GCActivityCallback.cpp

    r192773 r194057  
    9696    double delta = m_delay - newDelay;
    9797    m_delay = newDelay;
     98    m_nextFireTime = WTF::currentTime() + newDelay;
    9899    CFRunLoopTimerSetNextFireDate(m_timer.get(), CFRunLoopTimerGetNextFireDate(m_timer.get()) - delta);
    99100}
     
    102103{
    103104    m_delay = s_decade;
     105    m_nextFireTime = 0;
    104106    CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + s_decade);
    105107}
  • trunk/Source/JavaScriptCore/heap/GCActivityCallback.h

    r192773 r194057  
    6262    static bool s_shouldCreateGCTimer;
    6363
     64#if USE(CF) || PLATFORM(EFL)
     65    double nextFireTime() const { return m_nextFireTime; }
     66#endif
     67
    6468protected:
    6569    virtual double lastGCLength() = 0;
     
    110114private:
    111115    double m_delay;
     116    double m_nextFireTime { 0 };
    112117#endif
    113118};
  • trunk/Source/WebCore/ChangeLog

    r194054 r194057  
     12015-12-14  Andreas Kling  <akling@apple.com>
     2
     3        ResourceUsageOverlay should show GC timers.
     4        <https://webkit.org/b/152151>
     5
     6        Reviewed by Darin Adler.
     7
     8        Add countdowns until next Eden and Full GC to the overlay. It also shows if there
     9        is no garbage collection scheduled. This will be helpful in understanding why GC
     10        sometimes takes a very long time to happen.
     11
     12        * page/ResourceUsageOverlay.h:
     13        * page/cocoa/ResourceUsageOverlayCocoa.mm:
     14        (WebCore::formatByteNumber): Drive-by silly math fix. :|
     15        (WebCore::gcTimerString):
     16        (WebCore::ResourceUsageOverlay::platformDraw):
     17        (WebCore::nextFireTimeForGCTimer):
     18        (WebCore::runSamplerThread):
     19
    1202015-12-14  Chris Fleizach  <cfleizach@apple.com>
    221
  • trunk/Source/WebCore/page/ResourceUsageOverlay.h

    r193873 r194057  
    6060
    6161    static const int normalWidth = 570;
    62     static const int normalHeight = 130;
     62    static const int normalHeight = 160;
    6363
    6464private:
  • trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm

    r193873 r194057  
    3333#include "PlatformCALayer.h"
    3434#include <CoreGraphics/CGContext.h>
     35#include <JavaScriptCore/GCActivityCallback.h>
    3536#include <QuartzCore/CALayer.h>
    3637#include <QuartzCore/CATransaction.h>
     
    186187    HashSet<CALayer *> overlayLayers;
    187188    JSC::VM* vm { nullptr };
     189
     190    double timeOfNextEdenCollection { 0 };
     191    double timeOfNextFullCollection { 0 };
    188192};
    189193
     
    422426{
    423427    if (number >= 1024 * 1048576)
    424         return String::format("%.3f GB", static_cast<double>(number) / 1024 * 1048576);
     428        return String::format("%.3f GB", static_cast<double>(number) / (1024 * 1048576));
    425429    if (number >= 1048576)
    426430        return String::format("%.2f MB", static_cast<double>(number) / 1048576);
     
    428432        return String::format("%.1f kB", static_cast<double>(number) / 1024);
    429433    return String::format("%lu", number);
     434}
     435
     436static String gcTimerString(double timerFireDate, double now)
     437{
     438    if (!timerFireDate)
     439        return ASCIILiteral("[not scheduled]");
     440    return String::format("%g", timerFireDate - now);
    430441}
    431442
     
    461472        y += 10;
    462473    }
     474
     475    double now = WTF::currentTime();
     476    showText(context, 10, y + 10, colorForLabels, String::format("    Eden GC: %s", gcTimerString(data.timeOfNextEdenCollection, now).ascii().data()));
     477    showText(context, 10, y + 20, colorForLabels, String::format("    Full GC: %s", gcTimerString(data.timeOfNextFullCollection, now).ascii().data()));
    463478
    464479    drawCpuHistory(context, viewBounds.size.width - 70, 0, viewBounds.size.height, data.cpuHistory);
     
    610625            // FIXME: Handle running with bmalloc disabled.
    611626            data.categories[MemoryCategory::bmalloc].history.last() -= currentGCHeapCapacity + currentGCOwned;
     627
     628            data.timeOfNextEdenCollection = data.vm->heap.edenActivityCallback()->nextFireTime();
     629            data.timeOfNextFullCollection = data.vm->heap.fullActivityCallback()->nextFireTime();
    612630        }
    613631
Note: See TracChangeset for help on using the changeset viewer.