Commit aa3bb574 authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Add UMA for durations of hung render processes.

BUG=823087

Change-Id: I8f01414bbeb1472f2fe062afa5b4c66f4bf1f621
Reviewed-on: https://chromium-review.googlesource.com/972184Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544920}
parent faf8f150
...@@ -1044,6 +1044,7 @@ void RenderWidgetHostImpl::StartHangMonitorTimeout(TimeDelta delay) { ...@@ -1044,6 +1044,7 @@ void RenderWidgetHostImpl::StartHangMonitorTimeout(TimeDelta delay) {
if (!hang_monitor_timeout_) if (!hang_monitor_timeout_)
return; return;
hang_monitor_timeout_->Start(delay); hang_monitor_timeout_->Start(delay);
hang_monitor_start_time_ = clock_->NowTicks();
} }
void RenderWidgetHostImpl::RestartHangMonitorTimeoutIfNecessary() { void RenderWidgetHostImpl::RestartHangMonitorTimeoutIfNecessary() {
...@@ -1058,6 +1059,16 @@ bool RenderWidgetHostImpl::IsCurrentlyUnresponsive() const { ...@@ -1058,6 +1059,16 @@ bool RenderWidgetHostImpl::IsCurrentlyUnresponsive() const {
void RenderWidgetHostImpl::StopHangMonitorTimeout() { void RenderWidgetHostImpl::StopHangMonitorTimeout() {
if (hang_monitor_timeout_) if (hang_monitor_timeout_)
hang_monitor_timeout_->Stop(); hang_monitor_timeout_->Stop();
if (!hang_monitor_start_time_.is_null()) {
base::TimeDelta elapsed = clock_->NowTicks() - hang_monitor_start_time_;
const base::TimeDelta kMinimumHangTimeToReport =
base::TimeDelta::FromSeconds(5);
if (elapsed >= kMinimumHangTimeToReport)
UMA_HISTOGRAM_LONG_TIMES("Renderer.Hung.Duration", elapsed);
hang_monitor_start_time_ = TimeTicks();
}
RendererIsResponsive(); RendererIsResponsive();
} }
......
...@@ -1004,6 +1004,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl ...@@ -1004,6 +1004,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl
std::unique_ptr<InputRouter> input_router_; std::unique_ptr<InputRouter> input_router_;
std::unique_ptr<TimeoutMonitor> hang_monitor_timeout_; std::unique_ptr<TimeoutMonitor> hang_monitor_timeout_;
base::TimeTicks hang_monitor_start_time_;
std::unique_ptr<TimeoutMonitor> new_content_rendering_timeout_; std::unique_ptr<TimeoutMonitor> new_content_rendering_timeout_;
......
...@@ -15,7 +15,9 @@ ...@@ -15,7 +15,9 @@
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/test/histogram_tester.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "build/build_config.h" #include "build/build_config.h"
...@@ -3131,4 +3133,29 @@ TEST_F(RenderWidgetHostTest, NavigateInBackgroundShowsBlank) { ...@@ -3131,4 +3133,29 @@ TEST_F(RenderWidgetHostTest, NavigateInBackgroundShowsBlank) {
EXPECT_TRUE(host_->new_content_rendering_timeout_fired()); EXPECT_TRUE(host_->new_content_rendering_timeout_fired());
} }
TEST_F(RenderWidgetHostTest, RendererHangRecordsMetrics) {
base::SimpleTestTickClock clock;
host_->set_clock_for_testing(&clock);
base::HistogramTester tester;
// RenderWidgetHost makes private the methods it overrides from
// InputRouterClient. Call them through the base class.
InputRouterClient* input_router_client = host_.get();
// Do a 3s hang. This shouldn't affect metrics.
input_router_client->IncrementInFlightEventCount();
clock.Advance(base::TimeDelta::FromSeconds(3));
input_router_client->DecrementInFlightEventCount(
InputEventAckSource::UNKNOWN);
tester.ExpectTotalCount("Renderer.Hung.Duration", 0u);
// Do a 17s hang. This should affect metrics.
input_router_client->IncrementInFlightEventCount();
clock.Advance(base::TimeDelta::FromSeconds(17));
input_router_client->DecrementInFlightEventCount(
InputEventAckSource::UNKNOWN);
tester.ExpectTotalCount("Renderer.Hung.Duration", 1u);
tester.ExpectUniqueSample("Renderer.Hung.Duration", 17000, 1);
}
} // namespace content } // namespace content
...@@ -72006,6 +72006,18 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -72006,6 +72006,18 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary> </summary>
</histogram> </histogram>
<histogram name="Renderer.Hung.Duration" units="ms">
<owner>avi@chromium.org</owner>
<summary>
The length of time render processes are hung, in milliseconds. Note that
because technically speaking render processes are &quot;hung&quot; from the
moment an input event is sent to them until the moment that they return an
ACK, only hangs of minimum length 5s are recorded. Note that this combines
measurements from both renderer processes that recover on their own, and
render processes that are killed.
</summary>
</histogram>
<histogram name="Renderer.Hung.MobileInfoBar.UserEvent" <histogram name="Renderer.Hung.MobileInfoBar.UserEvent"
enum="MobileHungRendererInfoBarEvent"> enum="MobileHungRendererInfoBarEvent">
<owner>dfalcantara@chromium.org</owner> <owner>dfalcantara@chromium.org</owner>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment