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

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

Issue 9963095: Reserve a dedicated arena for every construction of mmap_address_map. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: just rebased. Created 8 years, 8 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 1ef18586e4d050e6e0d1ded2b5ca2df256c058be..696f41e0b9cedbbaf36f43fd71e36605eb0e8117 100644
--- a/third_party/tcmalloc/chromium/src/heap-profile-table.cc
+++ b/third_party/tcmalloc/chromium/src/heap-profile-table.cc
@@ -123,7 +123,12 @@ static bool ByAllocatedSpace(HeapProfileTable::Stats* a,
//----------------------------------------------------------------------
HeapProfileTable::HeapProfileTable(Allocator alloc, DeAllocator dealloc)
- : alloc_(alloc), dealloc_(dealloc) {
+ : alloc_(alloc),
+ dealloc_(dealloc),
+ num_alloc_buckets_(0),
+ mmap_table_(NULL),
+ num_available_mmap_buckets_(0),
+ mmap_address_map_(NULL) {
// Initialize the overall profile stats.
memset(&total_, 0, sizeof(total_));
@@ -131,16 +136,10 @@ HeapProfileTable::HeapProfileTable(Allocator alloc, DeAllocator dealloc)
const int alloc_table_bytes = kHashTableSize * sizeof(*alloc_table_);
alloc_table_ = reinterpret_cast<Bucket**>(alloc_(alloc_table_bytes));
memset(alloc_table_, 0, alloc_table_bytes);
- num_alloc_buckets_ = 0;
-
- // Initialize the mmap table.
- mmap_table_ = NULL;
- num_available_mmap_buckets_ = 0;
// Make malloc and mmap allocation maps.
alloc_address_map_ =
new(alloc_(sizeof(AllocationMap))) AllocationMap(alloc_, dealloc_);
- mmap_address_map_ = NULL;
}
HeapProfileTable::~HeapProfileTable() {
@@ -355,7 +354,8 @@ HeapProfileTable::MakeSortedBucketList() const {
return list;
}
-void HeapProfileTable::RefreshMMapData() {
+void HeapProfileTable::RefreshMMapData(Allocator mmap_alloc,
+ DeAllocator mmap_dealloc) {
// Make the table
static const int mmap_table_bytes = kHashTableSize * sizeof(*mmap_table_);
if (mmap_table_ == NULL) {
@@ -365,8 +365,8 @@ void HeapProfileTable::RefreshMMapData() {
num_available_mmap_buckets_ = 0;
ClearMMapData();
- mmap_address_map_ =
- new(alloc_(sizeof(AllocationMap))) AllocationMap(alloc_, dealloc_);
+ mmap_address_map_ = new(alloc_(sizeof(AllocationMap)))
+ AllocationMap(mmap_alloc, mmap_dealloc);
MemoryRegionMap::LockHolder l;
for (MemoryRegionMap::RegionIterator r =
@@ -388,12 +388,12 @@ void HeapProfileTable::RefreshMMapData() {
}
void HeapProfileTable::ClearMMapData() {
- if (mmap_address_map_ != NULL) {
- mmap_address_map_->Iterate(ZeroBucketCountsIterator, this);
- mmap_address_map_->~AllocationMap();
- dealloc_(mmap_address_map_);
- mmap_address_map_ = NULL;
- }
+ if (mmap_address_map_ == NULL) return;
+
+ mmap_address_map_->Iterate(ZeroBucketCountsIterator, this);
+ mmap_address_map_->~AllocationMap();
+ dealloc_(mmap_address_map_);
+ mmap_address_map_ = NULL;
}
void HeapProfileTable::IterateOrderedAllocContexts(
@@ -505,22 +505,21 @@ bool HeapProfileTable::WriteProfile(const char* file_name,
AllocationMap* allocations) {
RAW_VLOG(1, "Dumping non-live heap profile to %s", file_name);
RawFD fd = RawOpenForWriting(file_name);
- if (fd != kIllegalRawFD) {
- RawWrite(fd, kProfileHeader, strlen(kProfileHeader));
- char buf[512];
- int len = UnparseBucket(total, buf, 0, sizeof(buf), " heapprofile",
- NULL);
- RawWrite(fd, buf, len);
- const DumpArgs args(fd, NULL);
- allocations->Iterate<const DumpArgs&>(DumpNonLiveIterator, args);
- RawWrite(fd, kProcSelfMapsHeader, strlen(kProcSelfMapsHeader));
- DumpProcSelfMaps(fd);
- RawClose(fd);
- return true;
- } else {
+ if (fd == kIllegalRawFD) {
RAW_LOG(ERROR, "Failed dumping filtered heap profile to %s", file_name);
return false;
}
+ RawWrite(fd, kProfileHeader, strlen(kProfileHeader));
+ char buf[512];
+ int len = UnparseBucket(total, buf, 0, sizeof(buf), " heapprofile",
+ NULL);
+ RawWrite(fd, buf, len);
+ const DumpArgs args(fd, NULL);
+ allocations->Iterate<const DumpArgs&>(DumpNonLiveIterator, args);
+ RawWrite(fd, kProcSelfMapsHeader, strlen(kProcSelfMapsHeader));
+ DumpProcSelfMaps(fd);
+ RawClose(fd);
+ return true;
}
void HeapProfileTable::CleanupOldProfiles(const char* prefix) {
« no previous file with comments | « third_party/tcmalloc/chromium/src/heap-profile-table.h ('k') | third_party/tcmalloc/chromium/src/heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698