summaryrefslogtreecommitdiffstats
path: root/base/tracked_objects.cc
diff options
context:
space:
mode:
authorvadimt <vadimt@chromium.org>2015-03-31 17:09:35 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-01 00:10:18 +0000
commit379d7fe794b4a200e08ac3f23c69184edef085f7 (patch)
tree82f80ce8e1c9253f027b7c750ef2abbb7431b7d8 /base/tracked_objects.cc
parenta7d16cadb7ca6e8d505ae37be437a4ad103d51bc (diff)
downloadchromium_src-379d7fe794b4a200e08ac3f23c69184edef085f7.zip
chromium_src-379d7fe794b4a200e08ac3f23c69184edef085f7.tar.gz
chromium_src-379d7fe794b4a200e08ac3f23c69184edef085f7.tar.bz2
Introducing phased profiling framework.
TrackingSynchronizer can send a "phase completed" message to all processes. Their ThreadData's make a snapshot of task deaths and store it in a static map, associating with the number of the completed phase. They also clean the death data. When requested to return a tasks snapshot, ThreadData returns that saved map, adding a snapshot of current task deaths as a separate "current" phase. The rest of code was transformed to work with the map of snapshots instead of a single snapshot. BUG=456354 Review URL: https://codereview.chromium.org/985773002 Cr-Commit-Position: refs/heads/master@{#323151}
Diffstat (limited to 'base/tracked_objects.cc')
-rw-r--r--base/tracked_objects.cc101
1 files changed, 56 insertions, 45 deletions
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc
index 5359d89..32ec75c 100644
--- a/base/tracked_objects.cc
+++ b/base/tracked_objects.cc
@@ -390,23 +390,9 @@ void ThreadData::OnThreadTerminationCleanup() {
}
// static
-void ThreadData::Snapshot(ProcessDataSnapshot* process_data) {
- // Add births that have run to completion to |collected_data|.
- // |birth_counts| tracks the total number of births recorded at each location
- // for which we have not seen a death count.
- BirthCountMap birth_counts;
- ThreadData::SnapshotAllExecutedTasks(process_data, &birth_counts);
-
- // Add births that are still active -- i.e. objects that have tallied a birth,
- // but have not yet tallied a matching death, and hence must be either
- // running, queued up, or being held in limbo for future posting.
- for (BirthCountMap::const_iterator it = birth_counts.begin();
- it != birth_counts.end(); ++it) {
- if (it->second > 0) {
- process_data->tasks.push_back(
- TaskSnapshot(*it->first, DeathData(it->second), "Still_Alive"));
- }
- }
+void ThreadData::Snapshot(ProcessDataSnapshot* process_data_snapshot) {
+ ThreadData::SnapshotCurrentPhase(
+ &process_data_snapshot->phased_process_data_snapshots[0]);
}
Births* ThreadData::TallyABirth(const Location& location) {
@@ -578,8 +564,9 @@ void ThreadData::TallyRunInAScopedRegionIfTracking(
}
// static
-void ThreadData::SnapshotAllExecutedTasks(ProcessDataSnapshot* process_data,
- BirthCountMap* birth_counts) {
+void ThreadData::SnapshotAllExecutedTasks(
+ ProcessDataPhaseSnapshot* process_data_phase,
+ BirthCountMap* birth_counts) {
if (!kTrackAllTaskObjects)
return; // Not compiled in.
@@ -595,12 +582,33 @@ void ThreadData::SnapshotAllExecutedTasks(ProcessDataSnapshot* process_data,
for (ThreadData* thread_data = my_list;
thread_data;
thread_data = thread_data->next()) {
- thread_data->SnapshotExecutedTasks(process_data, birth_counts);
+ thread_data->SnapshotExecutedTasks(process_data_phase, birth_counts);
+ }
+}
+
+// static
+void ThreadData::SnapshotCurrentPhase(
+ ProcessDataPhaseSnapshot* process_data_phase) {
+ // Add births that have run to completion to |collected_data|.
+ // |birth_counts| tracks the total number of births recorded at each location
+ // for which we have not seen a death count.
+ BirthCountMap birth_counts;
+ ThreadData::SnapshotAllExecutedTasks(process_data_phase, &birth_counts);
+
+ // Add births that are still active -- i.e. objects that have tallied a birth,
+ // but have not yet tallied a matching death, and hence must be either
+ // running, queued up, or being held in limbo for future posting.
+ for (const auto& birth_count : birth_counts) {
+ if (birth_count.second > 0) {
+ process_data_phase->tasks.push_back(TaskSnapshot(
+ *birth_count.first, DeathData(birth_count.second), "Still_Alive"));
+ }
}
}
-void ThreadData::SnapshotExecutedTasks(ProcessDataSnapshot* process_data,
- BirthCountMap* birth_counts) {
+void ThreadData::SnapshotExecutedTasks(
+ ProcessDataPhaseSnapshot* process_data_phase,
+ BirthCountMap* birth_counts) {
// Get copy of data, so that the data will not change during the iterations
// and processing.
ThreadData::BirthMap birth_map;
@@ -608,24 +616,22 @@ void ThreadData::SnapshotExecutedTasks(ProcessDataSnapshot* process_data,
ThreadData::ParentChildSet parent_child_set;
SnapshotMaps(&birth_map, &death_map, &parent_child_set);
- for (ThreadData::DeathMap::const_iterator it = death_map.begin();
- it != death_map.end(); ++it) {
- process_data->tasks.push_back(
- TaskSnapshot(*it->first, it->second, thread_name()));
- (*birth_counts)[it->first] -= it->first->birth_count();
+ for (const auto& death : death_map) {
+ process_data_phase->tasks.push_back(
+ TaskSnapshot(*death.first, death.second, thread_name()));
+ (*birth_counts)[death.first] -= death.first->birth_count();
}
- for (ThreadData::BirthMap::const_iterator it = birth_map.begin();
- it != birth_map.end(); ++it) {
- (*birth_counts)[it->second] += it->second->birth_count();
+ for (const auto& birth : birth_map) {
+ (*birth_counts)[birth.second] += birth.second->birth_count();
}
if (!kTrackParentChildLinks)
return;
- for (ThreadData::ParentChildSet::const_iterator it = parent_child_set.begin();
- it != parent_child_set.end(); ++it) {
- process_data->descendants.push_back(ParentChildPairSnapshot(*it));
+ for (const auto& parent_child : parent_child_set) {
+ process_data_phase->descendants.push_back(
+ ParentChildPairSnapshot(parent_child));
}
}
@@ -634,20 +640,16 @@ void ThreadData::SnapshotMaps(BirthMap* birth_map,
DeathMap* death_map,
ParentChildSet* parent_child_set) {
base::AutoLock lock(map_lock_);
- for (BirthMap::const_iterator it = birth_map_.begin();
- it != birth_map_.end(); ++it)
- (*birth_map)[it->first] = it->second;
- for (DeathMap::iterator it = death_map_.begin();
- it != death_map_.end(); ++it) {
- (*death_map)[it->first] = it->second;
- }
+ for (const auto& birth : birth_map_)
+ (*birth_map)[birth.first] = birth.second;
+ for (const auto& death : death_map_)
+ (*death_map)[death.first] = death.second;
if (!kTrackParentChildLinks)
return;
- for (ParentChildSet::iterator it = parent_child_set_.begin();
- it != parent_child_set_.end(); ++it)
- parent_child_set->insert(*it);
+ for (const auto& parent_child : parent_child_set_)
+ parent_child_set->insert(parent_child);
}
static void OptionallyInitializeAlternateTimer() {
@@ -959,13 +961,22 @@ ParentChildPairSnapshot::~ParentChildPairSnapshot() {
}
//------------------------------------------------------------------------------
-// ProcessDataSnapshot
+// ProcessDataPhaseSnapshot
+
+ProcessDataPhaseSnapshot::ProcessDataPhaseSnapshot() {
+}
+
+ProcessDataPhaseSnapshot::~ProcessDataPhaseSnapshot() {
+}
+
+//------------------------------------------------------------------------------
+// ProcessDataPhaseSnapshot
ProcessDataSnapshot::ProcessDataSnapshot()
#if !defined(OS_NACL)
: process_id(base::GetCurrentProcId()) {
#else
- : process_id(0) {
+ : process_id(base::kNullProcessId) {
#endif
}