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

Changeset 276682 in webkit


Ignore:
Timestamp:
Apr 27, 2021, 5:18:19 PM (5 years ago)
Author:
Ben Nham
Message:

Memory pressure events should be logged to com.apple.WebKit subsystem
​https://bugs.webkit.org/show_bug.cgi?id=225112

Reviewed by Chris Dumez.

Currently memory pressure events are logged to the default os_log subsystem instead of the
com.apple.WebKit subsystem. This makes it hard to capture such events using common logging
prefs (e.g. a pref that persists all logs from the WebKit subsystem).

To fix this, call WTFInitializeLogChannelStatesFromString at init time. This associates the
WTFLogChannel with an os_log object that sends the messages to the WebKit subsystem.

  • wtf/MemoryPressureHandler.cpp:

(WTF::MemoryPressureHandler::singleton):

  • wtf/cocoa/MemoryPressureHandlerCocoa.mm:

(WTF::MemoryPressureHandler::install):

Location:
trunk/Source/WTF
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r276652 r276682  
     12021-04-27  Ben Nham  <nham@apple.com>
     2
     3        Memory pressure events should be logged to com.apple.WebKit subsystem
     4        https://bugs.webkit.org/show_bug.cgi?id=225112
     5
     6        Reviewed by Chris Dumez.
     7
     8        Currently memory pressure events are logged to the default os_log subsystem instead of the
     9        com.apple.WebKit subsystem. This makes it hard to capture such events using common logging
     10        prefs (e.g. a pref that persists all logs from the WebKit subsystem).
     11
     12        To fix this, call WTFInitializeLogChannelStatesFromString at init time. This associates the
     13        WTFLogChannel with an os_log object that sends the messages to the WebKit subsystem.
     14
     15        * wtf/MemoryPressureHandler.cpp:
     16        (WTF::MemoryPressureHandler::singleton):
     17        * wtf/cocoa/MemoryPressureHandlerCocoa.mm:
     18        (WTF::MemoryPressureHandler::install):
     19
    1202021-04-27  Alex Christensen  <achristensen@webkit.org>
    221
  • trunk/Source/WTF/wtf/MemoryPressureHandler.cpp

    r274594 r276682  
    3535namespace WTF {
    3636
    37 #if RELEASE_LOG_DISABLED
    38 WTFLogChannel LogMemoryPressure = { WTFLogChannelState::On, "MemoryPressure", WTFLogLevel::Error };
    39 #endif
    40 #if USE(OS_LOG) && !RELEASE_LOG_DISABLED
    41 WTFLogChannel LogMemoryPressure = { WTFLogChannelState::On, "MemoryPressure", WTFLogLevel::Error, LOG_CHANNEL_WEBKIT_SUBSYSTEM, OS_LOG_DEFAULT };
    42 #endif
    43 #if USE(JOURNALD) && !RELEASE_LOG_DISABLED
    44 WTFLogChannel LogMemoryPressure = { WTFLogChannelState::On, "MemoryPressure", WTFLogLevel::Error, LOG_CHANNEL_WEBKIT_SUBSYSTEM };
    45 #endif
     37DEFINE_LOG_CHANNEL(MemoryPressure, LOG_CHANNEL_WEBKIT_SUBSYSTEM);
    4638
    4739WTF_EXPORT_PRIVATE bool MemoryPressureHandler::ReliefLogger::s_loggingEnabled = false;
    … …  
    5244    static std::once_flag onceKey;
    5345    std::call_once(onceKey, [&] {
     46        WTFLogChannel* channels[] = { &LogMemoryPressure };
     47        WTFInitializeLogChannelStatesFromString(channels, 1, "");
     48
    5449        memoryPressureHandler.construct();
    5550    });
  • trunk/Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm

    r275909 r276682  
    4242namespace WTF {
    4343
    44 #if RELEASE_LOG_DISABLED
    45 WTFLogChannel LogPerformanceLogging = { WTFLogChannelState::On, "PerformanceLogging", WTFLogLevel::Error };
    46 #else
    47 WTFLogChannel LogPerformanceLogging = { WTFLogChannelState::On, "PerformanceLogging", WTFLogLevel::Error, LOG_CHANNEL_WEBKIT_SUBSYSTEM, OS_LOG_DEFAULT };
    48 #endif
    49 
    5044void MemoryPressureHandler::platformReleaseMemory(Critical critical)
    5145{
    … …  
    10599            }
    106100            if (m_shouldLogMemoryMemoryPressureEvents)
    107                 RELEASE_LOG(PerformanceLogging, "Received memory pressure event %lu vm pressure %d", status, isUnderMemoryPressure());
     101                RELEASE_LOG(MemoryPressure, "Received memory pressure event %lu vm pressure %d", status, isUnderMemoryPressure());
    108102        });
    109103        dispatch_resume(memoryPressureEventSource);
Note: See TracChangeset for help on using the changeset viewer.