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

Unified Diff: Source/platform/scheduler/Scheduler.cpp

Issue 490913002: Adding flow traces for blink scheduler events (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updates from Alex's comments Created 6 years, 4 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 | « Source/platform/scheduler/Scheduler.h ('k') | Source/platform/scheduler/TracedTask.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/scheduler/Scheduler.cpp
diff --git a/Source/platform/scheduler/Scheduler.cpp b/Source/platform/scheduler/Scheduler.cpp
index fb331ac6e3766aad23db042059ad0c43b549bb18..b0c841eab23e1587d363d4626786c1d4d20f86b4 100644
--- a/Source/platform/scheduler/Scheduler.cpp
+++ b/Source/platform/scheduler/Scheduler.cpp
@@ -73,8 +73,8 @@ public:
class Scheduler::MainThreadPendingTaskRunner : public WebThread::Task {
public:
MainThreadPendingTaskRunner(
- const Scheduler::Task& task, const TraceLocation& location)
- : m_task(task, location)
+ const Scheduler::Task& task, const TraceLocation& location, const char* traceName, int flowTraceID)
+ : m_task(task, location, traceName, flowTraceID)
{
ASSERT(Scheduler::shared());
}
@@ -90,7 +90,7 @@ public:
m_task.run();
}
- Scheduler::TracedTask m_task;
+ TracedTask m_task;
};
Scheduler* Scheduler::s_sharedScheduler = nullptr;
@@ -115,6 +115,9 @@ Scheduler::Scheduler()
: m_sharedTimerFunction(nullptr)
, m_mainThread(blink::Platform::current()->currentThread())
, m_highPriorityTaskCount(0)
+ // flow trace ID begins as the 'this' pointer to help ensure different scheduler
Sami 2014/09/01 13:51:29 nit: Start with capital 'f'.
picksi1 2014/09/01 15:02:32 Done.
+ // instances don't generate identical IDs
+ , m_nextFlowTraceID(static_cast<int>(reinterpret_cast<intptr_t>(this)))
, m_highPriorityTaskRunnerPosted(false)
{
}
@@ -126,31 +129,39 @@ Scheduler::~Scheduler()
}
}
+int Scheduler::generateFlowTraceID()
+{
+ return atomicIncrement(&m_nextFlowTraceID);
+}
+
void Scheduler::scheduleIdleTask(const TraceLocation& location, const IdleTask& idleTask)
{
// TODO: send a real allottedTime here.
m_mainThread->postTask(new MainThreadIdleTaskAdapter(idleTask, 0, location));
}
+void Scheduler::postHighPriorityTaskInternal(const TraceLocation& location, const Task& task, const char * traceName)
Sami 2014/09/01 13:51:29 No space before "*". I think "git cl format" may b
picksi1 2014/09/01 15:02:32 Done. FYI "git cl format" messed up indentation of
+{
+ Locker<Mutex> lock(m_pendingTasksMutex);
+
+ m_pendingHighPriorityTasks.append(TracedTask(task, location, traceName, generateFlowTraceID()));
+ atomicIncrement(&m_highPriorityTaskCount);
+ maybePostMainThreadPendingHighPriorityTaskRunner();
+}
+
void Scheduler::postTask(const TraceLocation& location, const Task& task)
{
- m_mainThread->postTask(new MainThreadPendingTaskRunner(task, location));
+ m_mainThread->postTask(new MainThreadPendingTaskRunner(task, location, "Scheduler::MainThreadTask", generateFlowTraceID()));
}
void Scheduler::postInputTask(const TraceLocation& location, const Task& task)
{
- Locker<Mutex> lock(m_pendingTasksMutex);
- m_pendingHighPriorityTasks.append(TracedTask(task, location));
- atomicIncrement(&m_highPriorityTaskCount);
- maybePostMainThreadPendingHighPriorityTaskRunner();
+ postHighPriorityTaskInternal(location, task, "Scheduler::InputTask");
}
void Scheduler::postCompositorTask(const TraceLocation& location, const Task& task)
{
- Locker<Mutex> lock(m_pendingTasksMutex);
- m_pendingHighPriorityTasks.append(TracedTask(task, location));
- atomicIncrement(&m_highPriorityTaskCount);
- maybePostMainThreadPendingHighPriorityTaskRunner();
+ postHighPriorityTaskInternal(location, task, "Scheduler::CompositorTask");
}
void Scheduler::maybePostMainThreadPendingHighPriorityTaskRunner()
@@ -256,12 +267,4 @@ bool Scheduler::hasPendingHighPriorityWork() const
return acquireLoad(&m_highPriorityTaskCount) != 0;
}
-void Scheduler::TracedTask::run()
-{
- TRACE_EVENT2("blink", "TracedTask::run",
- "src_file", m_location.fileName(),
- "src_func", m_location.functionName());
- m_task();
-}
-
} // namespace blink
« no previous file with comments | « Source/platform/scheduler/Scheduler.h ('k') | Source/platform/scheduler/TracedTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698