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

Unified Diff: content/renderer/scheduler/task_queue_manager.cc

Issue 954833005: scheduler: Trace queue size at post time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/scheduler/task_queue_manager.cc
diff --git a/content/renderer/scheduler/task_queue_manager.cc b/content/renderer/scheduler/task_queue_manager.cc
index 112a37ca33c120b61319a12d587106335badfaf0..0c3fcf58a4f91350f8f968b8e98fea23c1848eb9 100644
--- a/content/renderer/scheduler/task_queue_manager.cc
+++ b/content/renderer/scheduler/task_queue_manager.cc
@@ -69,7 +69,7 @@ class TaskQueue : public base::SingleThreadTaskRunner {
void PumpQueueLocked();
void EnqueueTaskLocked(const base::PendingTask& pending_task);
- void TraceWorkQueueSize() const;
+ void TraceQueueSize(bool is_locked) const;
static void QueueAsValueInto(const base::TaskQueue& queue,
base::trace_event::TracedValue* state);
static void TaskAsValueInto(const base::PendingTask& task,
@@ -155,7 +155,7 @@ bool TaskQueue::UpdateWorkQueue(base::TimeTicks* next_pending_delayed_task) {
if (!auto_pump_ || incoming_queue_.empty())
return false;
work_queue_.Swap(&incoming_queue_);
- TraceWorkQueueSize();
+ TraceQueueSize(true);
return true;
}
}
@@ -163,15 +163,24 @@ bool TaskQueue::UpdateWorkQueue(base::TimeTicks* next_pending_delayed_task) {
base::PendingTask TaskQueue::TakeTaskFromWorkQueue() {
base::PendingTask pending_task = work_queue_.front();
work_queue_.pop();
- TraceWorkQueueSize();
+ TraceQueueSize(false);
return pending_task;
}
-void TaskQueue::TraceWorkQueueSize() const {
- if (!name_)
+void TaskQueue::TraceQueueSize(bool is_locked) const {
+ bool is_tracing;
+ TRACE_EVENT_CATEGORY_GROUP_ENABLED(
+ TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), &is_tracing);
+ if (!is_tracing || !name_)
return;
+ if (!is_locked)
alex clarke (OOO till 29th) 2015/02/25 12:37:51 Did you consider using lock_.Try() here?
alex clarke (OOO till 29th) 2015/02/25 12:38:51 Ah you can't do that on the same thread.
+ lock_.Acquire();
+ else
+ lock_.AssertAcquired();
TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), name_,
- work_queue_.size());
+ incoming_queue_.size() + work_queue_.size());
+ if (!is_locked)
+ lock_.Release();
}
void TaskQueue::EnqueueTask(const base::PendingTask& pending_task) {
@@ -197,6 +206,7 @@ void TaskQueue::EnqueueTaskLocked(const base::PendingTask& pending_task) {
// before getting here.
incoming_queue_.back().delayed_run_time = base::TimeTicks();
}
+ TraceQueueSize(true);
}
void TaskQueue::SetAutoPump(bool auto_pump) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698