diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-30 03:44:25 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-30 03:44:25 +0000 |
commit | f0ab5bae61e2691b4434e67d124247b9a7c4d1e8 (patch) | |
tree | 5aadb1578fa27fcd113a4d193df8f2010497d760 /base/threading | |
parent | 0bc27162426c0597db38942f09ab00382c67dfb6 (diff) | |
download | chromium_src-f0ab5bae61e2691b4434e67d124247b9a7c4d1e8.zip chromium_src-f0ab5bae61e2691b4434e67d124247b9a7c4d1e8.tar.gz chromium_src-f0ab5bae61e2691b4434e67d124247b9a7c4d1e8.tar.bz2 |
Fully enable about:tracking by default
This is a re-land of:
http://codereview.chromium.org/8391019/
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=107793
Original landing had trouble with message_loop_x.h, due to header
include ordering. I pulled out the structure that was really needed by
tracked_objects.h into a new file tracked_info.*. This allows tracked_objects
to inlude this tracked_info, but not have to include the message_loop.h
totality. I also removed a DCHECK that that was triggering on a test,
and added yet one more file (browser_main.cc) where I removed a #ifdef
for TRACKING_ALL_OBJECTS. The changes were minor, and I'm hoping to get
clear perf runs with tihs landing, so I'm going to TBR it and reland
early in the morning.
Comments from original landing:
Support is now controlled by the flag:
--enable-tracking
and the default is always on. To turn it off, use:
--enable-tracking=0
All profiler code is compiled now in release and official
builds (in addition to debug, where it was already active),
but most entry points can be disabled (turned into no-ops)
by a single const bool setting atop tracked_objects.cc (in
case folks want to revert the perf-impact of this change).
Transition to faster Now() service on Windows for the
profiler use only.
The TimeTicks::Now() function on Window uses locking
to get a 64 bit time value. This CL transitions
times used for profiling to more directly use a
32 bit Time interface, which is actually what drives the
64 bit TimeTicks. By using the smaller value, we avoid
the need for locks, or even atomic operations for the most
part in the tracking system. On linux, we just down-sample
the standard TimeTicks to 32 bits for consistency (clean
ability to snapshot asyncronously without atomics...
but I should verify that such is helpful to performance).
I've also put in yet more cleanup and refactoring.
tbr=rtenneti
bug=101856
Review URL: http://codereview.chromium.org/8414036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107895 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/threading')
-rw-r--r-- | base/threading/thread.cc | 2 | ||||
-rw-r--r-- | base/threading/worker_pool_posix.cc | 19 | ||||
-rw-r--r-- | base/threading/worker_pool_posix.h | 6 | ||||
-rw-r--r-- | base/threading/worker_pool_win.cc | 24 |
4 files changed, 19 insertions, 32 deletions
diff --git a/base/threading/thread.cc b/base/threading/thread.cc index 2a8d999..d49f247 100644 --- a/base/threading/thread.cc +++ b/base/threading/thread.cc @@ -152,9 +152,7 @@ void Thread::ThreadMain() { ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector. message_loop.set_thread_name(name_); message_loop_ = &message_loop; -#if defined(TRACK_ALL_TASK_OBJECTS) tracked_objects::ThreadData::InitializeThreadContext(name_); -#endif // TRACK_ALL_TASK_OBJECTS // Let the thread do extra initialization. // Let's do this before signaling we are started. diff --git a/base/threading/worker_pool_posix.cc b/base/threading/worker_pool_posix.cc index 41fa01a..917565d 100644 --- a/base/threading/worker_pool_posix.cc +++ b/base/threading/worker_pool_posix.cc @@ -88,15 +88,14 @@ void WorkerThread::ThreadMain() { "src_file", pending_task.posted_from.file_name(), "src_func", pending_task.posted_from.function_name()); -#if defined(TRACK_ALL_TASK_OBJECTS) - TimeTicks start_of_run = tracked_objects::ThreadData::Now(); -#endif // defined(TRACK_ALL_TASK_OBJECTS) + tracked_objects::TrackedTime start_time = + tracked_objects::ThreadData::Now(); + pending_task.task.Run(); -#if defined(TRACK_ALL_TASK_OBJECTS) - tracked_objects::ThreadData::TallyADeathIfActive(pending_task.post_births, - pending_task.time_posted, TimeTicks(), start_of_run, - tracked_objects::ThreadData::Now()); -#endif // defined(TRACK_ALL_TASK_OBJECTS) + + tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( + pending_task.birth_tally, pending_task.time_posted, + start_time, tracked_objects::ThreadData::Now()); } // The WorkerThread is non-joinable, so it deletes itself. @@ -122,10 +121,8 @@ PosixDynamicThreadPool::PendingTask::PendingTask( const base::Closure& task) : posted_from(posted_from), task(task) { -#if defined(TRACK_ALL_TASK_OBJECTS) - post_births = tracked_objects::ThreadData::TallyABirthIfActive(posted_from); + birth_tally = tracked_objects::ThreadData::TallyABirthIfActive(posted_from); time_posted = tracked_objects::ThreadData::Now(); -#endif // defined(TRACK_ALL_TASK_OBJECTS) } PosixDynamicThreadPool::PendingTask::~PendingTask() { diff --git a/base/threading/worker_pool_posix.h b/base/threading/worker_pool_posix.h index c0a60cc..2cc1150 100644 --- a/base/threading/worker_pool_posix.h +++ b/base/threading/worker_pool_posix.h @@ -53,13 +53,11 @@ class BASE_EXPORT PosixDynamicThreadPool const base::Closure& task); ~PendingTask(); -#if defined(TRACK_ALL_TASK_OBJECTS) // Counter for location where the Closure was posted from. - tracked_objects::Births* post_births; + tracked_objects::Births* birth_tally; // Time the task was posted. - TimeTicks time_posted; -#endif // defined(TRACK_ALL_TASK_OBJECTS) + tracked_objects::TrackedTime time_posted; const tracked_objects::Location posted_from; diff --git a/base/threading/worker_pool_win.cc b/base/threading/worker_pool_win.cc index 0cd3d96..b73cabd 100644 --- a/base/threading/worker_pool_win.cc +++ b/base/threading/worker_pool_win.cc @@ -20,19 +20,15 @@ struct PendingTask { const base::Closure& task) : posted_from(posted_from), task(task) { -#if defined(TRACK_ALL_TASK_OBJECTS) - post_births = tracked_objects::ThreadData::TallyABirthIfActive(posted_from); + birth_tally = tracked_objects::ThreadData::TallyABirthIfActive(posted_from); time_posted = tracked_objects::ThreadData::Now(); -#endif // defined(TRACK_ALL_TASK_OBJECTS) } -#if defined(TRACK_ALL_TASK_OBJECTS) // Counter for location where the Closure was posted from. - tracked_objects::Births* post_births; + tracked_objects::Births* birth_tally; // Time the task was posted. - TimeTicks time_posted; -#endif // defined(TRACK_ALL_TASK_OBJECTS) + tracked_objects::TrackedTime time_posted; // The site this PendingTask was posted from. tracked_objects::Location posted_from; @@ -47,15 +43,13 @@ DWORD CALLBACK WorkItemCallback(void* param) { "src_file", pending_task->posted_from.file_name(), "src_func", pending_task->posted_from.function_name()); -#if defined(TRACK_ALL_TASK_OBJECTS) - TimeTicks start_of_run = tracked_objects::ThreadData::Now(); -#endif // defined(TRACK_ALL_TASK_OBJECTS) + tracked_objects::TrackedTime start_time = tracked_objects::ThreadData::Now(); + pending_task->task.Run(); -#if defined(TRACK_ALL_TASK_OBJECTS) - tracked_objects::ThreadData::TallyADeathIfActive(pending_task->post_births, - pending_task->time_posted, TimeTicks::TimeTicks(), start_of_run, - tracked_objects::ThreadData::Now()); -#endif // defined(TRACK_ALL_TASK_OBJECTS) + + tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( + pending_task->birth_tally, pending_task->time_posted, + start_time, tracked_objects::ThreadData::Now()); delete pending_task; return 0; |