| 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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 virtual void AddPrepareTilesDuration(base::TimeDelta duration, | 43 virtual void AddPrepareTilesDuration(base::TimeDelta duration, |
| 44 base::TimeDelta estimate, | 44 base::TimeDelta estimate, |
| 45 bool affects_estimate) = 0; | 45 bool affects_estimate) = 0; |
| 46 virtual void AddActivateDuration(base::TimeDelta duration, | 46 virtual void AddActivateDuration(base::TimeDelta duration, |
| 47 base::TimeDelta estimate, | 47 base::TimeDelta estimate, |
| 48 bool affects_estimate) = 0; | 48 bool affects_estimate) = 0; |
| 49 virtual void AddDrawDuration(base::TimeDelta duration, | 49 virtual void AddDrawDuration(base::TimeDelta duration, |
| 50 base::TimeDelta estimate, | 50 base::TimeDelta estimate, |
| 51 bool affects_estimate) = 0; | 51 bool affects_estimate) = 0; |
| 52 virtual void AddSwapToAckLatency(base::TimeDelta duration) = 0; | 52 virtual void AddSwapToAckLatency(base::TimeDelta duration) = 0; |
| 53 |
| 54 // Synchronization measurements |
| 55 virtual void AddMainAndImplSynchronized(bool synchronized); |
| 53 }; | 56 }; |
| 54 | 57 |
| 55 namespace { | 58 namespace { |
| 56 | 59 |
| 57 // Using the 90th percentile will disable latency recovery | 60 // Using the 90th percentile will disable latency recovery |
| 58 // if we are missing the deadline approximately ~6 times per | 61 // if we are missing the deadline approximately ~6 times per |
| 59 // second. | 62 // second. |
| 60 // TODO(brianderson): Fine tune the percentiles below. | 63 // TODO(brianderson): Fine tune the percentiles below. |
| 61 const size_t kDurationHistorySize = 60; | 64 const size_t kDurationHistorySize = 60; |
| 62 const double kBeginMainFrameToCommitEstimationPercentile = 90.0; | 65 const double kBeginMainFrameToCommitEstimationPercentile = 90.0; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 base::TimeDelta estimate, | 212 base::TimeDelta estimate, |
| 210 bool affects_estimate) override { | 213 bool affects_estimate) override { |
| 211 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Renderer", "Draw"); | 214 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Renderer", "Draw"); |
| 212 DeprecatedDrawDurationUMA(duration, estimate); | 215 DeprecatedDrawDurationUMA(duration, estimate); |
| 213 } | 216 } |
| 214 | 217 |
| 215 void AddSwapToAckLatency(base::TimeDelta duration) override { | 218 void AddSwapToAckLatency(base::TimeDelta duration) override { |
| 216 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling.Renderer.SwapToAckLatency", | 219 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling.Renderer.SwapToAckLatency", |
| 217 duration); | 220 duration); |
| 218 } | 221 } |
| 222 |
| 223 void AddMainAndImplSynchronized(bool synchronized) override { |
| 224 UMA_HISTOGRAM_BOOLEAN("Scheduling.Renderer.MainAndImplSynchronized", |
| 225 synchronized); |
| 226 } |
| 219 }; | 227 }; |
| 220 | 228 |
| 221 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter { | 229 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter { |
| 222 public: | 230 public: |
| 223 ~BrowserUMAReporter() override {} | 231 ~BrowserUMAReporter() override {} |
| 224 | 232 |
| 225 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override { | 233 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override { |
| 226 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS( | 234 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS( |
| 227 "Scheduling.Browser.BeginMainFrameIntervalCritical", interval); | 235 "Scheduling.Browser.BeginMainFrameIntervalCritical", interval); |
| 228 } | 236 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 base::TimeDelta estimate, | 298 base::TimeDelta estimate, |
| 291 bool affects_estimate) override { | 299 bool affects_estimate) override { |
| 292 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "Draw"); | 300 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "Draw"); |
| 293 DeprecatedDrawDurationUMA(duration, estimate); | 301 DeprecatedDrawDurationUMA(duration, estimate); |
| 294 } | 302 } |
| 295 | 303 |
| 296 void AddSwapToAckLatency(base::TimeDelta duration) override { | 304 void AddSwapToAckLatency(base::TimeDelta duration) override { |
| 297 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling.Browser.SwapToAckLatency", | 305 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling.Browser.SwapToAckLatency", |
| 298 duration); | 306 duration); |
| 299 } | 307 } |
| 308 |
| 309 void AddMainAndImplSynchronized(bool synchronized) override { |
| 310 UMA_HISTOGRAM_BOOLEAN("Scheduling.Browser.MainAndImplSynchronized", |
| 311 synchronized); |
| 312 } |
| 300 }; | 313 }; |
| 301 | 314 |
| 302 class NullUMAReporter : public CompositorTimingHistory::UMAReporter { | 315 class NullUMAReporter : public CompositorTimingHistory::UMAReporter { |
| 303 public: | 316 public: |
| 304 ~NullUMAReporter() override {} | 317 ~NullUMAReporter() override {} |
| 305 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override {} | 318 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override {} |
| 306 void AddBeginMainFrameIntervalNotCritical(base::TimeDelta interval) override { | 319 void AddBeginMainFrameIntervalNotCritical(base::TimeDelta interval) override { |
| 307 } | 320 } |
| 308 void AddCommitInterval(base::TimeDelta interval) override {} | 321 void AddCommitInterval(base::TimeDelta interval) override {} |
| 309 void AddDrawInterval(base::TimeDelta interval) override {} | 322 void AddDrawInterval(base::TimeDelta interval) override {} |
| (...skipping 14 matching lines...) Expand all Loading... |
| 324 void AddPrepareTilesDuration(base::TimeDelta duration, | 337 void AddPrepareTilesDuration(base::TimeDelta duration, |
| 325 base::TimeDelta estimate, | 338 base::TimeDelta estimate, |
| 326 bool affects_estimate) override {} | 339 bool affects_estimate) override {} |
| 327 void AddActivateDuration(base::TimeDelta duration, | 340 void AddActivateDuration(base::TimeDelta duration, |
| 328 base::TimeDelta estimate, | 341 base::TimeDelta estimate, |
| 329 bool affects_estimate) override {} | 342 bool affects_estimate) override {} |
| 330 void AddDrawDuration(base::TimeDelta duration, | 343 void AddDrawDuration(base::TimeDelta duration, |
| 331 base::TimeDelta estimate, | 344 base::TimeDelta estimate, |
| 332 bool affects_estimate) override {} | 345 bool affects_estimate) override {} |
| 333 void AddSwapToAckLatency(base::TimeDelta duration) override {} | 346 void AddSwapToAckLatency(base::TimeDelta duration) override {} |
| 347 void AddMainAndImplSynchronized(bool synchronized) override {} |
| 334 }; | 348 }; |
| 335 | 349 |
| 336 } // namespace | 350 } // namespace |
| 337 | 351 |
| 338 CompositorTimingHistory::CompositorTimingHistory( | 352 CompositorTimingHistory::CompositorTimingHistory( |
| 339 UMACategory uma_category, | 353 UMACategory uma_category, |
| 340 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 354 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
| 341 : enabled_(false), | 355 : enabled_(false), |
| 342 did_send_begin_main_frame_(false), | 356 did_send_begin_main_frame_(false), |
| 343 begin_main_frame_needed_continuously_(false), | 357 begin_main_frame_needed_continuously_(false), |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 activate_duration_history_.InsertSample(activate_duration); | 665 activate_duration_history_.InsertSample(activate_duration); |
| 652 | 666 |
| 653 activate_start_time_ = base::TimeTicks(); | 667 activate_start_time_ = base::TimeTicks(); |
| 654 } | 668 } |
| 655 | 669 |
| 656 void CompositorTimingHistory::WillDraw() { | 670 void CompositorTimingHistory::WillDraw() { |
| 657 DCHECK_EQ(base::TimeTicks(), draw_start_time_); | 671 DCHECK_EQ(base::TimeTicks(), draw_start_time_); |
| 658 draw_start_time_ = Now(); | 672 draw_start_time_ = Now(); |
| 659 } | 673 } |
| 660 | 674 |
| 661 void CompositorTimingHistory::DidDraw(bool used_new_active_tree) { | 675 void CompositorTimingHistory::DidDraw(bool used_new_active_tree, |
| 676 bool main_thread_missed_last_deadline) { |
| 662 DCHECK_NE(base::TimeTicks(), draw_start_time_); | 677 DCHECK_NE(base::TimeTicks(), draw_start_time_); |
| 663 base::TimeTicks draw_end_time = Now(); | 678 base::TimeTicks draw_end_time = Now(); |
| 664 base::TimeDelta draw_duration = draw_end_time - draw_start_time_; | 679 base::TimeDelta draw_duration = draw_end_time - draw_start_time_; |
| 665 | 680 |
| 666 // Before adding the new data point to the timing history, see what we would | 681 // Before adding the new data point to the timing history, see what we would |
| 667 // have predicted for this frame. This allows us to keep track of the accuracy | 682 // have predicted for this frame. This allows us to keep track of the accuracy |
| 668 // of our predictions. | 683 // of our predictions. |
| 669 base::TimeDelta draw_estimate = DrawDurationEstimate(); | 684 base::TimeDelta draw_estimate = DrawDurationEstimate(); |
| 670 rendering_stats_instrumentation_->AddDrawDuration(draw_duration, | 685 rendering_stats_instrumentation_->AddDrawDuration(draw_duration, |
| 671 draw_estimate); | 686 draw_estimate); |
| 672 | 687 |
| 673 uma_reporter_->AddDrawDuration(draw_duration, draw_estimate, enabled_); | 688 uma_reporter_->AddDrawDuration(draw_duration, draw_estimate, enabled_); |
| 674 | 689 |
| 675 if (enabled_) { | 690 if (enabled_) { |
| 676 draw_duration_history_.InsertSample(draw_duration); | 691 draw_duration_history_.InsertSample(draw_duration); |
| 677 } | 692 } |
| 678 | 693 |
| 679 SetCompositorDrawingContinuously(true); | 694 SetCompositorDrawingContinuously(true); |
| 680 if (!draw_end_time_prev_.is_null()) { | 695 if (!draw_end_time_prev_.is_null()) { |
| 681 base::TimeDelta draw_interval = draw_end_time - draw_end_time_prev_; | 696 base::TimeDelta draw_interval = draw_end_time - draw_end_time_prev_; |
| 682 uma_reporter_->AddDrawInterval(draw_interval); | 697 uma_reporter_->AddDrawInterval(draw_interval); |
| 683 } | 698 } |
| 684 draw_end_time_prev_ = draw_end_time; | 699 draw_end_time_prev_ = draw_end_time; |
| 685 | 700 |
| 686 if (begin_main_frame_committing_continuously_ && used_new_active_tree) { | 701 if (used_new_active_tree) { |
| 687 if (!new_active_tree_draw_end_time_prev_.is_null()) { | 702 uma_reporter_->AddMainAndImplSynchronized( |
| 688 base::TimeDelta draw_interval = | 703 !main_thread_missed_last_deadline); |
| 689 draw_end_time - new_active_tree_draw_end_time_prev_; | 704 if (begin_main_frame_committing_continuously_) { |
| 690 uma_reporter_->AddCommitInterval(draw_interval); | 705 if (!new_active_tree_draw_end_time_prev_.is_null()) { |
| 706 base::TimeDelta draw_interval = |
| 707 draw_end_time - new_active_tree_draw_end_time_prev_; |
| 708 uma_reporter_->AddCommitInterval(draw_interval); |
| 709 } |
| 710 new_active_tree_draw_end_time_prev_ = draw_end_time; |
| 691 } | 711 } |
| 692 new_active_tree_draw_end_time_prev_ = draw_end_time; | |
| 693 } | 712 } |
| 694 | 713 |
| 695 draw_start_time_ = base::TimeTicks(); | 714 draw_start_time_ = base::TimeTicks(); |
| 696 } | 715 } |
| 697 | 716 |
| 698 void CompositorTimingHistory::DidSwapBuffers() { | 717 void CompositorTimingHistory::DidSwapBuffers() { |
| 699 DCHECK_EQ(base::TimeTicks(), swap_start_time_); | 718 DCHECK_EQ(base::TimeTicks(), swap_start_time_); |
| 700 swap_start_time_ = Now(); | 719 swap_start_time_ = Now(); |
| 701 } | 720 } |
| 702 | 721 |
| 703 void CompositorTimingHistory::DidSwapBuffersComplete() { | 722 void CompositorTimingHistory::DidSwapBuffersComplete() { |
| 704 DCHECK_NE(base::TimeTicks(), swap_start_time_); | 723 DCHECK_NE(base::TimeTicks(), swap_start_time_); |
| 705 base::TimeDelta swap_to_ack_duration = Now() - swap_start_time_; | 724 base::TimeDelta swap_to_ack_duration = Now() - swap_start_time_; |
| 706 uma_reporter_->AddSwapToAckLatency(swap_to_ack_duration); | 725 uma_reporter_->AddSwapToAckLatency(swap_to_ack_duration); |
| 707 swap_start_time_ = base::TimeTicks(); | 726 swap_start_time_ = base::TimeTicks(); |
| 708 } | 727 } |
| 709 | 728 |
| 710 void CompositorTimingHistory::DidSwapBuffersReset() { | 729 void CompositorTimingHistory::DidSwapBuffersReset() { |
| 711 swap_start_time_ = base::TimeTicks(); | 730 swap_start_time_ = base::TimeTicks(); |
| 712 } | 731 } |
| 713 | 732 |
| 714 } // namespace cc | 733 } // namespace cc |
| OLD | NEW |