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(), |
haraken
2017/03/17 11:59:51
I'm just curious but wouldn't it be heavy to recor
altimin
2017/03/17 12:43:12
We've started recording task lengths a while ago.
| |
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, 1000 * 1000, 50); | |
1797 | |
1785 UMA_HISTOGRAM_ENUMERATION("RendererScheduler.NumberOfTasksPerQueueType", | 1798 UMA_HISTOGRAM_ENUMERATION("RendererScheduler.NumberOfTasksPerQueueType", |
Sami
2017/03/17 12:53:38
Is this metric useful anymore with the new duratio
altimin
2017/03/17 13:05:01
Good question. Let's leave it for now (to see the
Sami
2017/05/16 10:45:07
Ok, let's add a TODO to look into it though?
altimin
2017/05/16 11:56:14
Done.
| |
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( | |
Sami
2017/03/17 12:53:38
Could we cache this getter?
altimin
2017/03/17 13:05:01
Let's avoid doing this — all macros do invoke Hist
Ilya Sherman
2017/03/17 20:27:36
Actually, the macros define a static pointer. Tha
altimin
2017/05/16 11:56:14
Done.
| |
1811 "RendererScheduler.TaskDurationPerQueueType", 1, | |
1812 static_cast<int>(TaskQueue::QueueType::COUNT), | |
1813 static_cast<int>(TaskQueue::QueueType::COUNT) + 1, | |
1814 base::HistogramBase::kUmaTargetedHistogramFlag) | |
1815 ->AddCount(static_cast<int>(queue_type), | |
1816 static_cast<int>(milliseconds)); | |
1817 } | |
1788 } | 1818 } |
1789 | 1819 |
1790 void RendererSchedulerImpl::AddTaskTimeObserver( | 1820 void RendererSchedulerImpl::AddTaskTimeObserver( |
1791 TaskTimeObserver* task_time_observer) { | 1821 TaskTimeObserver* task_time_observer) { |
1792 helper_.AddTaskTimeObserver(task_time_observer); | 1822 helper_.AddTaskTimeObserver(task_time_observer); |
1793 } | 1823 } |
1794 | 1824 |
1795 void RendererSchedulerImpl::RemoveTaskTimeObserver( | 1825 void RendererSchedulerImpl::RemoveTaskTimeObserver( |
1796 TaskTimeObserver* task_time_observer) { | 1826 TaskTimeObserver* task_time_observer) { |
1797 helper_.RemoveTaskTimeObserver(task_time_observer); | 1827 helper_.RemoveTaskTimeObserver(task_time_observer); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1915 case TimeDomainType::VIRTUAL: | 1945 case TimeDomainType::VIRTUAL: |
1916 return "virtual"; | 1946 return "virtual"; |
1917 default: | 1947 default: |
1918 NOTREACHED(); | 1948 NOTREACHED(); |
1919 return nullptr; | 1949 return nullptr; |
1920 } | 1950 } |
1921 } | 1951 } |
1922 | 1952 |
1923 } // namespace scheduler | 1953 } // namespace scheduler |
1924 } // namespace blink | 1954 } // namespace blink |
OLD | NEW |