We should log how much CPU a background process was using when killing it due to...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Apr 2017 22:22:24 +0000 (22:22 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Apr 2017 22:22:24 +0000 (22:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170619

Reviewed by Andreas Kling.

Source/WebCore:

CPUMonitor now passes the CPU usage to the callback when it exceeds the threashold.

* platform/CPUMonitor.cpp:
(WebCore::CPUMonitor::timerFired):
* platform/CPUMonitor.h:

Source/WebKit2:

* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::updateBackgroundCPUMonitorState):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215123 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/CPUMonitor.cpp
Source/WebCore/platform/CPUMonitor.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm

index a364f0b..40dc4fd 100644 (file)
@@ -1,5 +1,18 @@
 2017-04-07  Chris Dumez  <cdumez@apple.com>
 
+        We should log how much CPU a background process was using when killing it due to CPU limiting
+        https://bugs.webkit.org/show_bug.cgi?id=170619
+
+        Reviewed by Andreas Kling.
+
+        CPUMonitor now passes the CPU usage to the callback when it exceeds the threashold.
+
+        * platform/CPUMonitor.cpp:
+        (WebCore::CPUMonitor::timerFired):
+        * platform/CPUMonitor.h:
+
+2017-04-07  Chris Dumez  <cdumez@apple.com>
+
         Audible autoplay videos should not get paused when outside the viewport
         https://bugs.webkit.org/show_bug.cgi?id=170610
         <rdar://problem/31505984>
index 3235b62..2d3384c 100644 (file)
@@ -65,7 +65,7 @@ void CPUMonitor::timerFired()
 
     auto cpuUsagePercent = cpuTime.value().percentageCPUUsageSince(m_lastCPUTime.value());
     if (cpuUsagePercent > m_cpuLimit.value() * 100)
-        m_exceededCPULimitHandler();
+        m_exceededCPULimitHandler(cpuUsagePercent / 100.);
 
     m_lastCPUTime = cpuTime;
 }
index 2888268..afab6ea 100644 (file)
@@ -34,7 +34,7 @@ namespace WebCore {
 
 class CPUMonitor {
 public:
-    using ExceededCPULimitHandler = WTF::Function<void()>;
+    using ExceededCPULimitHandler = WTF::Function<void(double)>;
     WEBCORE_EXPORT CPUMonitor(Seconds checkInterval, ExceededCPULimitHandler&&);
 
     WEBCORE_EXPORT void setCPULimit(std::optional<double>);
index cf8fb99..ca3e7e1 100644 (file)
@@ -1,3 +1,13 @@
+2017-04-07  Chris Dumez  <cdumez@apple.com>
+
+        We should log how much CPU a background process was using when killing it due to CPU limiting
+        https://bugs.webkit.org/show_bug.cgi?id=170619
+
+        Reviewed by Andreas Kling.
+
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::updateBackgroundCPUMonitorState):
+
 2017-04-07  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Missing conversion from window to content coordinates when adjusting unobscured content rects for input view
index 78d3df5..caec46b 100644 (file)
@@ -430,8 +430,8 @@ void WebProcess::updateBackgroundCPUMonitorState()
     }
 
     if (!m_backgroundCPUMonitor) {
-        m_backgroundCPUMonitor = std::make_unique<CPUMonitor>(backgroundCPUMonitoringInterval, [this] {
-            RELEASE_LOG(PerformanceLogging, "%p - WebProcess exceeded background CPU limit of %.1f%%", this, m_backgroundCPULimit.value() * 100);
+        m_backgroundCPUMonitor = std::make_unique<CPUMonitor>(backgroundCPUMonitoringInterval, [this](double cpuUsage) {
+            RELEASE_LOG(PerformanceLogging, "%p - WebProcess exceeded background CPU limit of %.1f%% (was using %.1f%%)", this, m_backgroundCPULimit.value() * 100, cpuUsage * 100);
             parentProcessConnection()->send(Messages::WebProcessProxy::DidExceedBackgroundCPULimit(), 0);
         });
     }