⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 245499 in webkit


Ignore:
Timestamp:
May 18, 2019, 12:12:17 AM (7 years ago)
Author:
Tadeu Zagallo
Message:

Add extra information to dumpJITMemory
https://bugs.webkit.org/show_bug.cgi?id=197998

Reviewed by Saam Barati.

Source/JavaScriptCore:

Add ktrace events around the memory dump and mach_absolute_time to link the
events with the entries in the dump. Additionally, add a background queue
to flush on a configurable interval, since the atexit callback does not work
in every situation.

  • jit/ExecutableAllocator.cpp:

(JSC::dumpJITMemory):

  • runtime/Options.h:

Source/WTF:

Add a new trace point code for JSC::dumpJITMemory

  • wtf/SystemTracing.h:

Tools:

Add description for the new dumpJITMemory trace point code.

  • Tracing/SystemTracePoints.plist:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r245496 r245499  
     12019-05-18  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        Add extra information to dumpJITMemory
     4        https://bugs.webkit.org/show_bug.cgi?id=197998
     5
     6        Reviewed by Saam Barati.
     7
     8        Add ktrace events around the memory dump and mach_absolute_time to link the
     9        events with the entries in the dump. Additionally, add a background queue
     10        to flush on a configurable interval, since the atexit callback does not work
     11        in every situation.
     12
     13        * jit/ExecutableAllocator.cpp:
     14        (JSC::dumpJITMemory):
     15        * runtime/Options.h:
     16
    1172019-05-17  Justin Michaud  <justin_michaud@apple.com>
    218
  • trunk/Source/JavaScriptCore/jit/ExecutableAllocator.cpp

    r244483 r245499  
    3434#include <wtf/MetaAllocator.h>
    3535#include <wtf/PageReservation.h>
     36#include <wtf/SystemTracing.h>
     37#include <wtf/WorkQueue.h>
    3638
    3739#if OS(DARWIN)
     40#include <mach/mach_time.h>
    3841#include <sys/mman.h>
    3942#endif
     
    560563    static constexpr size_t bufferSize = fixedExecutableMemoryPoolSize;
    561564    static size_t offset = 0;
    562     static auto flush = [] {
     565    static Lock dumpJITMemoryLock;
     566    static bool needsToFlush = false;
     567    static auto flush = [](const AbstractLocker&) {
    563568        if (fd == -1) {
    564569            fd = open(Options::dumpJITMemoryPath(), O_CREAT | O_TRUNC | O_APPEND | O_WRONLY | O_EXLOCK | O_NONBLOCK, 0666);
     
    567572        write(fd, buffer, offset);
    568573        offset = 0;
     574        needsToFlush = false;
    569575    };
    570576
    571     static Lock dumpJITMemoryLock;
    572577    static std::once_flag once;
     578    static LazyNeverDestroyed<Ref<WorkQueue>> flushQueue;
    573579    std::call_once(once, [] {
    574580        buffer = bitwise_cast<uint8_t*>(malloc(bufferSize));
     581        flushQueue.construct(WorkQueue::create("jsc.dumpJITMemory.queue", WorkQueue::Type::Serial, WorkQueue::QOS::Background));
    575582        std::atexit([] {
    576583            LockHolder locker(dumpJITMemoryLock);
    577             flush();
     584            flush(locker);
    578585            close(fd);
     586            fd = -1;
    579587        });
    580588    });
    581589
    582     static auto write = [](const void* src, size_t size) {
     590    static auto enqueueFlush = [](const AbstractLocker&) {
     591        if (needsToFlush)
     592            return;
     593
     594        needsToFlush = true;
     595        flushQueue.get()->dispatchAfter(Seconds(Options::dumpJITMemoryFlushInterval()), [] {
     596            LockHolder locker(dumpJITMemoryLock);
     597            if (!needsToFlush)
     598                return;
     599            flush(locker);
     600        });
     601    };
     602
     603    static auto write = [](const AbstractLocker& locker, const void* src, size_t size) {
    583604        if (UNLIKELY(offset + size > bufferSize))
    584             flush();
     605            flush(locker);
    585606        memcpy(buffer + offset, src, size);
    586607        offset += size;
     608        enqueueFlush(locker);
    587609    };
    588610
    589611    LockHolder locker(dumpJITMemoryLock);
     612    uint64_t time = mach_absolute_time();
    590613    uint64_t dst64 = bitwise_cast<uintptr_t>(dst);
    591     write(&dst64, sizeof(dst64));
    592614    uint64_t size64 = size;
    593     write(&size64, sizeof(size64));
    594     write(src, size);
     615    TraceScope(DumpJITMemoryStart, DumpJITMemoryStop, time, dst64, size64);
     616    write(locker, &time, sizeof(time));
     617    write(locker, &dst64, sizeof(dst64));
     618    write(locker, &size64, sizeof(size64));
     619    write(locker, src, size);
    595620#else
    596621    UNUSED_PARAM(dst);
  • trunk/Source/JavaScriptCore/runtime/Options.h

    r245496 r245499  
    520520    v(double, validateAbstractInterpreterStateProbability, 0.5, Normal, nullptr) \
    521521    v(optionString, dumpJITMemoryPath, nullptr, Restricted, nullptr) \
     522    v(double, dumpJITMemoryFlushInterval, 10, Restricted, "Maximum time in between flushes of the JIT memory dump in seconds.") \
    522523
    523524
  • trunk/Source/WTF/ChangeLog

    r245492 r245499  
     12019-05-18  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        Add extra information to dumpJITMemory
     4        https://bugs.webkit.org/show_bug.cgi?id=197998
     5
     6        Reviewed by Saam Barati.
     7
     8        Add a new trace point code for JSC::dumpJITMemory
     9
     10        * wtf/SystemTracing.h:
     11
    1122019-05-17  Don Olmstead  <don.olmstead@sony.com>
    213
  • trunk/Source/WTF/wtf/SystemTracing.h

    r244182 r245499  
    4848    WebAssemblyExecuteStart,
    4949    WebAssemblyExecuteEnd,
     50    DumpJITMemoryStart,
     51    DumpJITMemoryStop,
    5052
    5153    WebCoreRange = 5000,
  • trunk/Tools/ChangeLog

    r245496 r245499  
     12019-05-18  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        Add extra information to dumpJITMemory
     4        https://bugs.webkit.org/show_bug.cgi?id=197998
     5
     6        Reviewed by Saam Barati.
     7
     8        Add description for the new dumpJITMemory trace point code.
     9
     10        * Tracing/SystemTracePoints.plist:
     11
    1122019-05-17  Justin Michaud  <justin_michaud@apple.com>
    213
  • trunk/Tools/Tracing/SystemTracePoints.plist

    r244182 r245499  
    4646             <dict>
    4747                 <key>Name</key>
     48                 <string>Dump JIT Memory</string>
     49                 <key>Type</key>
     50                 <string>Interval</string>
     51                 <key>Component</key>
     52                 <string>47</string>
     53                 <key>CodeBegin</key>
     54                 <string>2507</string>
     55                 <key>CodeEnd</key>
     56                 <string>2508</string>
     57             </dict>
     58             <dict>
     59                 <key>Name</key>
    4860                 <string>Main Resource Load</string>
    4961                 <key>Type</key>
Note: See TracChangeset for help on using the changeset viewer.