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 "platform/scheduler/renderer/renderer_scheduler_impl.h" | 5 #include "platform/scheduler/renderer/renderer_scheduler_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/stack_trace.h" | 8 #include "base/debug/stack_trace.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 // the cost of loading tasks. | 29 // the cost of loading tasks. |
| 30 const int kLoadingTaskEstimationSampleCount = 1000; | 30 const int kLoadingTaskEstimationSampleCount = 1000; |
| 31 const double kLoadingTaskEstimationPercentile = 99; | 31 const double kLoadingTaskEstimationPercentile = 99; |
| 32 const int kTimerTaskEstimationSampleCount = 1000; | 32 const int kTimerTaskEstimationSampleCount = 1000; |
| 33 const double kTimerTaskEstimationPercentile = 99; | 33 const double kTimerTaskEstimationPercentile = 99; |
| 34 const int kShortIdlePeriodDurationSampleCount = 10; | 34 const int kShortIdlePeriodDurationSampleCount = 10; |
| 35 const double kShortIdlePeriodDurationPercentile = 50; | 35 const double kShortIdlePeriodDurationPercentile = 50; |
| 36 // Amount of idle time left in a frame (as a ratio of the vsync interval) above | 36 // Amount of idle time left in a frame (as a ratio of the vsync interval) above |
| 37 // which main thread compositing can be considered fast. | 37 // which main thread compositing can be considered fast. |
| 38 const double kFastCompositingIdleTimeThreshold = .2; | 38 const double kFastCompositingIdleTimeThreshold = .2; |
| 39 | |
| 40 base::TimeTicks MonotonicTimeInSecondsToTimeTicks(double monotonicTimeInSeconds) { | |
| 41 return base::TimeTicks::FromInternalValue( | |
|
alph
2016/08/22 22:21:27
nit: Consider the following one, as it ensures bet
panicker
2016/08/22 23:29:46
What's the an equivalent counterpart for convertin
alph
2016/08/22 23:51:07
Added it as a comment.
panicker
2016/08/25 23:11:52
Done.
| |
| 42 monotonicTimeInSeconds * base::Time::kMicrosecondsPerSecond); | |
| 43 } | |
| 39 } // namespace | 44 } // namespace |
| 40 | 45 |
| 41 RendererSchedulerImpl::RendererSchedulerImpl( | 46 RendererSchedulerImpl::RendererSchedulerImpl( |
| 42 scoped_refptr<SchedulerTqmDelegate> main_task_runner) | 47 scoped_refptr<SchedulerTqmDelegate> main_task_runner) |
| 43 : helper_(main_task_runner, | 48 : helper_(main_task_runner, |
| 44 "renderer.scheduler", | 49 "renderer.scheduler", |
| 45 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 50 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 46 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler.debug")), | 51 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler.debug")), |
| 47 idle_helper_(&helper_, | 52 idle_helper_(&helper_, |
| 48 this, | 53 this, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 74 weak_factory_.GetWeakPtr())); | 79 weak_factory_.GetWeakPtr())); |
| 75 | 80 |
| 76 default_loading_task_runner_ = NewLoadingTaskRunner("default_loading_tq"); | 81 default_loading_task_runner_ = NewLoadingTaskRunner("default_loading_tq"); |
| 77 default_timer_task_runner_ = NewTimerTaskRunner("default_timer_tq"); | 82 default_timer_task_runner_ = NewTimerTaskRunner("default_timer_tq"); |
| 78 | 83 |
| 79 TRACE_EVENT_OBJECT_CREATED_WITH_ID( | 84 TRACE_EVENT_OBJECT_CREATED_WITH_ID( |
| 80 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", | 85 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", |
| 81 this); | 86 this); |
| 82 | 87 |
| 83 helper_.SetObserver(this); | 88 helper_.SetObserver(this); |
| 84 helper_.SetTaskTimeTracker(this); | 89 helper_.AddTaskTimeObserver(this); |
| 85 } | 90 } |
| 86 | 91 |
| 87 RendererSchedulerImpl::~RendererSchedulerImpl() { | 92 RendererSchedulerImpl::~RendererSchedulerImpl() { |
| 88 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 93 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
| 89 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", | 94 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", |
| 90 this); | 95 this); |
| 91 | 96 |
| 92 for (const scoped_refptr<TaskQueue>& loading_queue : loading_task_runners_) { | 97 for (const scoped_refptr<TaskQueue>& loading_queue : loading_task_runners_) { |
| 93 loading_queue->RemoveTaskObserver( | 98 loading_queue->RemoveTaskObserver( |
| 94 &MainThreadOnly().loading_task_cost_estimator); | 99 &MainThreadOnly().loading_task_cost_estimator); |
| 95 } | 100 } |
| 96 for (const scoped_refptr<TaskQueue>& timer_queue : timer_task_runners_) { | 101 for (const scoped_refptr<TaskQueue>& timer_queue : timer_task_runners_) { |
| 97 timer_queue->RemoveTaskObserver( | 102 timer_queue->RemoveTaskObserver( |
| 98 &MainThreadOnly().timer_task_cost_estimator); | 103 &MainThreadOnly().timer_task_cost_estimator); |
| 99 } | 104 } |
| 100 | 105 |
| 101 if (virtual_time_domain_) | 106 if (virtual_time_domain_) |
| 102 UnregisterTimeDomain(virtual_time_domain_.get()); | 107 UnregisterTimeDomain(virtual_time_domain_.get()); |
| 103 | 108 |
| 109 helper_.RemoveTaskTimeObserver(this); | |
| 110 | |
| 104 // Ensure the renderer scheduler was shut down explicitly, because otherwise | 111 // Ensure the renderer scheduler was shut down explicitly, because otherwise |
| 105 // we could end up having stale pointers to the Blink heap which has been | 112 // we could end up having stale pointers to the Blink heap which has been |
| 106 // terminated by this point. | 113 // terminated by this point. |
| 107 DCHECK(MainThreadOnly().was_shutdown); | 114 DCHECK(MainThreadOnly().was_shutdown); |
| 108 } | 115 } |
| 109 | 116 |
| 110 RendererSchedulerImpl::MainThreadOnly::MainThreadOnly( | 117 RendererSchedulerImpl::MainThreadOnly::MainThreadOnly( |
| 111 RendererSchedulerImpl* renderer_scheduler_impl, | 118 RendererSchedulerImpl* renderer_scheduler_impl, |
| 112 const scoped_refptr<TaskQueue>& compositor_task_runner, | 119 const scoped_refptr<TaskQueue>& compositor_task_runner, |
| 113 base::TickClock* time_source) | 120 base::TickClock* time_source) |
| (...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1400 true; | 1407 true; |
| 1401 BroadcastIntervention( | 1408 BroadcastIntervention( |
| 1402 "Blink deferred a task in order to make scrolling smoother. " | 1409 "Blink deferred a task in order to make scrolling smoother. " |
| 1403 "Your timer and network tasks should take less than 50ms to run " | 1410 "Your timer and network tasks should take less than 50ms to run " |
| 1404 "to avoid this. Please see " | 1411 "to avoid this. Please see " |
| 1405 "https://developers.google.com/web/tools/chrome-devtools/profile/evaluat e-performance/rail" | 1412 "https://developers.google.com/web/tools/chrome-devtools/profile/evaluat e-performance/rail" |
| 1406 " and https://crbug.com/574343#c40 for more information."); | 1413 " and https://crbug.com/574343#c40 for more information."); |
| 1407 } | 1414 } |
| 1408 } | 1415 } |
| 1409 | 1416 |
| 1410 void RendererSchedulerImpl::ReportTaskTime(base::TimeTicks start_time, | 1417 void RendererSchedulerImpl::reportTaskTime(double start_time, |
|
Sami
2016/08/22 15:51:30
FYI, altimin@ is adding another task time consumer
panicker
2016/08/22 23:14:15
Acknowledged.
| |
| 1411 base::TimeTicks end_time) { | 1418 double end_time) { |
| 1412 MainThreadOnly().queueing_time_estimator.OnToplevelTaskCompleted(start_time, | 1419 base::TimeTicks start_time_ticks = MonotonicTimeInSecondsToTimeTicks(start_tim e); |
| 1413 end_time); | 1420 base::TimeTicks end_time_ticks = MonotonicTimeInSecondsToTimeTicks(end_time); |
| 1414 MainThreadOnly().long_task_tracker.RecordLongTask( | 1421 |
| 1415 start_time, end_time - start_time); | 1422 MainThreadOnly().queueing_time_estimator.OnToplevelTaskCompleted(start_time_ti cks, |
| 1423 end_time_tick s); | |
| 1416 UMA_HISTOGRAM_CUSTOM_COUNTS("RendererScheduler.TaskTime", | 1424 UMA_HISTOGRAM_CUSTOM_COUNTS("RendererScheduler.TaskTime", |
| 1417 (end_time - start_time).InMicroseconds(), 1, | 1425 (end_time_ticks - start_time_ticks).InMicroseconds (), 1, |
| 1418 1000000, 50); | 1426 1000000, 50); |
| 1419 } | 1427 } |
| 1420 | 1428 |
| 1421 LongTaskTracker::LongTaskTiming RendererSchedulerImpl::GetLongTaskTiming() { | 1429 void RendererSchedulerImpl::AddTaskTimeObserver( |
| 1422 return MainThreadOnly().long_task_tracker.GetLongTaskTiming(); | 1430 WebThread::TaskTimeObserver* task_time_observer) { |
| 1431 helper_.AddTaskTimeObserver(task_time_observer); | |
| 1432 } | |
| 1433 | |
| 1434 void RendererSchedulerImpl::RemoveTaskTimeObserver( | |
| 1435 WebThread::TaskTimeObserver* task_time_observer) { | |
| 1436 helper_.RemoveTaskTimeObserver(task_time_observer); | |
| 1423 } | 1437 } |
| 1424 | 1438 |
| 1425 void RendererSchedulerImpl::OnQueueingTimeForWindowEstimated( | 1439 void RendererSchedulerImpl::OnQueueingTimeForWindowEstimated( |
| 1426 base::TimeDelta queueing_time) { | 1440 base::TimeDelta queueing_time) { |
| 1427 UMA_HISTOGRAM_TIMES("RendererScheduler.ExpectedTaskQueueingDuration", | 1441 UMA_HISTOGRAM_TIMES("RendererScheduler.ExpectedTaskQueueingDuration", |
| 1428 queueing_time); | 1442 queueing_time); |
| 1429 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 1443 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 1430 "estimated_queueing_time_for_window", | 1444 "estimated_queueing_time_for_window", |
| 1431 queueing_time.InMillisecondsF()); | 1445 queueing_time.InMillisecondsF()); |
| 1432 } | 1446 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1488 case v8::PERFORMANCE_LOAD: | 1502 case v8::PERFORMANCE_LOAD: |
| 1489 return "load"; | 1503 return "load"; |
| 1490 default: | 1504 default: |
| 1491 NOTREACHED(); | 1505 NOTREACHED(); |
| 1492 return nullptr; | 1506 return nullptr; |
| 1493 } | 1507 } |
| 1494 } | 1508 } |
| 1495 | 1509 |
| 1496 } // namespace scheduler | 1510 } // namespace scheduler |
| 1497 } // namespace blink | 1511 } // namespace blink |
| OLD | NEW |