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

Unified Diff: third_party/tcmalloc/chromium/src/heap-profile-table.cc

Issue 15418002: Record Chrome trace events in tcmalloc heap profiles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments 2 Created 7 years, 6 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
Index: third_party/tcmalloc/chromium/src/heap-profile-table.cc
diff --git a/third_party/tcmalloc/chromium/src/heap-profile-table.cc b/third_party/tcmalloc/chromium/src/heap-profile-table.cc
index 68ec5735026f8feced50e6612c760ced6915b809..23ba288bbed397221ce99a3c37396414a47655e6 100644
--- a/third_party/tcmalloc/chromium/src/heap-profile-table.cc
+++ b/third_party/tcmalloc/chromium/src/heap-profile-table.cc
@@ -131,6 +131,7 @@ HeapProfileTable::HeapProfileTable(Allocator alloc,
dealloc_(dealloc),
bucket_table_(NULL),
profile_mmap_(profile_mmap),
+ profile_self_maps_(true),
num_buckets_(0),
address_map_(NULL) {
// Make a hash table for buckets.
@@ -393,24 +394,34 @@ void HeapProfileTable::IterateOrderedAllocContexts(
dealloc_(list);
}
+void HeapProfileTable::DisableProfileSelfMaps() {
+ profile_self_maps_ = false;
+}
+
int HeapProfileTable::FillOrderedProfile(char buf[], int size) const {
Bucket** list = MakeSortedBucketList();
- // Our file format is "bucket, bucket, ..., bucket, proc_self_maps_info".
- // In the cases buf is too small, we'd rather leave out the last
- // buckets than leave out the /proc/self/maps info. To ensure that,
- // we actually print the /proc/self/maps info first, then move it to
- // the end of the buffer, then write the bucket info into whatever
- // is remaining, and then move the maps info one last time to close
- // any gaps. Whew!
- int map_length = snprintf(buf, size, "%s", kProcSelfMapsHeader);
- if (map_length < 0 || map_length >= size) return 0;
- bool dummy; // "wrote_all" -- did /proc/self/maps fit in its entirety?
- map_length += FillProcSelfMaps(buf + map_length, size - map_length, &dummy);
- RAW_DCHECK(map_length <= size, "");
- char* const map_start = buf + size - map_length; // move to end
- memmove(map_start, buf, map_length);
- size -= map_length;
+ int map_length = 0;
+ char* map_start = NULL;
+ // The data from /proc/self/maps is not required for pseudo-stack profiles
+ // and increases the size of the profile dumps significantly.
Dai Mikurube (NOT FULLTIME) 2013/07/01 05:47:42 Is maps so large? Is large output so serious? I
James Cook 2013/07/01 16:59:16 There's also a problem where attempting to read /p
James Cook 2013/07/01 22:37:16 The GPU process hang is due to the security sandbo
Dai Mikurube (NOT FULLTIME) 2013/07/02 01:39:06 Ah, makes sense. Sorry that I forgot it. In case o
+ if (profile_self_maps_) {
+ // Our file format is "bucket, bucket, ..., bucket, proc_self_maps_info".
+ // In the cases buf is too small, we'd rather leave out the last
+ // buckets than leave out the /proc/self/maps info. To ensure that,
+ // we actually print the /proc/self/maps info first, then move it to
+ // the end of the buffer, then write the bucket info into whatever
+ // is remaining, and then move the maps info one last time to close
+ // any gaps. Whew!
+ map_length = snprintf(buf, size, "%s", kProcSelfMapsHeader);
+ if (map_length < 0 || map_length >= size) return 0;
+ bool dummy; // "wrote_all" -- did /proc/self/maps fit in its entirety?
+ map_length += FillProcSelfMaps(buf + map_length, size - map_length, &dummy);
+ RAW_DCHECK(map_length <= size, "");
+ map_start = buf + size - map_length; // move to end
+ memmove(map_start, buf, map_length);
+ size -= map_length;
+ }
Stats stats;
memset(&stats, 0, sizeof(stats));
@@ -434,6 +445,9 @@ int HeapProfileTable::FillOrderedProfile(char buf[], int size) const {
dealloc_(list);
+ if (!profile_self_maps_)
+ return bucket_length;
+
RAW_DCHECK(buf + bucket_length <= map_start, "");
memmove(buf + bucket_length, map_start, map_length); // close the gap

Powered by Google App Engine
This is Rietveld 408576698