Title: [276682] trunk/Source/WTF
- Revision
- 276682
- Author
- [email protected]
- Date
- 2021-04-27 17:18:19 -0700 (Tue, 27 Apr 2021)
Log 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):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (276681 => 276682)
--- trunk/Source/WTF/ChangeLog 2021-04-28 00:04:53 UTC (rev 276681)
+++ trunk/Source/WTF/ChangeLog 2021-04-28 00:18:19 UTC (rev 276682)
@@ -1,3 +1,22 @@
+2021-04-27 Ben Nham <[email protected]>
+
+ 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):
+
2021-04-27 Alex Christensen <[email protected]>
Unreviewed, reverting r275912.
Modified: trunk/Source/WTF/wtf/MemoryPressureHandler.cpp (276681 => 276682)
--- trunk/Source/WTF/wtf/MemoryPressureHandler.cpp 2021-04-28 00:04:53 UTC (rev 276681)
+++ trunk/Source/WTF/wtf/MemoryPressureHandler.cpp 2021-04-28 00:18:19 UTC (rev 276682)
@@ -34,15 +34,7 @@
namespace WTF {
-#if RELEASE_LOG_DISABLED
-WTFLogChannel LogMemoryPressure = { WTFLogChannelState::On, "MemoryPressure", WTFLogLevel::Error };
-#endif
-#if USE(OS_LOG) && !RELEASE_LOG_DISABLED
-WTFLogChannel LogMemoryPressure = { WTFLogChannelState::On, "MemoryPressure", WTFLogLevel::Error, LOG_CHANNEL_WEBKIT_SUBSYSTEM, OS_LOG_DEFAULT };
-#endif
-#if USE(JOURNALD) && !RELEASE_LOG_DISABLED
-WTFLogChannel LogMemoryPressure = { WTFLogChannelState::On, "MemoryPressure", WTFLogLevel::Error, LOG_CHANNEL_WEBKIT_SUBSYSTEM };
-#endif
+DEFINE_LOG_CHANNEL(MemoryPressure, LOG_CHANNEL_WEBKIT_SUBSYSTEM);
WTF_EXPORT_PRIVATE bool MemoryPressureHandler::ReliefLogger::s_loggingEnabled = false;
@@ -51,6 +43,9 @@
static LazyNeverDestroyed<MemoryPressureHandler> memoryPressureHandler;
static std::once_flag onceKey;
std::call_once(onceKey, [&] {
+ WTFLogChannel* channels[] = { &LogMemoryPressure };
+ WTFInitializeLogChannelStatesFromString(channels, 1, "");
+
memoryPressureHandler.construct();
});
return memoryPressureHandler;
Modified: trunk/Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm (276681 => 276682)
--- trunk/Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm 2021-04-28 00:04:53 UTC (rev 276681)
+++ trunk/Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm 2021-04-28 00:18:19 UTC (rev 276682)
@@ -41,12 +41,6 @@
namespace WTF {
-#if RELEASE_LOG_DISABLED
-WTFLogChannel LogPerformanceLogging = { WTFLogChannelState::On, "PerformanceLogging", WTFLogLevel::Error };
-#else
-WTFLogChannel LogPerformanceLogging = { WTFLogChannelState::On, "PerformanceLogging", WTFLogLevel::Error, LOG_CHANNEL_WEBKIT_SUBSYSTEM, OS_LOG_DEFAULT };
-#endif
-
void MemoryPressureHandler::platformReleaseMemory(Critical critical)
{
if (critical == Critical::Yes && (!isUnderMemoryPressure() || m_isSimulatingMemoryPressure)) {
@@ -104,7 +98,7 @@
break;
}
if (m_shouldLogMemoryMemoryPressureEvents)
- RELEASE_LOG(PerformanceLogging, "Received memory pressure event %lu vm pressure %d", status, isUnderMemoryPressure());
+ RELEASE_LOG(MemoryPressure, "Received memory pressure event %lu vm pressure %d", status, isUnderMemoryPressure());
});
dispatch_resume(memoryPressureEventSource);
});
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes