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

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

Issue 2890173002: EQT: Record the max queueing time from navigation start to navigation away (Closed)
Patch Set: add a single thread and multi-thread test Created 3 years, 6 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.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
15 #include "base/trace_event/trace_event_argument.h" 15 #include "base/trace_event/trace_event_argument.h"
16 #include "cc/output/begin_frame_args.h" 16 #include "cc/output/begin_frame_args.h"
17 #include "components/metrics/single_sample_metrics_factory_impl.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"
21 #include "platform/scheduler/base/time_converter.h" 22 #include "platform/scheduler/base/time_converter.h"
22 #include "platform/scheduler/base/trace_helper.h" 23 #include "platform/scheduler/base/trace_helper.h"
23 #include "platform/scheduler/base/virtual_time_domain.h" 24 #include "platform/scheduler/base/virtual_time_domain.h"
24 #include "platform/scheduler/child/scheduler_tqm_delegate.h" 25 #include "platform/scheduler/child/scheduler_tqm_delegate.h"
25 #include "platform/scheduler/renderer/auto_advancing_virtual_time_domain.h" 26 #include "platform/scheduler/renderer/auto_advancing_virtual_time_domain.h"
26 #include "platform/scheduler/renderer/task_queue_throttler.h" 27 #include "platform/scheduler/renderer/task_queue_throttler.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 timer_tasks_seem_expensive(false), 213 timer_tasks_seem_expensive(false),
213 touchstart_expected_soon(false), 214 touchstart_expected_soon(false),
214 have_seen_a_begin_main_frame(false), 215 have_seen_a_begin_main_frame(false),
215 have_reported_blocking_intervention_in_current_policy(false), 216 have_reported_blocking_intervention_in_current_policy(false),
216 have_reported_blocking_intervention_since_navigation(false), 217 have_reported_blocking_intervention_since_navigation(false),
217 has_visible_render_widget_with_touch_handler(false), 218 has_visible_render_widget_with_touch_handler(false),
218 begin_frame_not_expected_soon(false), 219 begin_frame_not_expected_soon(false),
219 in_idle_period_for_testing(false), 220 in_idle_period_for_testing(false),
220 use_virtual_time(false), 221 use_virtual_time(false),
221 is_audio_playing(false), 222 is_audio_playing(false),
223 has_navigated(false),
222 rail_mode_observer(nullptr), 224 rail_mode_observer(nullptr),
223 wake_up_budget_pool(nullptr), 225 wake_up_budget_pool(nullptr),
224 task_duration_per_queue_type_histogram(base::Histogram::FactoryGet( 226 task_duration_per_queue_type_histogram(base::Histogram::FactoryGet(
225 "RendererScheduler.TaskDurationPerQueueType2", 227 "RendererScheduler.TaskDurationPerQueueType2",
226 1, 228 1,
227 static_cast<int>(TaskQueue::QueueType::COUNT), 229 static_cast<int>(TaskQueue::QueueType::COUNT),
228 static_cast<int>(TaskQueue::QueueType::COUNT) + 1, 230 static_cast<int>(TaskQueue::QueueType::COUNT) + 1,
229 base::HistogramBase::kUmaTargetedHistogramFlag)) { 231 base::HistogramBase::kUmaTargetedHistogramFlag)) {
230 foreground_main_thread_load_tracker.Resume(now); 232 foreground_main_thread_load_tracker.Resume(now);
231 } 233 }
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 void RendererSchedulerImpl::RemovePendingNavigation(NavigatingFrameType type) { 1626 void RendererSchedulerImpl::RemovePendingNavigation(NavigatingFrameType type) {
1625 helper_.CheckOnValidThread(); 1627 helper_.CheckOnValidThread();
1626 DCHECK_GT(GetMainThreadOnly().navigation_task_expected_count, 0); 1628 DCHECK_GT(GetMainThreadOnly().navigation_task_expected_count, 0);
1627 if (type == NavigatingFrameType::kMainFrame && 1629 if (type == NavigatingFrameType::kMainFrame &&
1628 GetMainThreadOnly().navigation_task_expected_count > 0) { 1630 GetMainThreadOnly().navigation_task_expected_count > 0) {
1629 GetMainThreadOnly().navigation_task_expected_count--; 1631 GetMainThreadOnly().navigation_task_expected_count--;
1630 UpdatePolicy(); 1632 UpdatePolicy();
1631 } 1633 }
1632 } 1634 }
1633 1635
1636 void RendererSchedulerImpl::OnCommitProvisionalLoad() {
1637 // Initialize |max_queueing_time_metric| as we need it so that
tdresser 2017/05/30 13:34:44 I think "as we need it" -> "lazily" is a bit clear
Liquan (Max) Gu 2017/05/30 19:57:19 Done.
1638 // |SingleSampleMetricsFactory::SetFactory()| is called before
1639 // |SingleSampleMetricsFactory::Get()|
1640 if (!GetMainThreadOnly().max_queueing_time_metric) {
1641 GetMainThreadOnly().max_queueing_time_metric = GetMaxQueueingTimeMetric();
1642 }
tdresser 2017/05/30 13:34:44 Do we need this? We reset it immediately below. Do
Liquan (Max) Gu 2017/05/30 19:57:19 Lazy init is not happened just from the beginning.
1643 GetMainThreadOnly().max_queueing_time_metric.reset();
1644 GetMainThreadOnly().max_queueing_time = base::TimeDelta();
1645 GetMainThreadOnly().has_navigated = true;
1646 }
1647
1648 std::unique_ptr<base::SingleSampleMetric>
1649 RendererSchedulerImpl::GetMaxQueueingTimeMetric() {
tdresser 2017/05/30 15:44:41 GetOrCreate
Liquan (Max) Gu 2017/05/30 19:57:19 Done.
1650 return base::SingleSampleMetricsFactory::Get()->CreateCustomCountsMetric(
1651 "RendererScheduler.MaxQueueingTime", 1, 10000, 50);
1652 }
1653
1634 void RendererSchedulerImpl::OnNavigationStarted() { 1654 void RendererSchedulerImpl::OnNavigationStarted() {
1635 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 1655 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
1636 "RendererSchedulerImpl::OnNavigationStarted"); 1656 "RendererSchedulerImpl::OnNavigationStarted");
1637 base::AutoLock lock(any_thread_lock_); 1657 base::AutoLock lock(any_thread_lock_);
1638 ResetForNavigationLocked(); 1658 ResetForNavigationLocked();
1639 } 1659 }
1640 1660
1641 void RendererSchedulerImpl::OnFirstMeaningfulPaint() { 1661 void RendererSchedulerImpl::OnFirstMeaningfulPaint() {
1642 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 1662 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
1643 "RendererSchedulerImpl::OnFirstMeaningfulPaint"); 1663 "RendererSchedulerImpl::OnFirstMeaningfulPaint");
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 } 1920 }
1901 1921
1902 void RendererSchedulerImpl::RemoveTaskTimeObserver( 1922 void RendererSchedulerImpl::RemoveTaskTimeObserver(
1903 TaskTimeObserver* task_time_observer) { 1923 TaskTimeObserver* task_time_observer) {
1904 helper_.RemoveTaskTimeObserver(task_time_observer); 1924 helper_.RemoveTaskTimeObserver(task_time_observer);
1905 } 1925 }
1906 1926
1907 void RendererSchedulerImpl::OnQueueingTimeForWindowEstimated( 1927 void RendererSchedulerImpl::OnQueueingTimeForWindowEstimated(
1908 base::TimeDelta queueing_time, 1928 base::TimeDelta queueing_time,
1909 base::TimeTicks window_start_time) { 1929 base::TimeTicks window_start_time) {
1930 if (GetMainThreadOnly().has_navigated) {
tdresser 2017/05/30 13:34:44 Can we get here when |has_navigated| is false? If
Liquan (Max) Gu 2017/05/30 19:57:19 Yes, the EQTEstimator starts to measure EQTs befor
1931 if (GetMainThreadOnly().max_queueing_time < queueing_time) {
1932 if (!GetMainThreadOnly().max_queueing_time_metric) {
1933 GetMainThreadOnly().max_queueing_time_metric =
1934 GetMaxQueueingTimeMetric();
1935 }
1936 GetMainThreadOnly().max_queueing_time_metric->SetSample(
1937 queueing_time.InMilliseconds());
1938 GetMainThreadOnly().max_queueing_time = queueing_time;
1939 }
1940 }
1910 // RendererScheduler reports the queueing time once per window's duration. 1941 // RendererScheduler reports the queueing time once per window's duration.
1911 // |stepEQT|stepEQT|stepEQT|stepEQT|stepEQT|stepEQT| 1942 // |stepEQT|stepEQT|stepEQT|stepEQT|stepEQT|stepEQT|
1912 // Report: |-------window EQT------| 1943 // Report: |-------window EQT------|
1913 // Discard: |-------window EQT------| 1944 // Discard: |-------window EQT------|
1914 // Discard: |-------window EQT------| 1945 // Discard: |-------window EQT------|
1915 // Report: |-------window EQT------| 1946 // Report: |-------window EQT------|
1916 if (window_start_time - 1947 if (window_start_time -
1917 GetMainThreadOnly().uma_last_queueing_time_report_window_start_time < 1948 GetMainThreadOnly().uma_last_queueing_time_report_window_start_time <
1918 kQueueingTimeWindowDuration) { 1949 kQueueingTimeWindowDuration) {
1919 return; 1950 return;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 case TimeDomainType::VIRTUAL: 2088 case TimeDomainType::VIRTUAL:
2058 return "virtual"; 2089 return "virtual";
2059 default: 2090 default:
2060 NOTREACHED(); 2091 NOTREACHED();
2061 return nullptr; 2092 return nullptr;
2062 } 2093 }
2063 } 2094 }
2064 2095
2065 } // namespace scheduler 2096 } // namespace scheduler
2066 } // namespace blink 2097 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698