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

Side by Side Diff: cc/raster/task_graph_work_queue.cc

Issue 1784623005: Test dynamic priorities (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « cc/raster/task_graph_runner.cc ('k') | cc/raster/tile_task_runner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "cc/raster/task_graph_work_queue.h" 5 #include "cc/raster/task_graph_work_queue.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 TaskGraphWorkQueue::TaskGraphWorkQueue() : next_namespace_id_(1) {} 55 TaskGraphWorkQueue::TaskGraphWorkQueue() : next_namespace_id_(1) {}
56 TaskGraphWorkQueue::~TaskGraphWorkQueue() {} 56 TaskGraphWorkQueue::~TaskGraphWorkQueue() {}
57 57
58 NamespaceToken TaskGraphWorkQueue::GetNamespaceToken() { 58 NamespaceToken TaskGraphWorkQueue::GetNamespaceToken() {
59 NamespaceToken token(next_namespace_id_++); 59 NamespaceToken token(next_namespace_id_++);
60 DCHECK(namespaces_.find(token) == namespaces_.end()); 60 DCHECK(namespaces_.find(token) == namespaces_.end());
61 return token; 61 return token;
62 } 62 }
63 63
64 void AdjustRunnerPriority(Task* task, uint16_t old_cat, uint16_t new_cat) {
65 // Remove or put DCHECK.
66 if (old_cat == new_cat)
67 return;
68
69 // Put DCHECK.
70 if (!task->IsRasterTask())
71 return;
72
73 base::TestSimpleThread* runner = task->GetRunner();
74
75 // Currently take care of only speeding up background threads.
76 if (new_cat == TASK_CATEGORY_NONCONCURRENT_FOREGROUND ||
77 new_cat == TASK_CATEGORY_FOREGROUND) {
78 if (runner->Speedup()) {
79 // LOG(ERROR) << "\nPRAS:: [" << std::hex << runner << "] "
80 // << runner->GetPrioritySetForDebugging()
81 // << ". Runner speeded up ^^^^^^^^^";
82 }
83 }
84 }
85
64 void TaskGraphWorkQueue::ScheduleTasks(NamespaceToken token, TaskGraph* graph) { 86 void TaskGraphWorkQueue::ScheduleTasks(NamespaceToken token, TaskGraph* graph) {
65 TaskNamespace& task_namespace = namespaces_[token]; 87 TaskNamespace& task_namespace = namespaces_[token];
66 88
67 // First adjust number of dependencies to reflect completed tasks. 89 // First adjust number of dependencies to reflect completed tasks.
68 for (const scoped_refptr<Task>& task : task_namespace.completed_tasks) { 90 for (const scoped_refptr<Task>& task : task_namespace.completed_tasks) {
69 for (DependentIterator node_it(graph, task.get()); node_it; ++node_it) { 91 for (DependentIterator node_it(graph, task.get()); node_it; ++node_it) {
70 TaskGraph::Node& node = *node_it; 92 TaskGraph::Node& node = *node_it;
71 DCHECK_LT(0u, node.dependencies); 93 DCHECK_LT(0u, node.dependencies);
72 node.dependencies--; 94 node.dependencies--;
73 } 95 }
(...skipping 19 matching lines...) Expand all
93 115
94 // Task is not ready to run if dependencies are not yet satisfied. 116 // Task is not ready to run if dependencies are not yet satisfied.
95 if (node.dependencies) 117 if (node.dependencies)
96 continue; 118 continue;
97 119
98 // Skip if already finished running task. 120 // Skip if already finished running task.
99 if (node.task->HasFinishedRunning()) 121 if (node.task->HasFinishedRunning())
100 continue; 122 continue;
101 123
102 // Skip if already running. 124 // Skip if already running.
103 if (std::any_of(task_namespace.running_tasks.begin(), 125 if (std::any_of(
104 task_namespace.running_tasks.end(), 126 task_namespace.running_tasks.begin(),
105 [&node](const CategorizedTask& task) { 127 task_namespace.running_tasks.end(),
106 return task.second == node.task; 128 [&node](const CategorizedTask& task) {
107 })) 129 if ((task.second == node.task) && task.first != node.category) {
130 AdjustRunnerPriority(task.second.get(), (uint16_t)task.first,
131 (uint16_t)node.category);
132 }
133 return task.second == node.task;
134 }))
108 continue; 135 continue;
109 136
110 task_namespace.ready_to_run_tasks[node.category].push_back(PrioritizedTask( 137 task_namespace.ready_to_run_tasks[node.category].push_back(PrioritizedTask(
111 node.task, &task_namespace, node.category, node.priority)); 138 node.task, &task_namespace, node.category, node.priority));
112 } 139 }
113 140
114 // Rearrange the elements in each vector within |ready_to_run_tasks| in such a 141 // Rearrange the elements in each vector within |ready_to_run_tasks| in such a
115 // way that they form a heap. 142 // way that they form a heap.
116 for (auto& it : task_namespace.ready_to_run_tasks) { 143 for (auto& it : task_namespace.ready_to_run_tasks) {
117 auto& ready_to_run_tasks = it.second; 144 auto& ready_to_run_tasks = it.second;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 328
302 for (const TaskGraph::Node& node : graph->nodes) { 329 for (const TaskGraph::Node& node : graph->nodes) {
303 if (dependents[node.task] != node.dependencies) 330 if (dependents[node.task] != node.dependencies)
304 return true; 331 return true;
305 } 332 }
306 333
307 return false; 334 return false;
308 } 335 }
309 336
310 } // namespace cc 337 } // namespace cc
OLDNEW
« no previous file with comments | « cc/raster/task_graph_runner.cc ('k') | cc/raster/tile_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698