summaryrefslogtreecommitdiffstats
path: root/base/threading
diff options
context:
space:
mode:
authorvadimt <vadimt@chromium.org>2014-09-15 12:19:38 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-15 19:24:08 +0000
commit12f0f7db8095f1a5e40fb7227b217ddfc1724116 (patch)
tree91c53ad3932e0b73b5715ab936530007a8b7f831 /base/threading
parent2e9bcdf661d0231880bafc4be33f74b6f6b685a8 (diff)
downloadchromium_src-12f0f7db8095f1a5e40fb7227b217ddfc1724116.zip
chromium_src-12f0f7db8095f1a5e40fb7227b217ddfc1724116.tar.gz
chromium_src-12f0f7db8095f1a5e40fb7227b217ddfc1724116.tar.bz2
Creating a framework for suppressing pollution of the profiler data and applying for know cases of pollution.
See the bug. The CL introduces TaskStopwatch that has to be used to measure run time for tasks. It takes care of double-counting run time in the nested-tasks case by subtracting run time of nested tasks from their parents. TaskStopwatch can be also used for subtracting other nested intervals, such as the time while a nested message pump runs. ThreadData::TallyADeath now takes a stopwatch parameter instead of start_time and end_time. This helps avoid mistakes when the interval passed up to the parent for exclusion is different from the interval for the current task duration. BUG=401560 Review URL: https://codereview.chromium.org/445413003 Cr-Commit-Position: refs/heads/master@{#294865}
Diffstat (limited to 'base/threading')
-rw-r--r--base/threading/sequenced_worker_pool.cc10
-rw-r--r--base/threading/worker_pool_posix.cc8
-rw-r--r--base/threading/worker_pool_win.cc11
3 files changed, 16 insertions, 13 deletions
diff --git a/base/threading/sequenced_worker_pool.cc b/base/threading/sequenced_worker_pool.cc
index 532f26e..38b2998 100644
--- a/base/threading/sequenced_worker_pool.cc
+++ b/base/threading/sequenced_worker_pool.cc
@@ -755,13 +755,13 @@ void SequencedWorkerPool::Inner::ThreadLoop(Worker* this_worker) {
this_worker->set_running_task_info(
SequenceToken(task.sequence_token_id), task.shutdown_behavior);
- tracked_objects::TrackedTime start_time =
- tracked_objects::ThreadData::NowForStartOfRun(task.birth_tally);
-
+ tracked_objects::ThreadData::PrepareForStartOfRun(task.birth_tally);
+ tracked_objects::TaskStopwatch stopwatch;
task.task.Run();
+ stopwatch.Stop();
- tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking(task,
- start_time, tracked_objects::ThreadData::NowForEndOfRun());
+ tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking(
+ task, stopwatch);
// Make sure our task is erased outside the lock for the
// same reason we do this with delete_these_oustide_lock.
diff --git a/base/threading/worker_pool_posix.cc b/base/threading/worker_pool_posix.cc
index f00d799..167d20f 100644
--- a/base/threading/worker_pool_posix.cc
+++ b/base/threading/worker_pool_posix.cc
@@ -95,14 +95,14 @@ void WorkerThread::ThreadMain() {
"src_file", pending_task.posted_from.file_name(),
"src_func", pending_task.posted_from.function_name());
- TrackedTime start_time =
- tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally);
-
+ tracked_objects::ThreadData::PrepareForStartOfRun(pending_task.birth_tally);
+ tracked_objects::TaskStopwatch stopwatch;
pending_task.task.Run();
+ stopwatch.Stop();
tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking(
pending_task.birth_tally, TrackedTime(pending_task.time_posted),
- start_time, tracked_objects::ThreadData::NowForEndOfRun());
+ stopwatch);
}
// The WorkerThread is non-joinable, so it deletes itself.
diff --git a/base/threading/worker_pool_win.cc b/base/threading/worker_pool_win.cc
index fa11dc5..8fc7324 100644
--- a/base/threading/worker_pool_win.cc
+++ b/base/threading/worker_pool_win.cc
@@ -25,17 +25,20 @@ DWORD CALLBACK WorkItemCallback(void* param) {
"src_file", pending_task->posted_from.file_name(),
"src_func", pending_task->posted_from.function_name());
- tracked_objects::TrackedTime start_time =
- tracked_objects::ThreadData::NowForStartOfRun(pending_task->birth_tally);
+ tracked_objects::ThreadData::PrepareForStartOfRun(pending_task->birth_tally);
g_worker_pool_running_on_this_thread.Get().Set(true);
+
+ tracked_objects::TaskStopwatch stopwatch;
pending_task->task.Run();
+ stopwatch.Stop();
+
g_worker_pool_running_on_this_thread.Get().Set(false);
tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking(
pending_task->birth_tally,
- tracked_objects::TrackedTime(pending_task->time_posted), start_time,
- tracked_objects::ThreadData::NowForEndOfRun());
+ tracked_objects::TrackedTime(pending_task->time_posted),
+ stopwatch);
delete pending_task;
return 0;