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

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

Issue 2517383004: [scheduler] Bunch of improvements for blink scheduler tracing (Closed)
Patch Set: Some more Created 4 years 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"
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 1314
1315 if (optional_now.is_null()) 1315 if (optional_now.is_null())
1316 optional_now = helper_.scheduler_tqm_delegate()->NowTicks(); 1316 optional_now = helper_.scheduler_tqm_delegate()->NowTicks();
1317 std::unique_ptr<base::trace_event::TracedValue> state( 1317 std::unique_ptr<base::trace_event::TracedValue> state(
1318 new base::trace_event::TracedValue()); 1318 new base::trace_event::TracedValue());
1319 state->SetBoolean( 1319 state->SetBoolean(
1320 "has_visible_render_widget_with_touch_handler", 1320 "has_visible_render_widget_with_touch_handler",
1321 MainThreadOnly().has_visible_render_widget_with_touch_handler); 1321 MainThreadOnly().has_visible_render_widget_with_touch_handler);
1322 state->SetString("current_use_case", 1322 state->SetString("current_use_case",
1323 UseCaseToString(MainThreadOnly().current_use_case)); 1323 UseCaseToString(MainThreadOnly().current_use_case));
1324 state->SetString("rail_mode",
1325 RAILModeToString(MainThreadOnly().current_policy.rail_mode));
1326 state->SetBoolean("loading_tasks_seem_expensive", 1324 state->SetBoolean("loading_tasks_seem_expensive",
1327 MainThreadOnly().loading_tasks_seem_expensive); 1325 MainThreadOnly().loading_tasks_seem_expensive);
1328 state->SetBoolean("timer_tasks_seem_expensive", 1326 state->SetBoolean("timer_tasks_seem_expensive",
1329 MainThreadOnly().timer_tasks_seem_expensive); 1327 MainThreadOnly().timer_tasks_seem_expensive);
1330 state->SetBoolean("begin_frame_not_expected_soon", 1328 state->SetBoolean("begin_frame_not_expected_soon",
1331 MainThreadOnly().begin_frame_not_expected_soon); 1329 MainThreadOnly().begin_frame_not_expected_soon);
1332 state->SetBoolean("touchstart_expected_soon", 1330 state->SetBoolean("touchstart_expected_soon",
1333 MainThreadOnly().touchstart_expected_soon); 1331 MainThreadOnly().touchstart_expected_soon);
1334 state->SetString("idle_period_state", 1332 state->SetString("idle_period_state",
1335 IdleHelper::IdlePeriodStateToString( 1333 IdleHelper::IdlePeriodStateToString(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 state->SetDouble("expected_loading_task_duration", 1372 state->SetDouble("expected_loading_task_duration",
1375 MainThreadOnly() 1373 MainThreadOnly()
1376 .loading_task_cost_estimator.expected_task_duration() 1374 .loading_task_cost_estimator.expected_task_duration()
1377 .InMillisecondsF()); 1375 .InMillisecondsF());
1378 state->SetDouble("expected_timer_task_duration", 1376 state->SetDouble("expected_timer_task_duration",
1379 MainThreadOnly() 1377 MainThreadOnly()
1380 .timer_task_cost_estimator.expected_task_duration() 1378 .timer_task_cost_estimator.expected_task_duration()
1381 .InMillisecondsF()); 1379 .InMillisecondsF());
1382 state->SetBoolean("is_audio_playing", MainThreadOnly().is_audio_playing); 1380 state->SetBoolean("is_audio_playing", MainThreadOnly().is_audio_playing);
1383 1381
1382 state->BeginDictionary("policy");
1383 MainThreadOnly().current_policy.AsValueInto(state.get());
1384 state->EndDictionary();
1385
1384 // TODO(skyostil): Can we somehow trace how accurate these estimates were? 1386 // TODO(skyostil): Can we somehow trace how accurate these estimates were?
1385 state->SetDouble( 1387 state->SetDouble(
1386 "longest_jank_free_task_duration", 1388 "longest_jank_free_task_duration",
1387 MainThreadOnly().longest_jank_free_task_duration.InMillisecondsF()); 1389 MainThreadOnly().longest_jank_free_task_duration.InMillisecondsF());
1388 state->SetDouble( 1390 state->SetDouble(
1389 "compositor_frame_interval", 1391 "compositor_frame_interval",
1390 MainThreadOnly().compositor_frame_interval.InMillisecondsF()); 1392 MainThreadOnly().compositor_frame_interval.InMillisecondsF());
1391 state->SetDouble( 1393 state->SetDouble(
1392 "estimated_next_frame_begin", 1394 "estimated_next_frame_begin",
1393 (MainThreadOnly().estimated_next_frame_begin - base::TimeTicks()) 1395 (MainThreadOnly().estimated_next_frame_begin - base::TimeTicks())
1394 .InMillisecondsF()); 1396 .InMillisecondsF());
1395 state->SetBoolean("in_idle_period", AnyThread().in_idle_period); 1397 state->SetBoolean("in_idle_period", AnyThread().in_idle_period);
1396 1398
1397 state->SetString( 1399 state->SetString(
Sami 2016/11/22 18:03:28 Could you move this to the policy too?
altimin 2016/11/22 19:01:24 I don't really like this idea. Currently "policy"
Sami 2016/11/22 19:10:27 Ah, right. I wonder if we could come up with a bet
1398 "expensive_task_policy", 1400 "expensive_task_policy",
1399 ExpensiveTaskPolicyToString(MainThreadOnly().expensive_task_policy)); 1401 ExpensiveTaskPolicyToString(MainThreadOnly().expensive_task_policy));
1400 1402
1401 AnyThread().user_model.AsValueInto(state.get()); 1403 AnyThread().user_model.AsValueInto(state.get());
1402 render_widget_scheduler_signals_.AsValueInto(state.get()); 1404 render_widget_scheduler_signals_.AsValueInto(state.get());
1403 1405
1404 state->BeginDictionary("task_queue_throttler"); 1406 state->BeginDictionary("task_queue_throttler");
1405 task_queue_throttler_->AsValueInto(state.get(), optional_now); 1407 task_queue_throttler_->AsValueInto(state.get(), optional_now);
1406 state->EndDictionary(); 1408 state->EndDictionary();
1407 1409
1408 return std::move(state); 1410 return std::move(state);
1409 } 1411 }
1410 1412
1413 void RendererSchedulerImpl::TaskQueuePolicy::AsValueInto(
1414 base::trace_event::TracedValue* state) const {
1415 state->SetBoolean("is_enabled", is_enabled);
1416 state->SetString("priority", TaskQueue::PriorityToString(priority));
1417 state->SetString("time_domain_type",
1418 TimeDomainTypeToString(time_domain_type));
1419 }
1420
1421 void RendererSchedulerImpl::Policy::AsValueInto(
1422 base::trace_event::TracedValue* state) const {
1423 state->BeginDictionary("compositor_queue_policy");
1424 compositor_queue_policy.AsValueInto(state);
1425 state->EndDictionary();
1426
1427 state->BeginDictionary("loading_queue_policy");
1428 loading_queue_policy.AsValueInto(state);
1429 state->EndDictionary();
1430
1431 state->BeginDictionary("timer_queue_policy");
1432 timer_queue_policy.AsValueInto(state);
1433 state->EndDictionary();
1434
1435 state->BeginDictionary("default_queue_policy");
1436 default_queue_policy.AsValueInto(state);
1437 state->EndDictionary();
1438
1439 state->SetString("rail_mode", RAILModeToString(rail_mode));
1440 state->SetBoolean("should_disable_throttling", should_disable_throttling);
1441 }
1442
1411 void RendererSchedulerImpl::OnIdlePeriodStarted() { 1443 void RendererSchedulerImpl::OnIdlePeriodStarted() {
1412 base::AutoLock lock(any_thread_lock_); 1444 base::AutoLock lock(any_thread_lock_);
1413 AnyThread().in_idle_period = true; 1445 AnyThread().in_idle_period = true;
1414 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); 1446 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED);
1415 } 1447 }
1416 1448
1417 void RendererSchedulerImpl::OnIdlePeriodEnded() { 1449 void RendererSchedulerImpl::OnIdlePeriodEnded() {
1418 base::AutoLock lock(any_thread_lock_); 1450 base::AutoLock lock(any_thread_lock_);
1419 AnyThread().last_idle_period_end_time = 1451 AnyThread().last_idle_period_end_time =
1420 helper_.scheduler_tqm_delegate()->NowTicks(); 1452 helper_.scheduler_tqm_delegate()->NowTicks();
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 case v8::PERFORMANCE_IDLE: 1734 case v8::PERFORMANCE_IDLE:
1703 return "idle"; 1735 return "idle";
1704 case v8::PERFORMANCE_LOAD: 1736 case v8::PERFORMANCE_LOAD:
1705 return "load"; 1737 return "load";
1706 default: 1738 default:
1707 NOTREACHED(); 1739 NOTREACHED();
1708 return nullptr; 1740 return nullptr;
1709 } 1741 }
1710 } 1742 }
1711 1743
1744 // static
1745 const char* RendererSchedulerImpl::TimeDomainTypeToString(
1746 TimeDomainType domain_type) {
1747 switch (domain_type) {
1748 case TimeDomainType::REAL:
1749 return "real";
1750 case TimeDomainType::THROTTLED:
1751 return "throttled";
1752 case TimeDomainType::VIRTUAL:
1753 return "virtual";
1754 default:
1755 NOTREACHED();
1756 return nullptr;
1757 }
1758 }
1759
1712 } // namespace scheduler 1760 } // namespace scheduler
1713 } // namespace blink 1761 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698