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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "cc/debug/rendering_stats_instrumentation.h" | 9 #include "cc/debug/rendering_stats_instrumentation.h" |
10 | 10 |
11 namespace cc { | 11 namespace cc { |
12 | 12 |
13 class CompositorTimingHistory::UMAReporter { | 13 class CompositorTimingHistory::UMAReporter { |
14 public: | 14 public: |
15 virtual ~UMAReporter() {} | 15 virtual ~UMAReporter() {} |
16 | 16 |
17 virtual void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, | 17 virtual void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, |
18 base::TimeDelta estimate, | 18 base::TimeDelta estimate, |
19 bool affects_estimate) = 0; | 19 bool affects_estimate) = 0; |
| 20 virtual void AddBeginMainFrameQueueDurationCriticalDuration( |
| 21 base::TimeDelta duration, |
| 22 bool affects_estimate) = 0; |
| 23 virtual void AddBeginMainFrameQueueDurationNotCriticalDuration( |
| 24 base::TimeDelta duration, |
| 25 bool affects_estimate) = 0; |
| 26 virtual void AddBeginMainFrameStartToCommitDuration( |
| 27 base::TimeDelta duration, |
| 28 bool affects_estimate) = 0; |
20 virtual void AddCommitToReadyToActivateDuration(base::TimeDelta duration, | 29 virtual void AddCommitToReadyToActivateDuration(base::TimeDelta duration, |
21 base::TimeDelta estimate, | 30 base::TimeDelta estimate, |
22 bool affects_estimate) = 0; | 31 bool affects_estimate) = 0; |
23 virtual void AddPrepareTilesDuration(base::TimeDelta duration, | 32 virtual void AddPrepareTilesDuration(base::TimeDelta duration, |
24 base::TimeDelta estimate, | 33 base::TimeDelta estimate, |
25 bool affects_estimate) = 0; | 34 bool affects_estimate) = 0; |
26 virtual void AddActivateDuration(base::TimeDelta duration, | 35 virtual void AddActivateDuration(base::TimeDelta duration, |
27 base::TimeDelta estimate, | 36 base::TimeDelta estimate, |
28 bool affects_estimate) = 0; | 37 bool affects_estimate) = 0; |
29 virtual void AddDrawDuration(base::TimeDelta duration, | 38 virtual void AddDrawDuration(base::TimeDelta duration, |
30 base::TimeDelta estimate, | 39 base::TimeDelta estimate, |
31 bool affects_estimate) = 0; | 40 bool affects_estimate) = 0; |
32 }; | 41 }; |
33 | 42 |
34 namespace { | 43 namespace { |
35 | 44 |
36 // Using the 90th percentile will disable latency recovery | 45 // Using the 90th percentile will disable latency recovery |
37 // if we are missing the deadline approximately ~6 times per | 46 // if we are missing the deadline approximately ~6 times per |
38 // second. | 47 // second. |
39 // TODO(brianderson): Fine tune the percentiles below. | 48 // TODO(brianderson): Fine tune the percentiles below. |
40 const size_t kDurationHistorySize = 60; | 49 const size_t kDurationHistorySize = 60; |
41 const double kBeginMainFrameToCommitEstimationPercentile = 90.0; | 50 const double kBeginMainFrameToCommitEstimationPercentile = 90.0; |
| 51 const double kBeginMainFrameQueueDurationCriticalEstimationPercentile = 90.0; |
| 52 const double kBeginMainFrameQueueDurationNotCriticalEstimationPercentile = 90.0; |
| 53 const double kBeginMainFrameStartToCommitEstimationPercentile = 90.0; |
42 const double kCommitToReadyToActivateEstimationPercentile = 90.0; | 54 const double kCommitToReadyToActivateEstimationPercentile = 90.0; |
43 const double kPrepareTilesEstimationPercentile = 90.0; | 55 const double kPrepareTilesEstimationPercentile = 90.0; |
44 const double kActivateEstimationPercentile = 90.0; | 56 const double kActivateEstimationPercentile = 90.0; |
45 const double kDrawEstimationPercentile = 90.0; | 57 const double kDrawEstimationPercentile = 90.0; |
46 | 58 |
47 const int kUmaDurationMinMicros = 1; | 59 const int kUmaDurationMinMicros = 1; |
48 const int64 kUmaDurationMaxMicros = 1 * base::Time::kMicrosecondsPerSecond; | 60 const int64 kUmaDurationMaxMicros = 1 * base::Time::kMicrosecondsPerSecond; |
49 const size_t kUmaDurationBucketCount = 100; | 61 const size_t kUmaDurationBucketCount = 100; |
50 | 62 |
51 // Deprecated because they combine Browser and Renderer stats and have low | 63 // Deprecated because they combine Browser and Renderer stats and have low |
(...skipping 18 matching lines...) Expand all Loading... |
70 duration_overestimate, | 82 duration_overestimate, |
71 base::TimeDelta::FromMilliseconds(1), | 83 base::TimeDelta::FromMilliseconds(1), |
72 base::TimeDelta::FromMilliseconds(100), 50); | 84 base::TimeDelta::FromMilliseconds(100), 50); |
73 } | 85 } |
74 | 86 |
75 #define UMA_HISTOGRAM_CUSTOM_TIMES_MICROS(name, sample) \ | 87 #define UMA_HISTOGRAM_CUSTOM_TIMES_MICROS(name, sample) \ |
76 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample.InMicroseconds(), \ | 88 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample.InMicroseconds(), \ |
77 kUmaDurationMinMicros, kUmaDurationMaxMicros, \ | 89 kUmaDurationMinMicros, kUmaDurationMaxMicros, \ |
78 kUmaDurationBucketCount); | 90 kUmaDurationBucketCount); |
79 | 91 |
| 92 // Records over/under estimates. |
80 #define REPORT_COMPOSITOR_TIMING_HISTORY_UMA(category, subcategory) \ | 93 #define REPORT_COMPOSITOR_TIMING_HISTORY_UMA(category, subcategory) \ |
81 do { \ | 94 do { \ |
82 base::TimeDelta duration_overestimate; \ | 95 base::TimeDelta duration_overestimate; \ |
83 base::TimeDelta duration_underestimate; \ | 96 base::TimeDelta duration_underestimate; \ |
84 if (duration > estimate) \ | 97 if (duration > estimate) \ |
85 duration_underestimate = duration - estimate; \ | 98 duration_underestimate = duration - estimate; \ |
86 else \ | 99 else \ |
87 duration_overestimate = estimate - duration; \ | 100 duration_overestimate = estimate - duration; \ |
88 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS( \ | 101 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS( \ |
89 "Scheduling." category "." subcategory "Duration", duration); \ | 102 "Scheduling." category "." subcategory "Duration", duration); \ |
90 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling." category "." subcategory \ | 103 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling." category "." subcategory \ |
91 "Duration.Underestimate", \ | 104 "Duration.Underestimate", \ |
92 duration_underestimate); \ | 105 duration_underestimate); \ |
93 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling." category "." subcategory \ | 106 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling." category "." subcategory \ |
94 "Duration.Overestimate", \ | 107 "Duration.Overestimate", \ |
95 duration_overestimate); \ | 108 duration_overestimate); \ |
96 if (!affects_estimate) { \ | 109 if (!affects_estimate) { \ |
97 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling." category "." subcategory \ | 110 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling." category "." subcategory \ |
98 "Duration.NotUsedForEstimate", \ | 111 "Duration.NotUsedForEstimate", \ |
99 duration); \ | 112 duration); \ |
100 } \ | 113 } \ |
101 } while (false) | 114 } while (false) |
102 | 115 |
| 116 // Does not record over/under estimates. |
| 117 #define REPORT_COMPOSITOR_TIMING_HISTORY_UMA2(category, subcategory) \ |
| 118 do { \ |
| 119 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling." category "." subcategory, \ |
| 120 duration); \ |
| 121 if (!affects_estimate) { \ |
| 122 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling." category "." subcategory \ |
| 123 ".NotUsedForEstimate", \ |
| 124 duration); \ |
| 125 } \ |
| 126 } while (false) |
| 127 |
103 class RendererUMAReporter : public CompositorTimingHistory::UMAReporter { | 128 class RendererUMAReporter : public CompositorTimingHistory::UMAReporter { |
104 public: | 129 public: |
105 ~RendererUMAReporter() override {} | 130 ~RendererUMAReporter() override {} |
106 | 131 |
107 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, | 132 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, |
108 base::TimeDelta estimate, | 133 base::TimeDelta estimate, |
109 bool affects_estimate) override { | 134 bool affects_estimate) override { |
110 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Renderer", "BeginMainFrameToCommit"); | 135 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Renderer", "BeginMainFrameToCommit"); |
111 } | 136 } |
112 | 137 |
| 138 void AddBeginMainFrameQueueDurationCriticalDuration( |
| 139 base::TimeDelta duration, |
| 140 bool affects_estimate) override { |
| 141 REPORT_COMPOSITOR_TIMING_HISTORY_UMA2( |
| 142 "Renderer", "BeginMainFrameQueueDurationCritical"); |
| 143 } |
| 144 |
| 145 void AddBeginMainFrameQueueDurationNotCriticalDuration( |
| 146 base::TimeDelta duration, |
| 147 bool affects_estimate) override { |
| 148 REPORT_COMPOSITOR_TIMING_HISTORY_UMA2( |
| 149 "Renderer", "BeginMainFrameQueueDurationNotCritical"); |
| 150 } |
| 151 |
| 152 void AddBeginMainFrameStartToCommitDuration(base::TimeDelta duration, |
| 153 bool affects_estimate) override { |
| 154 REPORT_COMPOSITOR_TIMING_HISTORY_UMA2( |
| 155 "Renderer", "BeginMainFrameStartToCommitDuration"); |
| 156 } |
| 157 |
113 void AddCommitToReadyToActivateDuration(base::TimeDelta duration, | 158 void AddCommitToReadyToActivateDuration(base::TimeDelta duration, |
114 base::TimeDelta estimate, | 159 base::TimeDelta estimate, |
115 bool affects_estimate) override { | 160 bool affects_estimate) override { |
116 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Renderer", "CommitToReadyToActivate"); | 161 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Renderer", "CommitToReadyToActivate"); |
117 } | 162 } |
118 | 163 |
119 void AddPrepareTilesDuration(base::TimeDelta duration, | 164 void AddPrepareTilesDuration(base::TimeDelta duration, |
120 base::TimeDelta estimate, | 165 base::TimeDelta estimate, |
121 bool affects_estimate) override { | 166 bool affects_estimate) override { |
122 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Renderer", "PrepareTiles"); | 167 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Renderer", "PrepareTiles"); |
(...skipping 16 matching lines...) Expand all Loading... |
139 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter { | 184 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter { |
140 public: | 185 public: |
141 ~BrowserUMAReporter() override {} | 186 ~BrowserUMAReporter() override {} |
142 | 187 |
143 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, | 188 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, |
144 base::TimeDelta estimate, | 189 base::TimeDelta estimate, |
145 bool affects_estimate) override { | 190 bool affects_estimate) override { |
146 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "BeginMainFrameToCommit"); | 191 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "BeginMainFrameToCommit"); |
147 } | 192 } |
148 | 193 |
| 194 void AddBeginMainFrameQueueDurationCriticalDuration( |
| 195 base::TimeDelta duration, |
| 196 bool affects_estimate) override { |
| 197 REPORT_COMPOSITOR_TIMING_HISTORY_UMA2( |
| 198 "Browser", "BeginMainFrameQueueDurationCritical"); |
| 199 } |
| 200 |
| 201 void AddBeginMainFrameQueueDurationNotCriticalDuration( |
| 202 base::TimeDelta duration, |
| 203 bool affects_estimate) override { |
| 204 REPORT_COMPOSITOR_TIMING_HISTORY_UMA2( |
| 205 "Browser", "BeginMainFrameQueueDurationNotCritical"); |
| 206 } |
| 207 |
| 208 void AddBeginMainFrameStartToCommitDuration(base::TimeDelta duration, |
| 209 bool affects_estimate) override { |
| 210 REPORT_COMPOSITOR_TIMING_HISTORY_UMA2("Browser", |
| 211 "BeginMainFrameStartToCommit"); |
| 212 } |
| 213 |
149 void AddCommitToReadyToActivateDuration(base::TimeDelta duration, | 214 void AddCommitToReadyToActivateDuration(base::TimeDelta duration, |
150 base::TimeDelta estimate, | 215 base::TimeDelta estimate, |
151 bool affects_estimate) override { | 216 bool affects_estimate) override { |
152 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "CommitToReadyToActivate"); | 217 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "CommitToReadyToActivate"); |
153 } | 218 } |
154 | 219 |
155 void AddPrepareTilesDuration(base::TimeDelta duration, | 220 void AddPrepareTilesDuration(base::TimeDelta duration, |
156 base::TimeDelta estimate, | 221 base::TimeDelta estimate, |
157 bool affects_estimate) override { | 222 bool affects_estimate) override { |
158 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "PrepareTiles"); | 223 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "PrepareTiles"); |
159 } | 224 } |
160 | 225 |
161 void AddActivateDuration(base::TimeDelta duration, | 226 void AddActivateDuration(base::TimeDelta duration, |
162 base::TimeDelta estimate, | 227 base::TimeDelta estimate, |
163 bool affects_estimate) override { | 228 bool affects_estimate) override { |
164 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "Activate"); | 229 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "Activate"); |
165 } | 230 } |
166 | 231 |
167 void AddDrawDuration(base::TimeDelta duration, | 232 void AddDrawDuration(base::TimeDelta duration, |
168 base::TimeDelta estimate, | 233 base::TimeDelta estimate, |
169 bool affects_estimate) override { | 234 bool affects_estimate) override { |
170 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "Draw"); | 235 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "Draw"); |
171 DeprecatedDrawDurationUMA(duration, estimate); | 236 DeprecatedDrawDurationUMA(duration, estimate); |
172 } | 237 } |
173 }; | 238 }; |
174 | 239 |
175 class NullUMAReporter : public CompositorTimingHistory::UMAReporter { | 240 class NullUMAReporter : public CompositorTimingHistory::UMAReporter { |
176 public: | 241 public: |
177 ~NullUMAReporter() override {} | 242 ~NullUMAReporter() override {} |
| 243 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, |
| 244 base::TimeDelta estimate, |
| 245 bool affects_estimate) override {} |
| 246 void AddBeginMainFrameQueueDurationCriticalDuration( |
| 247 base::TimeDelta duration, |
| 248 bool affects_estimate) override {} |
| 249 void AddBeginMainFrameQueueDurationNotCriticalDuration( |
| 250 base::TimeDelta duration, |
| 251 bool affects_estimate) override {} |
| 252 void AddBeginMainFrameStartToCommitDuration(base::TimeDelta duration, |
| 253 bool affects_estimate) override {} |
| 254 void AddCommitToReadyToActivateDuration(base::TimeDelta duration, |
| 255 base::TimeDelta estimate, |
| 256 bool affects_estimate) override {} |
178 void AddPrepareTilesDuration(base::TimeDelta duration, | 257 void AddPrepareTilesDuration(base::TimeDelta duration, |
179 base::TimeDelta estimate, | 258 base::TimeDelta estimate, |
180 bool affects_estimate) override {} | 259 bool affects_estimate) override {} |
181 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, | |
182 base::TimeDelta estimate, | |
183 bool affects_estimate) override {} | |
184 void AddCommitToReadyToActivateDuration(base::TimeDelta duration, | |
185 base::TimeDelta estimate, | |
186 bool affects_estimate) override {} | |
187 void AddActivateDuration(base::TimeDelta duration, | 260 void AddActivateDuration(base::TimeDelta duration, |
188 base::TimeDelta estimate, | 261 base::TimeDelta estimate, |
189 bool affects_estimate) override {} | 262 bool affects_estimate) override {} |
190 void AddDrawDuration(base::TimeDelta duration, | 263 void AddDrawDuration(base::TimeDelta duration, |
191 base::TimeDelta estimate, | 264 base::TimeDelta estimate, |
192 bool affects_estimate) override {} | 265 bool affects_estimate) override {} |
193 }; | 266 }; |
194 | 267 |
195 } // namespace | 268 } // namespace |
196 | 269 |
197 CompositorTimingHistory::CompositorTimingHistory( | 270 CompositorTimingHistory::CompositorTimingHistory( |
198 UMACategory uma_category, | 271 UMACategory uma_category, |
199 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 272 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
200 : enabled_(false), | 273 : enabled_(false), |
201 begin_main_frame_to_commit_duration_history_(kDurationHistorySize), | 274 begin_main_frame_sent_to_commit_duration_history_(kDurationHistorySize), |
| 275 begin_main_frame_queue_duration_critical_history_(kDurationHistorySize), |
| 276 begin_main_frame_queue_duration_not_critical_history_( |
| 277 kDurationHistorySize), |
| 278 begin_main_frame_start_to_commit_duration_history_(kDurationHistorySize), |
202 commit_to_ready_to_activate_duration_history_(kDurationHistorySize), | 279 commit_to_ready_to_activate_duration_history_(kDurationHistorySize), |
203 prepare_tiles_duration_history_(kDurationHistorySize), | 280 prepare_tiles_duration_history_(kDurationHistorySize), |
204 activate_duration_history_(kDurationHistorySize), | 281 activate_duration_history_(kDurationHistorySize), |
205 draw_duration_history_(kDurationHistorySize), | 282 draw_duration_history_(kDurationHistorySize), |
| 283 begin_main_frame_on_critical_path_(false), |
206 uma_reporter_(CreateUMAReporter(uma_category)), | 284 uma_reporter_(CreateUMAReporter(uma_category)), |
207 rendering_stats_instrumentation_(rendering_stats_instrumentation) {} | 285 rendering_stats_instrumentation_(rendering_stats_instrumentation) {} |
208 | 286 |
209 CompositorTimingHistory::~CompositorTimingHistory() { | 287 CompositorTimingHistory::~CompositorTimingHistory() { |
210 } | 288 } |
211 | 289 |
212 scoped_ptr<CompositorTimingHistory::UMAReporter> | 290 scoped_ptr<CompositorTimingHistory::UMAReporter> |
213 CompositorTimingHistory::CreateUMAReporter(UMACategory category) { | 291 CompositorTimingHistory::CreateUMAReporter(UMACategory category) { |
214 switch (category) { | 292 switch (category) { |
215 case RENDERER_UMA: | 293 case RENDERER_UMA: |
(...skipping 27 matching lines...) Expand all Loading... |
243 base::TimeTicks CompositorTimingHistory::Now() const { | 321 base::TimeTicks CompositorTimingHistory::Now() const { |
244 return base::TimeTicks::Now(); | 322 return base::TimeTicks::Now(); |
245 } | 323 } |
246 | 324 |
247 void CompositorTimingHistory::SetRecordingEnabled(bool enabled) { | 325 void CompositorTimingHistory::SetRecordingEnabled(bool enabled) { |
248 enabled_ = enabled; | 326 enabled_ = enabled; |
249 } | 327 } |
250 | 328 |
251 base::TimeDelta | 329 base::TimeDelta |
252 CompositorTimingHistory::BeginMainFrameToCommitDurationEstimate() const { | 330 CompositorTimingHistory::BeginMainFrameToCommitDurationEstimate() const { |
253 return begin_main_frame_to_commit_duration_history_.Percentile( | 331 return begin_main_frame_sent_to_commit_duration_history_.Percentile( |
254 kBeginMainFrameToCommitEstimationPercentile); | 332 kBeginMainFrameToCommitEstimationPercentile); |
255 } | 333 } |
256 | 334 |
257 base::TimeDelta | 335 base::TimeDelta |
| 336 CompositorTimingHistory::BeginMainFrameQueueDurationCriticalEstimate() const { |
| 337 return begin_main_frame_queue_duration_critical_history_.Percentile( |
| 338 kBeginMainFrameQueueDurationCriticalEstimationPercentile); |
| 339 } |
| 340 |
| 341 base::TimeDelta |
| 342 CompositorTimingHistory::BeginMainFrameQueueDurationNotCriticalEstimate() |
| 343 const { |
| 344 return begin_main_frame_queue_duration_not_critical_history_.Percentile( |
| 345 kBeginMainFrameQueueDurationNotCriticalEstimationPercentile); |
| 346 } |
| 347 |
| 348 base::TimeDelta |
| 349 CompositorTimingHistory::BeginMainFrameStartToCommitDurationEstimate() const { |
| 350 return begin_main_frame_start_to_commit_duration_history_.Percentile( |
| 351 kBeginMainFrameStartToCommitEstimationPercentile); |
| 352 } |
| 353 |
| 354 base::TimeDelta |
258 CompositorTimingHistory::CommitToReadyToActivateDurationEstimate() const { | 355 CompositorTimingHistory::CommitToReadyToActivateDurationEstimate() const { |
259 return commit_to_ready_to_activate_duration_history_.Percentile( | 356 return commit_to_ready_to_activate_duration_history_.Percentile( |
260 kCommitToReadyToActivateEstimationPercentile); | 357 kCommitToReadyToActivateEstimationPercentile); |
261 } | 358 } |
262 | 359 |
263 base::TimeDelta CompositorTimingHistory::PrepareTilesDurationEstimate() const { | 360 base::TimeDelta CompositorTimingHistory::PrepareTilesDurationEstimate() const { |
264 return prepare_tiles_duration_history_.Percentile( | 361 return prepare_tiles_duration_history_.Percentile( |
265 kPrepareTilesEstimationPercentile); | 362 kPrepareTilesEstimationPercentile); |
266 } | 363 } |
267 | 364 |
268 base::TimeDelta CompositorTimingHistory::ActivateDurationEstimate() const { | 365 base::TimeDelta CompositorTimingHistory::ActivateDurationEstimate() const { |
269 return activate_duration_history_.Percentile(kActivateEstimationPercentile); | 366 return activate_duration_history_.Percentile(kActivateEstimationPercentile); |
270 } | 367 } |
271 | 368 |
272 base::TimeDelta CompositorTimingHistory::DrawDurationEstimate() const { | 369 base::TimeDelta CompositorTimingHistory::DrawDurationEstimate() const { |
273 return draw_duration_history_.Percentile(kDrawEstimationPercentile); | 370 return draw_duration_history_.Percentile(kDrawEstimationPercentile); |
274 } | 371 } |
275 | 372 |
276 void CompositorTimingHistory::WillBeginMainFrame() { | 373 void CompositorTimingHistory::WillBeginMainFrame(bool on_critical_path) { |
277 DCHECK_EQ(base::TimeTicks(), begin_main_frame_sent_time_); | 374 DCHECK_EQ(base::TimeTicks(), begin_main_frame_sent_time_); |
| 375 begin_main_frame_on_critical_path_ = on_critical_path; |
278 begin_main_frame_sent_time_ = Now(); | 376 begin_main_frame_sent_time_ = Now(); |
279 } | 377 } |
280 | 378 |
| 379 void CompositorTimingHistory::BeginMainFrameStarted( |
| 380 base::TimeTicks main_thread_start_time) { |
| 381 DCHECK_NE(base::TimeTicks(), begin_main_frame_sent_time_); |
| 382 DCHECK_EQ(base::TimeTicks(), begin_main_frame_start_time_); |
| 383 begin_main_frame_start_time_ = main_thread_start_time; |
| 384 } |
| 385 |
281 void CompositorTimingHistory::BeginMainFrameAborted() { | 386 void CompositorTimingHistory::BeginMainFrameAborted() { |
282 DidCommit(); | 387 DidCommit(); |
283 } | 388 } |
284 | 389 |
285 void CompositorTimingHistory::DidCommit() { | 390 void CompositorTimingHistory::DidCommit() { |
286 DCHECK_NE(base::TimeTicks(), begin_main_frame_sent_time_); | 391 DCHECK_NE(base::TimeTicks(), begin_main_frame_sent_time_); |
287 | 392 |
288 commit_time_ = Now(); | 393 commit_time_ = Now(); |
289 | 394 |
290 base::TimeDelta begin_main_frame_to_commit_duration = | 395 // If the BeginMainFrame start time isn't know, assume it was immediate |
| 396 // for scheduling purposes, but don't report it for UMA to avoid skewing |
| 397 // the results. |
| 398 bool begin_main_frame_start_time_is_valid = |
| 399 !begin_main_frame_start_time_.is_null(); |
| 400 if (!begin_main_frame_start_time_is_valid) |
| 401 begin_main_frame_start_time_ = begin_main_frame_sent_time_; |
| 402 |
| 403 base::TimeDelta begin_main_frame_sent_to_commit_duration = |
291 commit_time_ - begin_main_frame_sent_time_; | 404 commit_time_ - begin_main_frame_sent_time_; |
| 405 base::TimeDelta begin_main_frame_queue_duration = |
| 406 begin_main_frame_start_time_ - begin_main_frame_sent_time_; |
| 407 base::TimeDelta begin_main_frame_start_to_commit_duration = |
| 408 commit_time_ - begin_main_frame_start_time_; |
292 | 409 |
293 // Before adding the new data point to the timing history, see what we would | 410 // Before adding the new data point to the timing history, see what we would |
294 // have predicted for this frame. This allows us to keep track of the accuracy | 411 // have predicted for this frame. This allows us to keep track of the accuracy |
295 // of our predictions. | 412 // of our predictions. |
296 base::TimeDelta begin_main_frame_to_commit_estimate = | 413 base::TimeDelta begin_main_frame_sent_to_commit_estimate = |
297 BeginMainFrameToCommitDurationEstimate(); | 414 BeginMainFrameToCommitDurationEstimate(); |
298 uma_reporter_->AddBeginMainFrameToCommitDuration( | 415 uma_reporter_->AddBeginMainFrameToCommitDuration( |
299 begin_main_frame_to_commit_duration, begin_main_frame_to_commit_estimate, | 416 begin_main_frame_sent_to_commit_duration, |
300 enabled_); | 417 begin_main_frame_sent_to_commit_estimate, enabled_); |
301 rendering_stats_instrumentation_->AddBeginMainFrameToCommitDuration( | 418 rendering_stats_instrumentation_->AddBeginMainFrameToCommitDuration( |
302 begin_main_frame_to_commit_duration, begin_main_frame_to_commit_estimate); | 419 begin_main_frame_sent_to_commit_duration, |
| 420 begin_main_frame_sent_to_commit_estimate); |
| 421 |
| 422 if (begin_main_frame_start_time_is_valid) { |
| 423 if (begin_main_frame_on_critical_path_) { |
| 424 uma_reporter_->AddBeginMainFrameQueueDurationCriticalDuration( |
| 425 begin_main_frame_queue_duration, enabled_); |
| 426 } else { |
| 427 uma_reporter_->AddBeginMainFrameQueueDurationNotCriticalDuration( |
| 428 begin_main_frame_queue_duration, enabled_); |
| 429 } |
| 430 } |
| 431 |
| 432 uma_reporter_->AddBeginMainFrameStartToCommitDuration( |
| 433 begin_main_frame_start_to_commit_duration, enabled_); |
303 | 434 |
304 if (enabled_) { | 435 if (enabled_) { |
305 begin_main_frame_to_commit_duration_history_.InsertSample( | 436 begin_main_frame_sent_to_commit_duration_history_.InsertSample( |
306 begin_main_frame_to_commit_duration); | 437 begin_main_frame_sent_to_commit_duration); |
| 438 if (begin_main_frame_on_critical_path_) { |
| 439 begin_main_frame_queue_duration_critical_history_.InsertSample( |
| 440 begin_main_frame_queue_duration); |
| 441 } else { |
| 442 begin_main_frame_queue_duration_not_critical_history_.InsertSample( |
| 443 begin_main_frame_queue_duration); |
| 444 } |
| 445 begin_main_frame_start_to_commit_duration_history_.InsertSample( |
| 446 begin_main_frame_start_to_commit_duration); |
307 } | 447 } |
308 | 448 |
309 begin_main_frame_sent_time_ = base::TimeTicks(); | 449 begin_main_frame_sent_time_ = base::TimeTicks(); |
| 450 begin_main_frame_start_time_ = base::TimeTicks(); |
310 } | 451 } |
311 | 452 |
312 void CompositorTimingHistory::WillPrepareTiles() { | 453 void CompositorTimingHistory::WillPrepareTiles() { |
313 DCHECK_EQ(base::TimeTicks(), start_prepare_tiles_time_); | 454 DCHECK_EQ(base::TimeTicks(), start_prepare_tiles_time_); |
314 start_prepare_tiles_time_ = Now(); | 455 start_prepare_tiles_time_ = Now(); |
315 } | 456 } |
316 | 457 |
317 void CompositorTimingHistory::DidPrepareTiles() { | 458 void CompositorTimingHistory::DidPrepareTiles() { |
318 DCHECK_NE(base::TimeTicks(), start_prepare_tiles_time_); | 459 DCHECK_NE(base::TimeTicks(), start_prepare_tiles_time_); |
319 | 460 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 uma_reporter_->AddDrawDuration(draw_duration, draw_estimate, enabled_); | 530 uma_reporter_->AddDrawDuration(draw_duration, draw_estimate, enabled_); |
390 | 531 |
391 if (enabled_) { | 532 if (enabled_) { |
392 draw_duration_history_.InsertSample(draw_duration); | 533 draw_duration_history_.InsertSample(draw_duration); |
393 } | 534 } |
394 | 535 |
395 start_draw_time_ = base::TimeTicks(); | 536 start_draw_time_ = base::TimeTicks(); |
396 } | 537 } |
397 | 538 |
398 } // namespace cc | 539 } // namespace cc |
OLD | NEW |