| Index: third_party/tcmalloc/chromium/src/heap-profiler.cc | 
| diff --git a/third_party/tcmalloc/chromium/src/heap-profiler.cc b/third_party/tcmalloc/chromium/src/heap-profiler.cc | 
| index cb34f018daaa337420680929de473ea5d242a57d..1327f4099c60326e74656189383f5df29e7743f4 100644 | 
| --- a/third_party/tcmalloc/chromium/src/heap-profiler.cc | 
| +++ b/third_party/tcmalloc/chromium/src/heap-profiler.cc | 
| @@ -71,7 +71,6 @@ | 
| #include "heap-profile-table.h" | 
| #include "memory_region_map.h" | 
|  | 
| - | 
| #ifndef	PATH_MAX | 
| #ifdef MAXPATHLEN | 
| #define	PATH_MAX	MAXPATHLEN | 
| @@ -117,7 +116,12 @@ DEFINE_bool(only_mmap_profile, | 
| EnvToBool("HEAP_PROFILE_ONLY_MMAP", false), | 
| "If heap-profiling is on, only profile mmap, mremap, and sbrk; " | 
| "do not profile malloc/new/etc"); | 
| - | 
| +#ifdef DEEP_PROFILER_ON | 
| +DEFINE_int64(heap_profile_time_interval, | 
| +             EnvToInt64("HEAP_PROFILE_TIME_INTERVAL", 0), | 
| +             "If non-zero, dump heap profiling information once every " | 
| +             "specified number of seconds since the last dump."); | 
| +#endif | 
|  | 
| //---------------------------------------------------------------------- | 
| // Locking | 
| @@ -145,8 +149,7 @@ static void ProfilerFree(void* p) { | 
| } | 
|  | 
| // We use buffers of this size in DoGetHeapProfile. | 
| -static const int kProfileBufferSize = 1 << 20; | 
| - | 
| +static const int kProfileBufferSize = 5 << 20; | 
| // This is a last-ditch buffer we use in DumpProfileLocked in case we | 
| // can't allocate more memory from ProfilerMalloc.  We expect this | 
| // will be used by HeapProfileEndWriter when the application has to | 
| @@ -168,9 +171,15 @@ static int   dump_count = 0;          // How many dumps so far | 
| static int64 last_dump_alloc = 0;     // alloc_size when did we last dump | 
| static int64 last_dump_free = 0;      // free_size when did we last dump | 
| static int64 high_water_mark = 0;     // In-use-bytes at last high-water dump | 
| +static int64 last_dump_time = 0;      // The time of the last dump | 
|  | 
| static HeapProfileTable* heap_profile = NULL;  // the heap profile table | 
|  | 
| +#ifdef DEEP_PROFILER_ON | 
| +#include "deep-memory-profiler.h" | 
| +static DeepMemoryProfiler* deep_profiler = NULL; // deep memory profiler | 
| +#endif | 
| + | 
| //---------------------------------------------------------------------- | 
| // Profile generation | 
| //---------------------------------------------------------------------- | 
| @@ -185,6 +194,7 @@ static void AddRemoveMMapDataLocked(AddOrRemove mode) { | 
| // MemoryRegionMap maintained all the data we need for all | 
| // mmap-like allocations, so we just use it here: | 
| MemoryRegionMap::LockHolder l; | 
| +  heap_profile->MMapRecordBegin(); | 
| for (MemoryRegionMap::RegionIterator r = MemoryRegionMap::BeginRegionLocked(); | 
| r != MemoryRegionMap::EndRegionLocked(); ++r) { | 
| if (mode == ADD) { | 
| @@ -196,6 +206,7 @@ static void AddRemoveMMapDataLocked(AddOrRemove mode) { | 
| heap_profile->RecordFree(reinterpret_cast<void*>(r->start_addr)); | 
| } | 
| } | 
| +  heap_profile->MMapRecordEnd(); | 
| } | 
|  | 
| // Input must be a buffer of size at least 1MB. | 
| @@ -211,7 +222,11 @@ static char* DoGetHeapProfileLocked(char* buf, int buflen) { | 
| HeapProfileTable::Stats const stats = heap_profile->total(); | 
| (void)stats;   // avoid an unused-variable warning in non-debug mode. | 
| AddRemoveMMapDataLocked(ADD); | 
| +#ifdef DEEP_PROFILER_ON | 
| +    bytes_written = deep_profiler->FillOrderedProfile(buf, buflen - 1); | 
| +#else | 
| bytes_written = heap_profile->FillOrderedProfile(buf, buflen - 1); | 
| +#endif | 
| // FillOrderedProfile should not reduce the set of active mmap-ed regions, | 
| // hence MemoryRegionMap will let us remove everything we've added above: | 
| AddRemoveMMapDataLocked(REMOVE); | 
| @@ -310,6 +325,12 @@ static void MaybeDumpProfileLocked() { | 
| snprintf(buf, sizeof(buf), "%"PRId64" MB currently in use", | 
| inuse_bytes >> 20); | 
| need_to_dump = true; | 
| +    } else if (FLAGS_heap_profile_time_interval > 0 && | 
| +               time(NULL) - last_dump_time >= FLAGS_heap_profile_time_interval) { | 
| +      snprintf(buf, sizeof(buf), "%d sec since the last dump", | 
| +               time(NULL) - last_dump_time); | 
| +      need_to_dump = true; | 
| +      last_dump_time = time(NULL); | 
| } | 
| if (need_to_dump) { | 
| DumpProfileLocked(buf); | 
| @@ -470,6 +491,14 @@ extern "C" void HeapProfilerStart(const char* prefix) { | 
| last_dump_alloc = 0; | 
| last_dump_free = 0; | 
| high_water_mark = 0; | 
| +  last_dump_time = 0; | 
| + | 
| +#ifdef DEEP_PROFILER_ON | 
| +  // Initialize deep memory profiler | 
| +  RAW_VLOG(0, "[%d] Starting a deep memory profiler", getpid()); | 
| +  deep_profiler = new(ProfilerMalloc(sizeof(DeepMemoryProfiler))) | 
| +      DeepMemoryProfiler(heap_profile, prefix); | 
| +#endif | 
|  | 
| // We do not reset dump_count so if the user does a sequence of | 
| // HeapProfilerStart/HeapProfileStop, we will get a continuous | 
| @@ -512,6 +541,13 @@ extern "C" void HeapProfilerStop() { | 
| RAW_CHECK(MallocHook::RemoveMunmapHook(&MunmapHook), ""); | 
| } | 
|  | 
| +#ifdef DEEP_PROFILER_ON | 
| +  // free deep memory profiler | 
| +  deep_profiler->~DeepMemoryProfiler(); | 
| +  ProfilerFree(deep_profiler); | 
| +  deep_profiler = NULL; | 
| +#endif | 
| + | 
| // free profile | 
| heap_profile->~HeapProfileTable(); | 
| ProfilerFree(heap_profile); | 
|  |