Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.cc

Issue 2755953003: [scheduler] Add RendererScheduler.TaskDurationPerQueueType. (Closed)
Patch Set: rebased Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
13 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
14 #include "base/trace_event/trace_event_argument.h" 15 #include "base/trace_event/trace_event_argument.h"
15 #include "cc/output/begin_frame_args.h" 16 #include "cc/output/begin_frame_args.h"
16 #include "platform/RuntimeEnabledFeatures.h" 17 #include "platform/RuntimeEnabledFeatures.h"
17 #include "platform/scheduler/base/real_time_domain.h" 18 #include "platform/scheduler/base/real_time_domain.h"
18 #include "platform/scheduler/base/task_queue_impl.h" 19 #include "platform/scheduler/base/task_queue_impl.h"
19 #include "platform/scheduler/base/task_queue_selector.h" 20 #include "platform/scheduler/base/task_queue_selector.h"
20 #include "platform/scheduler/base/time_converter.h" 21 #include "platform/scheduler/base/time_converter.h"
(...skipping 24 matching lines...) Expand all
45 const double kFastCompositingIdleTimeThreshold = .2; 46 const double kFastCompositingIdleTimeThreshold = .2;
46 constexpr base::TimeDelta kThreadLoadTrackerReportingInterval = 47 constexpr base::TimeDelta kThreadLoadTrackerReportingInterval =
47 base::TimeDelta::FromMinutes(1); 48 base::TimeDelta::FromMinutes(1);
48 constexpr base::TimeDelta kThreadLoadTrackerWaitingPeriodBeforeReporting = 49 constexpr base::TimeDelta kThreadLoadTrackerWaitingPeriodBeforeReporting =
49 base::TimeDelta::FromMinutes(2); 50 base::TimeDelta::FromMinutes(2);
50 // We do not throttle anything while audio is played and shortly after that. 51 // We do not throttle anything while audio is played and shortly after that.
51 constexpr base::TimeDelta kThrottlingDelayAfterAudioIsPlayed = 52 constexpr base::TimeDelta kThrottlingDelayAfterAudioIsPlayed =
52 base::TimeDelta::FromSeconds(5); 53 base::TimeDelta::FromSeconds(5);
53 constexpr base::TimeDelta kQueueingTimeWindowDuration = 54 constexpr base::TimeDelta kQueueingTimeWindowDuration =
54 base::TimeDelta::FromSeconds(1); 55 base::TimeDelta::FromSeconds(1);
56 // Maximal bound on task duration for reporting.
57 constexpr base::TimeDelta kMaxTaskDurationForReporting =
58 base::TimeDelta::FromMinutes(1);
55 59
56 void ReportForegroundRendererTaskLoad(base::TimeTicks time, double load) { 60 void ReportForegroundRendererTaskLoad(base::TimeTicks time, double load) {
57 if (!blink::RuntimeEnabledFeatures::timerThrottlingForBackgroundTabsEnabled()) 61 if (!blink::RuntimeEnabledFeatures::timerThrottlingForBackgroundTabsEnabled())
58 return; 62 return;
59 63
60 int load_percentage = static_cast<int>(load * 100); 64 int load_percentage = static_cast<int>(load * 100);
61 DCHECK_LE(load_percentage, 100); 65 DCHECK_LE(load_percentage, 100);
62 66
63 UMA_HISTOGRAM_PERCENTAGE("RendererScheduler.ForegroundRendererMainThreadLoad", 67 UMA_HISTOGRAM_PERCENTAGE("RendererScheduler.ForegroundRendererMainThreadLoad",
64 load_percentage); 68 load_percentage);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 touchstart_expected_soon(false), 211 touchstart_expected_soon(false),
208 have_seen_a_begin_main_frame(false), 212 have_seen_a_begin_main_frame(false),
209 have_reported_blocking_intervention_in_current_policy(false), 213 have_reported_blocking_intervention_in_current_policy(false),
210 have_reported_blocking_intervention_since_navigation(false), 214 have_reported_blocking_intervention_since_navigation(false),
211 has_visible_render_widget_with_touch_handler(false), 215 has_visible_render_widget_with_touch_handler(false),
212 begin_frame_not_expected_soon(false), 216 begin_frame_not_expected_soon(false),
213 in_idle_period_for_testing(false), 217 in_idle_period_for_testing(false),
214 use_virtual_time(false), 218 use_virtual_time(false),
215 is_audio_playing(false), 219 is_audio_playing(false),
216 rail_mode_observer(nullptr), 220 rail_mode_observer(nullptr),
217 wake_up_budget_pool(nullptr) { 221 wake_up_budget_pool(nullptr),
222 task_duration_per_queue_type_histogram(base::Histogram::FactoryGet(
223 "RendererScheduler.TaskDurationPerQueueType",
224 1,
225 static_cast<int>(TaskQueue::QueueType::COUNT),
226 static_cast<int>(TaskQueue::QueueType::COUNT) + 1,
227 base::HistogramBase::kUmaTargetedHistogramFlag)) {
218 foreground_main_thread_load_tracker.Resume(now); 228 foreground_main_thread_load_tracker.Resume(now);
219 } 229 }
220 230
221 RendererSchedulerImpl::MainThreadOnly::~MainThreadOnly() {} 231 RendererSchedulerImpl::MainThreadOnly::~MainThreadOnly() {}
222 232
223 RendererSchedulerImpl::AnyThread::AnyThread() 233 RendererSchedulerImpl::AnyThread::AnyThread()
224 : awaiting_touch_start_response(false), 234 : awaiting_touch_start_response(false),
225 in_idle_period(false), 235 in_idle_period(false),
226 begin_main_frame_on_critical_path(false), 236 begin_main_frame_on_critical_path(false),
227 last_gesture_was_compositor_driven(false), 237 last_gesture_was_compositor_driven(false),
(...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 1833
1824 task_queue_throttler()->OnTaskRunTimeReported(task_queue, start_time_ticks, 1834 task_queue_throttler()->OnTaskRunTimeReported(task_queue, start_time_ticks,
1825 end_time_ticks); 1835 end_time_ticks);
1826 1836
1827 // We want to measure thread time here, but for efficiency reasons 1837 // We want to measure thread time here, but for efficiency reasons
1828 // we stick with wall time. 1838 // we stick with wall time.
1829 GetMainThreadOnly().foreground_main_thread_load_tracker.RecordTaskTime( 1839 GetMainThreadOnly().foreground_main_thread_load_tracker.RecordTaskTime(
1830 start_time_ticks, end_time_ticks); 1840 start_time_ticks, end_time_ticks);
1831 GetMainThreadOnly().background_main_thread_load_tracker.RecordTaskTime( 1841 GetMainThreadOnly().background_main_thread_load_tracker.RecordTaskTime(
1832 start_time_ticks, end_time_ticks); 1842 start_time_ticks, end_time_ticks);
1843
1833 // TODO(altimin): Per-page metrics should also be considered. 1844 // TODO(altimin): Per-page metrics should also be considered.
1834 UMA_HISTOGRAM_CUSTOM_COUNTS( 1845 RecordTaskMetrics(task_queue->GetQueueType(),
1835 "RendererScheduler.TaskTime", 1846 end_time_ticks - start_time_ticks);
1836 (end_time_ticks - start_time_ticks).InMicroseconds(), 1, 1000000, 50); 1847 }
1848
1849 void RendererSchedulerImpl::RecordTaskMetrics(TaskQueue::QueueType queue_type,
1850 base::TimeDelta duration) {
1851 UMA_HISTOGRAM_CUSTOM_COUNTS("RendererScheduler.TaskTime",
1852 duration.InMicroseconds(), 1, 1000 * 1000, 50);
1853
1837 UMA_HISTOGRAM_ENUMERATION("RendererScheduler.NumberOfTasksPerQueueType", 1854 UMA_HISTOGRAM_ENUMERATION("RendererScheduler.NumberOfTasksPerQueueType",
1838 static_cast<int>(task_queue->GetQueueType()), 1855 static_cast<int>(queue_type),
1839 static_cast<int>(TaskQueue::QueueType::COUNT)); 1856 static_cast<int>(TaskQueue::QueueType::COUNT));
1857
1858 RecordTaskDurationPerQueueType(queue_type, duration);
1859 }
1860
1861 void RendererSchedulerImpl::RecordTaskDurationPerQueueType(
1862 TaskQueue::QueueType queue_type,
1863 base::TimeDelta duration) {
1864 duration = std::min(duration, kMaxTaskDurationForReporting);
1865
1866 // Report only whole milliseconds to avoid overflow.
1867 base::TimeDelta& total_duration =
Ilya Sherman 2017/05/15 22:53:22 Optional nit: Maybe name this something like "unre
altimin 2017/05/16 11:56:14 Done.
1868 GetMainThreadOnly()
1869 .task_duration_per_queue_type[static_cast<int>(queue_type)];
1870 total_duration += duration;
1871 int64_t milliseconds = total_duration.InMilliseconds();
1872 if (milliseconds > 0) {
1873 total_duration -= base::TimeDelta::FromMilliseconds(milliseconds);
1874 GetMainThreadOnly().task_duration_per_queue_type_histogram->AddCount(
1875 static_cast<int>(queue_type), static_cast<int>(milliseconds));
1876 }
1840 } 1877 }
1841 1878
1842 void RendererSchedulerImpl::OnBeginNestedRunLoop() { 1879 void RendererSchedulerImpl::OnBeginNestedRunLoop() {
1843 seqlock_queueing_time_estimator_.seqlock.WriteBegin(); 1880 seqlock_queueing_time_estimator_.seqlock.WriteBegin();
1844 seqlock_queueing_time_estimator_.data.OnBeginNestedRunLoop(); 1881 seqlock_queueing_time_estimator_.data.OnBeginNestedRunLoop();
1845 seqlock_queueing_time_estimator_.seqlock.WriteEnd(); 1882 seqlock_queueing_time_estimator_.seqlock.WriteEnd();
1846 } 1883 }
1847 1884
1848 void RendererSchedulerImpl::AddTaskTimeObserver( 1885 void RendererSchedulerImpl::AddTaskTimeObserver(
1849 TaskTimeObserver* task_time_observer) { 1886 TaskTimeObserver* task_time_observer) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2008 case TimeDomainType::VIRTUAL: 2045 case TimeDomainType::VIRTUAL:
2009 return "virtual"; 2046 return "virtual";
2010 default: 2047 default:
2011 NOTREACHED(); 2048 NOTREACHED();
2012 return nullptr; 2049 return nullptr;
2013 } 2050 }
2014 } 2051 }
2015 2052
2016 } // namespace scheduler 2053 } // namespace scheduler
2017 } // namespace blink 2054 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698