Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Side by Side Diff: cc/scheduler/compositor_timing_history.cc

Issue 2752573002: Add BeginFrameLatency UMA (Closed)
Patch Set: Skip frames that originate from BeginFrameArgs::MISSED args Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/scheduler/compositor_timing_history.h" 5 #include "cc/scheduler/compositor_timing_history.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "cc/debug/rendering_stats_instrumentation.h" 13 #include "cc/debug/rendering_stats_instrumentation.h"
14 14
15 namespace cc { 15 namespace cc {
16 16
17 class CompositorTimingHistory::UMAReporter { 17 class CompositorTimingHistory::UMAReporter {
18 public: 18 public:
19 virtual ~UMAReporter() {} 19 virtual ~UMAReporter() {}
20 20
21 // Throughput measurements 21 // Throughput measurements
22 virtual void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) = 0; 22 virtual void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) = 0;
23 virtual void AddBeginMainFrameIntervalNotCritical( 23 virtual void AddBeginMainFrameIntervalNotCritical(
24 base::TimeDelta interval) = 0; 24 base::TimeDelta interval) = 0;
25 virtual void AddCommitInterval(base::TimeDelta interval) = 0; 25 virtual void AddCommitInterval(base::TimeDelta interval) = 0;
26 virtual void AddDrawInterval(base::TimeDelta interval) = 0; 26 virtual void AddDrawInterval(base::TimeDelta interval) = 0;
27 27
28 // Latency measurements 28 // Latency measurements
29 virtual void AddBeginMainFrameLatency(base::TimeDelta delta) = 0;
29 virtual void AddBeginMainFrameQueueDurationCriticalDuration( 30 virtual void AddBeginMainFrameQueueDurationCriticalDuration(
30 base::TimeDelta duration) = 0; 31 base::TimeDelta duration) = 0;
31 virtual void AddBeginMainFrameQueueDurationNotCriticalDuration( 32 virtual void AddBeginMainFrameQueueDurationNotCriticalDuration(
32 base::TimeDelta duration) = 0; 33 base::TimeDelta duration) = 0;
33 virtual void AddBeginMainFrameStartToCommitDuration( 34 virtual void AddBeginMainFrameStartToCommitDuration(
34 base::TimeDelta duration) = 0; 35 base::TimeDelta duration) = 0;
35 virtual void AddCommitToReadyToActivateDuration(base::TimeDelta duration) = 0; 36 virtual void AddCommitToReadyToActivateDuration(base::TimeDelta duration) = 0;
36 virtual void AddPrepareTilesDuration(base::TimeDelta duration) = 0; 37 virtual void AddPrepareTilesDuration(base::TimeDelta duration) = 0;
37 virtual void AddActivateDuration(base::TimeDelta duration) = 0; 38 virtual void AddActivateDuration(base::TimeDelta duration) = 0;
38 virtual void AddDrawDuration(base::TimeDelta duration) = 0; 39 virtual void AddDrawDuration(base::TimeDelta duration) = 0;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 191 }
191 192
192 void AddSubmitAckWasFast(bool was_fast) override { 193 void AddSubmitAckWasFast(bool was_fast) override {
193 UMA_HISTOGRAM_BOOLEAN("Scheduling.Renderer.SwapAckWasFast", was_fast); 194 UMA_HISTOGRAM_BOOLEAN("Scheduling.Renderer.SwapAckWasFast", was_fast);
194 } 195 }
195 196
196 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override { 197 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override {
197 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( 198 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED(
198 "Scheduling.Renderer.MainAndImplFrameTimeDelta", delta); 199 "Scheduling.Renderer.MainAndImplFrameTimeDelta", delta);
199 } 200 }
201
202 void AddBeginMainFrameLatency(base::TimeDelta delta) override {
203 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION(
204 "Scheduling.Renderer.VsyncToBeginMainFrameLatency", delta);
205 }
200 }; 206 };
201 207
202 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter { 208 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter {
203 public: 209 public:
204 ~BrowserUMAReporter() override {} 210 ~BrowserUMAReporter() override {}
205 211
206 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override { 212 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override {
207 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( 213 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED(
208 "Scheduling.Browser.BeginMainFrameIntervalCritical", interval); 214 "Scheduling.Browser.BeginMainFrameIntervalCritical", interval);
209 } 215 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 273 }
268 274
269 void AddSubmitAckWasFast(bool was_fast) override { 275 void AddSubmitAckWasFast(bool was_fast) override {
270 UMA_HISTOGRAM_BOOLEAN("Scheduling.Browser.SwapAckWasFast", was_fast); 276 UMA_HISTOGRAM_BOOLEAN("Scheduling.Browser.SwapAckWasFast", was_fast);
271 } 277 }
272 278
273 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override { 279 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override {
274 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( 280 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED(
275 "Scheduling.Browser.MainAndImplFrameTimeDelta", delta); 281 "Scheduling.Browser.MainAndImplFrameTimeDelta", delta);
276 } 282 }
283
284 void AddBeginMainFrameLatency(base::TimeDelta delta) override {
285 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION(
286 "Scheduling.Browser.VsyncToBeginMainFrameLatency", delta);
287 }
277 }; 288 };
278 289
279 class NullUMAReporter : public CompositorTimingHistory::UMAReporter { 290 class NullUMAReporter : public CompositorTimingHistory::UMAReporter {
280 public: 291 public:
281 ~NullUMAReporter() override {} 292 ~NullUMAReporter() override {}
282 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override {} 293 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override {}
283 void AddBeginMainFrameIntervalNotCritical(base::TimeDelta interval) override { 294 void AddBeginMainFrameIntervalNotCritical(base::TimeDelta interval) override {
284 } 295 }
285 void AddCommitInterval(base::TimeDelta interval) override {} 296 void AddCommitInterval(base::TimeDelta interval) override {}
286 void AddDrawInterval(base::TimeDelta interval) override {} 297 void AddDrawInterval(base::TimeDelta interval) override {}
287 void AddBeginMainFrameQueueDurationCriticalDuration( 298 void AddBeginMainFrameQueueDurationCriticalDuration(
288 base::TimeDelta duration) override {} 299 base::TimeDelta duration) override {}
289 void AddBeginMainFrameQueueDurationNotCriticalDuration( 300 void AddBeginMainFrameQueueDurationNotCriticalDuration(
290 base::TimeDelta duration) override {} 301 base::TimeDelta duration) override {}
291 void AddBeginMainFrameStartToCommitDuration( 302 void AddBeginMainFrameStartToCommitDuration(
292 base::TimeDelta duration) override {} 303 base::TimeDelta duration) override {}
293 void AddCommitToReadyToActivateDuration(base::TimeDelta duration) override {} 304 void AddCommitToReadyToActivateDuration(base::TimeDelta duration) override {}
294 void AddPrepareTilesDuration(base::TimeDelta duration) override {} 305 void AddPrepareTilesDuration(base::TimeDelta duration) override {}
295 void AddActivateDuration(base::TimeDelta duration) override {} 306 void AddActivateDuration(base::TimeDelta duration) override {}
296 void AddDrawDuration(base::TimeDelta duration) override {} 307 void AddDrawDuration(base::TimeDelta duration) override {}
297 void AddSubmitToAckLatency(base::TimeDelta duration) override {} 308 void AddSubmitToAckLatency(base::TimeDelta duration) override {}
298 void AddSubmitAckWasFast(bool was_fast) override {} 309 void AddSubmitAckWasFast(bool was_fast) override {}
299 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override {} 310 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override {}
311 void AddBeginMainFrameLatency(base::TimeDelta delta) override {}
300 }; 312 };
301 313
302 } // namespace 314 } // namespace
303 315
304 CompositorTimingHistory::CompositorTimingHistory( 316 CompositorTimingHistory::CompositorTimingHistory(
305 bool using_synchronous_renderer_compositor, 317 bool using_synchronous_renderer_compositor,
306 UMACategory uma_category, 318 UMACategory uma_category,
307 RenderingStatsInstrumentation* rendering_stats_instrumentation) 319 RenderingStatsInstrumentation* rendering_stats_instrumentation)
308 : using_synchronous_renderer_compositor_( 320 : using_synchronous_renderer_compositor_(
309 using_synchronous_renderer_compositor), 321 using_synchronous_renderer_compositor),
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 return draw_duration_history_.Percentile(kDrawEstimationPercentile); 459 return draw_duration_history_.Percentile(kDrawEstimationPercentile);
448 } 460 }
449 461
450 void CompositorTimingHistory::DidCreateAndInitializeCompositorFrameSink() { 462 void CompositorTimingHistory::DidCreateAndInitializeCompositorFrameSink() {
451 // After we get a new output surface, we won't get a spurious 463 // After we get a new output surface, we won't get a spurious
452 // CompositorFrameAck from the old output surface. 464 // CompositorFrameAck from the old output surface.
453 submit_start_time_ = base::TimeTicks(); 465 submit_start_time_ = base::TimeTicks();
454 submit_ack_watchdog_enabled_ = false; 466 submit_ack_watchdog_enabled_ = false;
455 } 467 }
456 468
457 void CompositorTimingHistory::WillBeginImplFrame( 469 void CompositorTimingHistory::WillBeginImplFrame(
brianderson 2017/03/15 21:08:05 You may want to track the latency of this entry po
stanisc 2017/03/15 21:13:45 Thanks, I'll do an additional change to implement
458 bool new_active_tree_is_likely) { 470 bool new_active_tree_is_likely) {
459 // The check for whether a BeginMainFrame was sent anytime between two 471 // The check for whether a BeginMainFrame was sent anytime between two
460 // BeginImplFrames protects us from not detecting a fast main thread that 472 // BeginImplFrames protects us from not detecting a fast main thread that
461 // does all it's work and goes idle in between BeginImplFrames. 473 // does all it's work and goes idle in between BeginImplFrames.
462 // For example, this may happen if an animation is being driven with 474 // For example, this may happen if an animation is being driven with
463 // setInterval(17) or if input events just happen to arrive in the 475 // setInterval(17) or if input events just happen to arrive in the
464 // middle of every frame. 476 // middle of every frame.
465 if (!new_active_tree_is_likely && !did_send_begin_main_frame_) { 477 if (!new_active_tree_is_likely && !did_send_begin_main_frame_) {
466 SetBeginMainFrameNeededContinuously(false); 478 SetBeginMainFrameNeededContinuously(false);
467 SetBeginMainFrameCommittingContinuously(false); 479 SetBeginMainFrameCommittingContinuously(false);
(...skipping 17 matching lines...) Expand all
485 } 497 }
486 498
487 void CompositorTimingHistory::BeginImplFrameNotExpectedSoon() { 499 void CompositorTimingHistory::BeginImplFrameNotExpectedSoon() {
488 SetBeginMainFrameNeededContinuously(false); 500 SetBeginMainFrameNeededContinuously(false);
489 SetBeginMainFrameCommittingContinuously(false); 501 SetBeginMainFrameCommittingContinuously(false);
490 SetCompositorDrawingContinuously(false); 502 SetCompositorDrawingContinuously(false);
491 } 503 }
492 504
493 void CompositorTimingHistory::WillBeginMainFrame( 505 void CompositorTimingHistory::WillBeginMainFrame(
494 bool on_critical_path, 506 bool on_critical_path,
495 base::TimeTicks main_frame_time) { 507 base::TimeTicks main_frame_time,
508 BeginFrameArgs::BeginFrameArgsType frame_type) {
496 DCHECK_EQ(base::TimeTicks(), begin_main_frame_sent_time_); 509 DCHECK_EQ(base::TimeTicks(), begin_main_frame_sent_time_);
497 DCHECK_EQ(base::TimeTicks(), begin_main_frame_frame_time_); 510 DCHECK_EQ(base::TimeTicks(), begin_main_frame_frame_time_);
498 511
499 begin_main_frame_on_critical_path_ = on_critical_path; 512 begin_main_frame_on_critical_path_ = on_critical_path;
500 begin_main_frame_sent_time_ = Now(); 513 begin_main_frame_sent_time_ = Now();
501 begin_main_frame_frame_time_ = main_frame_time; 514 begin_main_frame_frame_time_ = main_frame_time;
502 515
516 if (frame_type == BeginFrameArgs::NORMAL) {
517 uma_reporter_->AddBeginMainFrameLatency(begin_main_frame_sent_time_ -
518 begin_main_frame_frame_time_);
519 }
520
503 did_send_begin_main_frame_ = true; 521 did_send_begin_main_frame_ = true;
504 SetBeginMainFrameNeededContinuously(true); 522 SetBeginMainFrameNeededContinuously(true);
505 } 523 }
506 524
507 void CompositorTimingHistory::BeginMainFrameStarted( 525 void CompositorTimingHistory::BeginMainFrameStarted(
508 base::TimeTicks main_thread_start_time) { 526 base::TimeTicks main_thread_start_time) {
509 DCHECK_NE(base::TimeTicks(), begin_main_frame_sent_time_); 527 DCHECK_NE(base::TimeTicks(), begin_main_frame_sent_time_);
510 DCHECK_EQ(base::TimeTicks(), begin_main_frame_start_time_); 528 DCHECK_EQ(base::TimeTicks(), begin_main_frame_start_time_);
511 begin_main_frame_start_time_ = main_thread_start_time; 529 begin_main_frame_start_time_ = main_thread_start_time;
512 } 530 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 uma_reporter_->AddSubmitToAckLatency(submit_to_ack_duration); 742 uma_reporter_->AddSubmitToAckLatency(submit_to_ack_duration);
725 if (submit_ack_watchdog_enabled_) { 743 if (submit_ack_watchdog_enabled_) {
726 bool was_fast = submit_to_ack_duration < kSubmitAckWatchdogTimeout; 744 bool was_fast = submit_to_ack_duration < kSubmitAckWatchdogTimeout;
727 uma_reporter_->AddSubmitAckWasFast(was_fast); 745 uma_reporter_->AddSubmitAckWasFast(was_fast);
728 submit_ack_watchdog_enabled_ = false; 746 submit_ack_watchdog_enabled_ = false;
729 } 747 }
730 submit_start_time_ = base::TimeTicks(); 748 submit_start_time_ = base::TimeTicks();
731 } 749 }
732 750
733 } // namespace cc 751 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/compositor_timing_history.h ('k') | cc/scheduler/compositor_timing_history_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698