Title: [212920] trunk/Source/WebCore
- Revision
- 212920
- Author
- cdu...@apple.com
- Date
- 2017-02-23 12:56:54 -0800 (Thu, 23 Feb 2017)
Log Message
Report domains using abnormally high CPU usage via enhanced privacy logging
https://bugs.webkit.org/show_bug.cgi?id=168794
<rdar://problem/29964018>
Reviewed by Ryosuke Niwa.
Report domains using abnormally high CPU usage (> 20%) via enhanced privacy
logging.
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::domainCausingEnergyDrainKey):
* page/DiagnosticLoggingKeys.h:
* page/PerformanceMonitor.cpp:
(WebCore::reportPageOverPostLoadCPUUsageThreshold):
(WebCore::PerformanceMonitor::measurePostLoadCPUUsage):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (212919 => 212920)
--- trunk/Source/WebCore/ChangeLog 2017-02-23 20:51:42 UTC (rev 212919)
+++ trunk/Source/WebCore/ChangeLog 2017-02-23 20:56:54 UTC (rev 212920)
@@ -1,3 +1,21 @@
+2017-02-23 Chris Dumez <cdu...@apple.com>
+
+ Report domains using abnormally high CPU usage via enhanced privacy logging
+ https://bugs.webkit.org/show_bug.cgi?id=168794
+ <rdar://problem/29964018>
+
+ Reviewed by Ryosuke Niwa.
+
+ Report domains using abnormally high CPU usage (> 20%) via enhanced privacy
+ logging.
+
+ * page/DiagnosticLoggingKeys.cpp:
+ (WebCore::DiagnosticLoggingKeys::domainCausingEnergyDrainKey):
+ * page/DiagnosticLoggingKeys.h:
+ * page/PerformanceMonitor.cpp:
+ (WebCore::reportPageOverPostLoadCPUUsageThreshold):
+ (WebCore::PerformanceMonitor::measurePostLoadCPUUsage):
+
2017-02-23 Zalan Bujtas <za...@apple.com>
Simple line layout: Adjust RunResolver::lineIndexForHeight with line struts.
Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp (212919 => 212920)
--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp 2017-02-23 20:51:42 UTC (rev 212919)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp 2017-02-23 20:56:54 UTC (rev 212920)
@@ -343,6 +343,11 @@
return ASCIILiteral("documentLoaderStopping");
}
+String DiagnosticLoggingKeys::domainCausingEnergyDrainKey()
+{
+ return ASCIILiteral("DomainCausingEnergyDrain");
+}
+
String DiagnosticLoggingKeys::domainVisitedKey()
{
return ASCIILiteral("DomainVisited");
Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.h (212919 => 212920)
--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.h 2017-02-23 20:51:42 UTC (rev 212919)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.h 2017-02-23 20:56:54 UTC (rev 212920)
@@ -50,6 +50,7 @@
static String diskCacheKey();
static String diskCacheAfterValidationKey();
static String documentLoaderStoppingKey();
+ static String domainCausingEnergyDrainKey();
static String domainVisitedKey();
static String engineFailedToLoadKey();
WEBCORE_EXPORT static String entryRightlyNotWarmedUpKey();
Modified: trunk/Source/WebCore/page/PerformanceMonitor.cpp (212919 => 212920)
--- trunk/Source/WebCore/page/PerformanceMonitor.cpp 2017-02-23 20:51:42 UTC (rev 212919)
+++ trunk/Source/WebCore/page/PerformanceMonitor.cpp 2017-02-23 20:56:54 UTC (rev 212920)
@@ -31,8 +31,10 @@
#include "DiagnosticLoggingClient.h"
#include "DiagnosticLoggingKeys.h"
#include "Logging.h"
+#include "MainFrame.h"
#include "Page.h"
#include "PerformanceLogging.h"
+#include "PublicSuffix.h"
#include "Settings.h"
namespace WebCore {
@@ -46,6 +48,8 @@
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.
+
static inline ActivityStateForCPUSampling activityStateForCPUSampling(ActivityState::Flags state)
{
if (!(state & ActivityState::IsVisible))
@@ -122,6 +126,23 @@
}
}
+static void reportPageOverPostLoadCPUUsageThreshold(Page& page)
+{
+#if ENABLE(PUBLIC_SUFFIX_LIST)
+ auto* document = page.mainFrame().document();
+ if (!document)
+ return;
+
+ String domain = topPrivatelyControlledDomain(document->url().host());
+ if (domain.isEmpty())
+ return;
+
+ page.diagnosticLoggingClient().logDiagnosticMessageWithEnhancedPrivacy(DiagnosticLoggingKeys::domainCausingEnergyDrainKey(), domain, ShouldSample::No);
+#else
+ UNUSED_PARAM(page);
+#endif
+}
+
void PerformanceMonitor::measurePostLoadCPUUsage()
{
if (!m_page.isOnlyNonUtilityPage()) {
@@ -142,6 +163,9 @@
double cpuUsage = cpuTime.value().percentageCPUUsageSince(*m_postLoadCPUTime);
RELEASE_LOG_IF_ALLOWED(PerformanceLogging, "measurePostLoadCPUUsage: Process was using %.1f%% CPU after the page load.", cpuUsage);
m_page.diagnosticLoggingClient().logDiagnosticMessage(DiagnosticLoggingKeys::postPageLoadCPUUsageKey(), DiagnosticLoggingKeys::foregroundCPUUsageToDiagnosticLoggingKey(cpuUsage), ShouldSample::No);
+
+ if (cpuUsage > postPageLoadCPUUsageDomainReportingThreshold)
+ reportPageOverPostLoadCPUUsageThreshold(m_page);
}
void PerformanceMonitor::measurePostLoadMemoryUsage()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes