Modified: trunk/Source/WebCore/ChangeLog (212960 => 212961)
--- trunk/Source/WebCore/ChangeLog 2017-02-24 17:50:06 UTC (rev 212960)
+++ trunk/Source/WebCore/ChangeLog 2017-02-24 19:24:21 UTC (rev 212961)
@@ -1,3 +1,23 @@
+2017-02-24 Chris Dumez <cdu...@apple.com>
+
+ [Mac] Report domains using abnormally high memory usage via enhanced privacy logging
+ https://bugs.webkit.org/show_bug.cgi?id=168797
+ <rdar://problem/29964017>
+
+ Reviewed by Andreas Kling.
+
+ Report domains using abnormally high memory usage (> 2GB) via enhanced privacy
+ logging on Mac.
+
+ * page/DiagnosticLoggingKeys.cpp:
+ (WebCore::DiagnosticLoggingKeys::domainCausingJetsamKey):
+ * page/DiagnosticLoggingKeys.h:
+ * page/PerformanceMonitor.cpp:
+ (WebCore::reportPageOverPostLoadResourceThreshold):
+ (WebCore::PerformanceMonitor::measurePostLoadCPUUsage):
+ (WebCore::PerformanceMonitor::measurePostLoadMemoryUsage):
+ (WebCore::reportPageOverPostLoadCPUUsageThreshold): Deleted.
+
2017-02-24 Alex Christensen <achristen...@webkit.org>
.. should not remove windows drive letters in paths of file URLs
Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp (212960 => 212961)
--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp 2017-02-24 17:50:06 UTC (rev 212960)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp 2017-02-24 19:24:21 UTC (rev 212961)
@@ -348,6 +348,11 @@
return ASCIILiteral("DomainCausingEnergyDrain");
}
+String DiagnosticLoggingKeys::domainCausingJetsamKey()
+{
+ return ASCIILiteral("DomainCausingJetsam");
+}
+
String DiagnosticLoggingKeys::domainVisitedKey()
{
return ASCIILiteral("DomainVisited");
Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.h (212960 => 212961)
--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.h 2017-02-24 17:50:06 UTC (rev 212960)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.h 2017-02-24 19:24:21 UTC (rev 212961)
@@ -51,6 +51,7 @@
static String diskCacheAfterValidationKey();
static String documentLoaderStoppingKey();
static String domainCausingEnergyDrainKey();
+ static String domainCausingJetsamKey();
static String domainVisitedKey();
static String engineFailedToLoadKey();
WEBCORE_EXPORT static String entryRightlyNotWarmedUpKey();
Modified: trunk/Source/WebCore/page/PerformanceMonitor.cpp (212960 => 212961)
--- trunk/Source/WebCore/page/PerformanceMonitor.cpp 2017-02-24 17:50:06 UTC (rev 212960)
+++ trunk/Source/WebCore/page/PerformanceMonitor.cpp 2017-02-24 19:24:21 UTC (rev 212961)
@@ -49,6 +49,9 @@
static const std::chrono::seconds memoryUsageMeasurementDelay { 10 };
static const double postPageLoadCPUUsageDomainReportingThreshold { 20.0 }; // Reporting pages using over 20% CPU is roughly equivalent to reporting the 10% worst pages.
+#if !PLATFORM(IOS)
+static const uint64_t postPageLoadMemoryUsageDomainReportingThreshold { 2048 * MB };
+#endif
static inline ActivityStateForCPUSampling activityStateForCPUSampling(ActivityState::Flags state)
{
@@ -126,7 +129,8 @@
}
}
-static void reportPageOverPostLoadCPUUsageThreshold(Page& page)
+enum class ReportingReason { HighCPUUsage, HighMemoryUsage };
+static void reportPageOverPostLoadResourceThreshold(Page& page, ReportingReason reason)
{
#if ENABLE(PUBLIC_SUFFIX_LIST)
auto* document = page.mainFrame().document();
@@ -137,9 +141,17 @@
if (domain.isEmpty())
return;
- page.diagnosticLoggingClient().logDiagnosticMessageWithEnhancedPrivacy(DiagnosticLoggingKeys::domainCausingEnergyDrainKey(), domain, ShouldSample::No);
+ switch (reason) {
+ case ReportingReason::HighCPUUsage:
+ page.diagnosticLoggingClient().logDiagnosticMessageWithEnhancedPrivacy(DiagnosticLoggingKeys::domainCausingEnergyDrainKey(), domain, ShouldSample::No);
+ break;
+ case ReportingReason::HighMemoryUsage:
+ page.diagnosticLoggingClient().logDiagnosticMessageWithEnhancedPrivacy(DiagnosticLoggingKeys::domainCausingJetsamKey(), domain, ShouldSample::No);
+ break;
+ }
#else
UNUSED_PARAM(page);
+ UNUSED_PARAM(reason);
#endif
}
@@ -165,7 +177,7 @@
m_page.diagnosticLoggingClient().logDiagnosticMessage(DiagnosticLoggingKeys::postPageLoadCPUUsageKey(), DiagnosticLoggingKeys::foregroundCPUUsageToDiagnosticLoggingKey(cpuUsage), ShouldSample::No);
if (cpuUsage > postPageLoadCPUUsageDomainReportingThreshold)
- reportPageOverPostLoadCPUUsageThreshold(m_page);
+ reportPageOverPostLoadResourceThreshold(m_page, ReportingReason::HighCPUUsage);
}
void PerformanceMonitor::measurePostLoadMemoryUsage()
@@ -179,6 +191,12 @@
RELEASE_LOG_IF_ALLOWED(PerformanceLogging, "measurePostLoadMemoryUsage: Process was using %llu bytes of memory after the page load.", memoryUsage.value());
m_page.diagnosticLoggingClient().logDiagnosticMessage(DiagnosticLoggingKeys::postPageLoadMemoryUsageKey(), DiagnosticLoggingKeys::memoryUsageToDiagnosticLoggingKey(memoryUsage.value()), ShouldSample::No);
+
+ // On iOS, we report actual Jetsams instead.
+#if !PLATFORM(IOS)
+ if (memoryUsage.value() > postPageLoadMemoryUsageDomainReportingThreshold)
+ reportPageOverPostLoadResourceThreshold(m_page, ReportingReason::HighMemoryUsage);
+#endif
}
void PerformanceMonitor::measurePostBackgroundingMemoryUsage()