Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 AddBeginImplFrameLatency(base::TimeDelta delta) = 0; |
| 30 virtual void AddBeginMainFrameQueueDurationCriticalDuration( | 30 virtual void AddBeginMainFrameQueueDurationCriticalDuration( |
| 31 base::TimeDelta duration) = 0; | 31 base::TimeDelta duration) = 0; |
| 32 virtual void AddBeginMainFrameQueueDurationNotCriticalDuration( | 32 virtual void AddBeginMainFrameQueueDurationNotCriticalDuration( |
| 33 base::TimeDelta duration) = 0; | 33 base::TimeDelta duration) = 0; |
| 34 virtual void AddBeginMainFrameStartToCommitDuration( | 34 virtual void AddBeginMainFrameStartToCommitDuration( |
| 35 base::TimeDelta duration) = 0; | 35 base::TimeDelta duration) = 0; |
| 36 virtual void AddCommitToReadyToActivateDuration(base::TimeDelta duration) = 0; | 36 virtual void AddCommitToReadyToActivateDuration(base::TimeDelta duration) = 0; |
| 37 virtual void AddPrepareTilesDuration(base::TimeDelta duration) = 0; | 37 virtual void AddPrepareTilesDuration(base::TimeDelta duration) = 0; |
| 38 virtual void AddActivateDuration(base::TimeDelta duration) = 0; | 38 virtual void AddActivateDuration(base::TimeDelta duration) = 0; |
| 39 virtual void AddDrawDuration(base::TimeDelta duration) = 0; | 39 virtual void AddDrawDuration(base::TimeDelta duration) = 0; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 | 192 |
| 193 void AddSubmitAckWasFast(bool was_fast) override { | 193 void AddSubmitAckWasFast(bool was_fast) override { |
| 194 UMA_HISTOGRAM_BOOLEAN("Scheduling.Renderer.SwapAckWasFast", was_fast); | 194 UMA_HISTOGRAM_BOOLEAN("Scheduling.Renderer.SwapAckWasFast", was_fast); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override { | 197 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override { |
| 198 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( | 198 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( |
| 199 "Scheduling.Renderer.MainAndImplFrameTimeDelta", delta); | 199 "Scheduling.Renderer.MainAndImplFrameTimeDelta", delta); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void AddBeginMainFrameLatency(base::TimeDelta delta) override { | 202 void AddBeginImplFrameLatency(base::TimeDelta delta) override { |
|
brianderson
2017/03/16 19:11:56
Nit: Here and below, can you put the method in the
stanisc
2017/03/16 20:45:48
Done.
| |
| 203 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION( | 203 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION( |
| 204 "Scheduling.Renderer.VsyncToBeginMainFrameLatency", delta); | 204 "Scheduling.Renderer.VsyncToBeginImplFrameLatency", delta); |
| 205 } | 205 } |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter { | 208 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter { |
| 209 public: | 209 public: |
| 210 ~BrowserUMAReporter() override {} | 210 ~BrowserUMAReporter() override {} |
| 211 | 211 |
| 212 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override { | 212 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override { |
| 213 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( | 213 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( |
| 214 "Scheduling.Browser.BeginMainFrameIntervalCritical", interval); | 214 "Scheduling.Browser.BeginMainFrameIntervalCritical", interval); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 | 274 |
| 275 void AddSubmitAckWasFast(bool was_fast) override { | 275 void AddSubmitAckWasFast(bool was_fast) override { |
| 276 UMA_HISTOGRAM_BOOLEAN("Scheduling.Browser.SwapAckWasFast", was_fast); | 276 UMA_HISTOGRAM_BOOLEAN("Scheduling.Browser.SwapAckWasFast", was_fast); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override { | 279 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override { |
| 280 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( | 280 UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED( |
| 281 "Scheduling.Browser.MainAndImplFrameTimeDelta", delta); | 281 "Scheduling.Browser.MainAndImplFrameTimeDelta", delta); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void AddBeginMainFrameLatency(base::TimeDelta delta) override { | 284 void AddBeginImplFrameLatency(base::TimeDelta delta) override { |
| 285 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION( | 285 UMA_HISTOGRAM_CUSTOM_TIMES_DURATION( |
| 286 "Scheduling.Browser.VsyncToBeginMainFrameLatency", delta); | 286 "Scheduling.Browser.VsyncToBeginImplFrameLatency", delta); |
| 287 } | 287 } |
| 288 }; | 288 }; |
| 289 | 289 |
| 290 class NullUMAReporter : public CompositorTimingHistory::UMAReporter { | 290 class NullUMAReporter : public CompositorTimingHistory::UMAReporter { |
| 291 public: | 291 public: |
| 292 ~NullUMAReporter() override {} | 292 ~NullUMAReporter() override {} |
| 293 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override {} | 293 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override {} |
| 294 void AddBeginMainFrameIntervalNotCritical(base::TimeDelta interval) override { | 294 void AddBeginMainFrameIntervalNotCritical(base::TimeDelta interval) override { |
| 295 } | 295 } |
| 296 void AddCommitInterval(base::TimeDelta interval) override {} | 296 void AddCommitInterval(base::TimeDelta interval) override {} |
| 297 void AddDrawInterval(base::TimeDelta interval) override {} | 297 void AddDrawInterval(base::TimeDelta interval) override {} |
| 298 void AddBeginMainFrameQueueDurationCriticalDuration( | 298 void AddBeginMainFrameQueueDurationCriticalDuration( |
| 299 base::TimeDelta duration) override {} | 299 base::TimeDelta duration) override {} |
| 300 void AddBeginMainFrameQueueDurationNotCriticalDuration( | 300 void AddBeginMainFrameQueueDurationNotCriticalDuration( |
| 301 base::TimeDelta duration) override {} | 301 base::TimeDelta duration) override {} |
| 302 void AddBeginMainFrameStartToCommitDuration( | 302 void AddBeginMainFrameStartToCommitDuration( |
| 303 base::TimeDelta duration) override {} | 303 base::TimeDelta duration) override {} |
| 304 void AddCommitToReadyToActivateDuration(base::TimeDelta duration) override {} | 304 void AddCommitToReadyToActivateDuration(base::TimeDelta duration) override {} |
| 305 void AddPrepareTilesDuration(base::TimeDelta duration) override {} | 305 void AddPrepareTilesDuration(base::TimeDelta duration) override {} |
| 306 void AddActivateDuration(base::TimeDelta duration) override {} | 306 void AddActivateDuration(base::TimeDelta duration) override {} |
| 307 void AddDrawDuration(base::TimeDelta duration) override {} | 307 void AddDrawDuration(base::TimeDelta duration) override {} |
| 308 void AddSubmitToAckLatency(base::TimeDelta duration) override {} | 308 void AddSubmitToAckLatency(base::TimeDelta duration) override {} |
| 309 void AddSubmitAckWasFast(bool was_fast) override {} | 309 void AddSubmitAckWasFast(bool was_fast) override {} |
| 310 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override {} | 310 void AddMainAndImplFrameTimeDelta(base::TimeDelta delta) override {} |
| 311 void AddBeginMainFrameLatency(base::TimeDelta delta) override {} | 311 void AddBeginImplFrameLatency(base::TimeDelta delta) override {} |
| 312 }; | 312 }; |
| 313 | 313 |
| 314 } // namespace | 314 } // namespace |
| 315 | 315 |
| 316 CompositorTimingHistory::CompositorTimingHistory( | 316 CompositorTimingHistory::CompositorTimingHistory( |
| 317 bool using_synchronous_renderer_compositor, | 317 bool using_synchronous_renderer_compositor, |
| 318 UMACategory uma_category, | 318 UMACategory uma_category, |
| 319 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 319 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
| 320 : using_synchronous_renderer_compositor_( | 320 : using_synchronous_renderer_compositor_( |
| 321 using_synchronous_renderer_compositor), | 321 using_synchronous_renderer_compositor), |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 460 } | 460 } |
| 461 | 461 |
| 462 void CompositorTimingHistory::DidCreateAndInitializeCompositorFrameSink() { | 462 void CompositorTimingHistory::DidCreateAndInitializeCompositorFrameSink() { |
| 463 // 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 |
| 464 // CompositorFrameAck from the old output surface. | 464 // CompositorFrameAck from the old output surface. |
| 465 submit_start_time_ = base::TimeTicks(); | 465 submit_start_time_ = base::TimeTicks(); |
| 466 submit_ack_watchdog_enabled_ = false; | 466 submit_ack_watchdog_enabled_ = false; |
| 467 } | 467 } |
| 468 | 468 |
| 469 void CompositorTimingHistory::WillBeginImplFrame( | 469 void CompositorTimingHistory::WillBeginImplFrame( |
| 470 bool new_active_tree_is_likely) { | 470 bool new_active_tree_is_likely, |
| 471 base::TimeTicks frame_time, | |
| 472 BeginFrameArgs::BeginFrameArgsType frame_type) { | |
| 471 // The check for whether a BeginMainFrame was sent anytime between two | 473 // The check for whether a BeginMainFrame was sent anytime between two |
| 472 // BeginImplFrames protects us from not detecting a fast main thread that | 474 // BeginImplFrames protects us from not detecting a fast main thread that |
| 473 // does all it's work and goes idle in between BeginImplFrames. | 475 // does all it's work and goes idle in between BeginImplFrames. |
| 474 // For example, this may happen if an animation is being driven with | 476 // For example, this may happen if an animation is being driven with |
| 475 // setInterval(17) or if input events just happen to arrive in the | 477 // setInterval(17) or if input events just happen to arrive in the |
| 476 // middle of every frame. | 478 // middle of every frame. |
| 479 if (frame_type == BeginFrameArgs::NORMAL) | |
| 480 uma_reporter_->AddBeginImplFrameLatency(Now() - frame_time); | |
| 481 | |
| 477 if (!new_active_tree_is_likely && !did_send_begin_main_frame_) { | 482 if (!new_active_tree_is_likely && !did_send_begin_main_frame_) { |
| 478 SetBeginMainFrameNeededContinuously(false); | 483 SetBeginMainFrameNeededContinuously(false); |
| 479 SetBeginMainFrameCommittingContinuously(false); | 484 SetBeginMainFrameCommittingContinuously(false); |
| 480 } | 485 } |
| 481 | 486 |
| 482 if (submit_ack_watchdog_enabled_) { | 487 if (submit_ack_watchdog_enabled_) { |
| 483 base::TimeDelta submit_not_acked_time_ = Now() - submit_start_time_; | 488 base::TimeDelta submit_not_acked_time_ = Now() - submit_start_time_; |
| 484 if (submit_not_acked_time_ >= kSubmitAckWatchdogTimeout) { | 489 if (submit_not_acked_time_ >= kSubmitAckWatchdogTimeout) { |
| 485 uma_reporter_->AddSubmitAckWasFast(false); | 490 uma_reporter_->AddSubmitAckWasFast(false); |
| 486 // Only record this UMA once per submitted CompositorFrame. | 491 // Only record this UMA once per submitted CompositorFrame. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 497 } | 502 } |
| 498 | 503 |
| 499 void CompositorTimingHistory::BeginImplFrameNotExpectedSoon() { | 504 void CompositorTimingHistory::BeginImplFrameNotExpectedSoon() { |
| 500 SetBeginMainFrameNeededContinuously(false); | 505 SetBeginMainFrameNeededContinuously(false); |
| 501 SetBeginMainFrameCommittingContinuously(false); | 506 SetBeginMainFrameCommittingContinuously(false); |
| 502 SetCompositorDrawingContinuously(false); | 507 SetCompositorDrawingContinuously(false); |
| 503 } | 508 } |
| 504 | 509 |
| 505 void CompositorTimingHistory::WillBeginMainFrame( | 510 void CompositorTimingHistory::WillBeginMainFrame( |
| 506 bool on_critical_path, | 511 bool on_critical_path, |
| 507 base::TimeTicks main_frame_time, | 512 base::TimeTicks main_frame_time) { |
| 508 BeginFrameArgs::BeginFrameArgsType frame_type) { | |
| 509 DCHECK_EQ(base::TimeTicks(), begin_main_frame_sent_time_); | 513 DCHECK_EQ(base::TimeTicks(), begin_main_frame_sent_time_); |
| 510 DCHECK_EQ(base::TimeTicks(), begin_main_frame_frame_time_); | 514 DCHECK_EQ(base::TimeTicks(), begin_main_frame_frame_time_); |
| 511 | 515 |
| 512 begin_main_frame_on_critical_path_ = on_critical_path; | 516 begin_main_frame_on_critical_path_ = on_critical_path; |
| 513 begin_main_frame_sent_time_ = Now(); | 517 begin_main_frame_sent_time_ = Now(); |
| 514 begin_main_frame_frame_time_ = main_frame_time; | 518 begin_main_frame_frame_time_ = main_frame_time; |
| 515 | 519 |
| 516 if (frame_type == BeginFrameArgs::NORMAL) { | |
| 517 uma_reporter_->AddBeginMainFrameLatency(begin_main_frame_sent_time_ - | |
| 518 begin_main_frame_frame_time_); | |
| 519 } | |
| 520 | |
| 521 did_send_begin_main_frame_ = true; | 520 did_send_begin_main_frame_ = true; |
| 522 SetBeginMainFrameNeededContinuously(true); | 521 SetBeginMainFrameNeededContinuously(true); |
| 523 } | 522 } |
| 524 | 523 |
| 525 void CompositorTimingHistory::BeginMainFrameStarted( | 524 void CompositorTimingHistory::BeginMainFrameStarted( |
| 526 base::TimeTicks main_thread_start_time) { | 525 base::TimeTicks main_thread_start_time) { |
| 527 DCHECK_NE(base::TimeTicks(), begin_main_frame_sent_time_); | 526 DCHECK_NE(base::TimeTicks(), begin_main_frame_sent_time_); |
| 528 DCHECK_EQ(base::TimeTicks(), begin_main_frame_start_time_); | 527 DCHECK_EQ(base::TimeTicks(), begin_main_frame_start_time_); |
| 529 begin_main_frame_start_time_ = main_thread_start_time; | 528 begin_main_frame_start_time_ = main_thread_start_time; |
| 530 } | 529 } |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 uma_reporter_->AddSubmitToAckLatency(submit_to_ack_duration); | 741 uma_reporter_->AddSubmitToAckLatency(submit_to_ack_duration); |
| 743 if (submit_ack_watchdog_enabled_) { | 742 if (submit_ack_watchdog_enabled_) { |
| 744 bool was_fast = submit_to_ack_duration < kSubmitAckWatchdogTimeout; | 743 bool was_fast = submit_to_ack_duration < kSubmitAckWatchdogTimeout; |
| 745 uma_reporter_->AddSubmitAckWasFast(was_fast); | 744 uma_reporter_->AddSubmitAckWasFast(was_fast); |
| 746 submit_ack_watchdog_enabled_ = false; | 745 submit_ack_watchdog_enabled_ = false; |
| 747 } | 746 } |
| 748 submit_start_time_ = base::TimeTicks(); | 747 submit_start_time_ = base::TimeTicks(); |
| 749 } | 748 } |
| 750 | 749 |
| 751 } // namespace cc | 750 } // namespace cc |
| OLD | NEW |