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" |
| 11 #include "base/metrics/histogram.h" | |
| 11 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
| 15 #include "base/trace_event/trace_event_argument.h" | 16 #include "base/trace_event/trace_event_argument.h" |
| 16 #include "cc/output/begin_frame_args.h" | 17 #include "cc/output/begin_frame_args.h" |
| 17 #include "platform/RuntimeEnabledFeatures.h" | 18 #include "platform/RuntimeEnabledFeatures.h" |
| 18 #include "platform/scheduler/base/real_time_domain.h" | 19 #include "platform/scheduler/base/real_time_domain.h" |
| 19 #include "platform/scheduler/base/task_queue_impl.h" | 20 #include "platform/scheduler/base/task_queue_impl.h" |
| 20 #include "platform/scheduler/base/task_queue_selector.h" | 21 #include "platform/scheduler/base/task_queue_selector.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 42 // Amount of idle time left in a frame (as a ratio of the vsync interval) above | 43 // Amount of idle time left in a frame (as a ratio of the vsync interval) above |
| 43 // which main thread compositing can be considered fast. | 44 // which main thread compositing can be considered fast. |
| 44 const double kFastCompositingIdleTimeThreshold = .2; | 45 const double kFastCompositingIdleTimeThreshold = .2; |
| 45 constexpr base::TimeDelta kThreadLoadTrackerReportingInterval = | 46 constexpr base::TimeDelta kThreadLoadTrackerReportingInterval = |
| 46 base::TimeDelta::FromMinutes(1); | 47 base::TimeDelta::FromMinutes(1); |
| 47 constexpr base::TimeDelta kThreadLoadTrackerWaitingPeriodBeforeReporting = | 48 constexpr base::TimeDelta kThreadLoadTrackerWaitingPeriodBeforeReporting = |
| 48 base::TimeDelta::FromMinutes(2); | 49 base::TimeDelta::FromMinutes(2); |
| 49 // We do not throttle anything while audio is played and shortly after that. | 50 // We do not throttle anything while audio is played and shortly after that. |
| 50 constexpr base::TimeDelta kThrottlingDelayAfterAudioIsPlayed = | 51 constexpr base::TimeDelta kThrottlingDelayAfterAudioIsPlayed = |
| 51 base::TimeDelta::FromSeconds(5); | 52 base::TimeDelta::FromSeconds(5); |
| 53 // Maximal bound on task duration for reporting. | |
| 54 constexpr base::TimeDelta kMaxTaskDurationForReporting = | |
| 55 base::TimeDelta::FromMinutes(1); | |
| 52 | 56 |
| 53 void ReportForegroundRendererTaskLoad(base::TimeTicks time, double load) { | 57 void ReportForegroundRendererTaskLoad(base::TimeTicks time, double load) { |
| 54 if (!blink::RuntimeEnabledFeatures::timerThrottlingForBackgroundTabsEnabled()) | 58 if (!blink::RuntimeEnabledFeatures::timerThrottlingForBackgroundTabsEnabled()) |
| 55 return; | 59 return; |
| 56 | 60 |
| 57 int load_percentage = static_cast<int>(load * 100); | 61 int load_percentage = static_cast<int>(load * 100); |
| 58 // TODO(altimin): Revert back to DCHECK. | 62 // TODO(altimin): Revert back to DCHECK. |
| 59 CHECK_LE(load_percentage, 100); | 63 CHECK_LE(load_percentage, 100); |
| 60 | 64 |
| 61 UMA_HISTOGRAM_PERCENTAGE("RendererScheduler.ForegroundRendererMainThreadLoad", | 65 UMA_HISTOGRAM_PERCENTAGE("RendererScheduler.ForegroundRendererMainThreadLoad", |
| (...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1771 | 1775 |
| 1772 task_queue_throttler()->OnTaskRunTimeReported(task_queue, start_time_ticks, | 1776 task_queue_throttler()->OnTaskRunTimeReported(task_queue, start_time_ticks, |
| 1773 end_time_ticks); | 1777 end_time_ticks); |
| 1774 | 1778 |
| 1775 // We want to measure thread time here, but for efficiency reasons | 1779 // We want to measure thread time here, but for efficiency reasons |
| 1776 // we stick with wall time. | 1780 // we stick with wall time. |
| 1777 MainThreadOnly().foreground_main_thread_load_tracker.RecordTaskTime( | 1781 MainThreadOnly().foreground_main_thread_load_tracker.RecordTaskTime( |
| 1778 start_time_ticks, end_time_ticks); | 1782 start_time_ticks, end_time_ticks); |
| 1779 MainThreadOnly().background_main_thread_load_tracker.RecordTaskTime( | 1783 MainThreadOnly().background_main_thread_load_tracker.RecordTaskTime( |
| 1780 start_time_ticks, end_time_ticks); | 1784 start_time_ticks, end_time_ticks); |
| 1785 | |
| 1781 // TODO(altimin): Per-page metrics should also be considered. | 1786 // TODO(altimin): Per-page metrics should also be considered. |
| 1782 UMA_HISTOGRAM_CUSTOM_COUNTS( | 1787 RecordTaskMetrics(task_queue->GetQueueType(), |
| 1783 "RendererScheduler.TaskTime", | 1788 end_time_ticks - start_time_ticks); |
| 1784 (end_time_ticks - start_time_ticks).InMicroseconds(), 1, 1000000, 50); | 1789 } |
| 1790 | |
| 1791 void RendererSchedulerImpl::RecordTaskMetrics(TaskQueue::QueueType queue_type, | |
| 1792 base::TimeDelta duration) { | |
| 1793 duration = std::min(duration, kMaxTaskDurationForReporting); | |
| 1794 | |
| 1795 UMA_HISTOGRAM_CUSTOM_COUNTS("RendererScheduler.TaskTime", | |
| 1796 duration.InMicroseconds(), 1, 1000000, 50); | |
|
Ilya Sherman
2017/03/16 21:23:43
Optional nit: The constant 1000000 would be easier
altimin
2017/03/16 23:44:23
Done.
| |
| 1797 | |
| 1785 UMA_HISTOGRAM_ENUMERATION("RendererScheduler.NumberOfTasksPerQueueType", | 1798 UMA_HISTOGRAM_ENUMERATION("RendererScheduler.NumberOfTasksPerQueueType", |
| 1786 static_cast<int>(task_queue->GetQueueType()), | 1799 static_cast<int>(queue_type), |
| 1787 static_cast<int>(TaskQueue::QueueType::COUNT)); | 1800 static_cast<int>(TaskQueue::QueueType::COUNT)); |
| 1801 | |
| 1802 // Report only whole milliseconds to avoid overflow. | |
| 1803 base::TimeDelta& total_duration = | |
| 1804 MainThreadOnly() | |
| 1805 .task_duration_per_queue_type[static_cast<int>(queue_type)]; | |
| 1806 total_duration += duration; | |
| 1807 int64_t milliseconds = total_duration.InMilliseconds(); | |
| 1808 if (milliseconds > 0) { | |
| 1809 total_duration -= base::TimeDelta::FromMilliseconds(milliseconds); | |
| 1810 base::Histogram::FactoryGet("RendererScheduler.TaskDurationPerQueueType", 0, | |
|
Ilya Sherman
2017/03/16 21:23:43
The min value should be 1, not 0.
altimin
2017/03/16 23:44:22
Done.
| |
| 1811 static_cast<int>(TaskQueue::QueueType::COUNT), | |
| 1812 static_cast<int>(TaskQueue::QueueType::COUNT), | |
|
Ilya Sherman
2017/03/16 21:23:43
This should be COUNT+1 -- the final bucket should
altimin
2017/03/16 23:44:23
Done. To be clear — if my samples are in range [0.
Ilya Sherman
2017/03/16 23:58:45
Correct. Yeah, it's a fairly confusing API, sorry
| |
| 1813 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 1814 ->AddCount(static_cast<int>(queue_type), | |
| 1815 static_cast<int>(milliseconds)); | |
|
Ilya Sherman
2017/03/16 21:23:43
It looks like histograms aggregate values in 32-bi
altimin
2017/03/16 23:44:22
By design we're expecting number of samples to be
Ilya Sherman
2017/03/16 23:58:45
Metrics are not reset on each upload -- we simply
altimin
2017/03/17 00:24:00
That's insightful, thanks. Any chance we could sta
Ilya Sherman
2017/03/17 20:27:36
I think we'd need to measure whether there are any
altimin
2017/03/17 23:49:53
I took a quick look at this — it seems that absenc
Ilya Sherman
2017/03/18 01:09:59
Hmm, I guess it depends on how much of a maintenan
| |
| 1816 } | |
| 1788 } | 1817 } |
| 1789 | 1818 |
| 1790 void RendererSchedulerImpl::AddTaskTimeObserver( | 1819 void RendererSchedulerImpl::AddTaskTimeObserver( |
| 1791 TaskTimeObserver* task_time_observer) { | 1820 TaskTimeObserver* task_time_observer) { |
| 1792 helper_.AddTaskTimeObserver(task_time_observer); | 1821 helper_.AddTaskTimeObserver(task_time_observer); |
| 1793 } | 1822 } |
| 1794 | 1823 |
| 1795 void RendererSchedulerImpl::RemoveTaskTimeObserver( | 1824 void RendererSchedulerImpl::RemoveTaskTimeObserver( |
| 1796 TaskTimeObserver* task_time_observer) { | 1825 TaskTimeObserver* task_time_observer) { |
| 1797 helper_.RemoveTaskTimeObserver(task_time_observer); | 1826 helper_.RemoveTaskTimeObserver(task_time_observer); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1915 case TimeDomainType::VIRTUAL: | 1944 case TimeDomainType::VIRTUAL: |
| 1916 return "virtual"; | 1945 return "virtual"; |
| 1917 default: | 1946 default: |
| 1918 NOTREACHED(); | 1947 NOTREACHED(); |
| 1919 return nullptr; | 1948 return nullptr; |
| 1920 } | 1949 } |
| 1921 } | 1950 } |
| 1922 | 1951 |
| 1923 } // namespace scheduler | 1952 } // namespace scheduler |
| 1924 } // namespace blink | 1953 } // namespace blink |
| OLD | NEW |