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

Side by Side Diff: third_party/tcmalloc/chromium/src/deep-heap-profile.cc

Issue 11418237: Get DMP to run without HEAP_PROFILE_MMAP=1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // --- 5 // ---
6 // Author: Sainbayar Sukhbaatar 6 // Author: Sainbayar Sukhbaatar
7 // Dai Mikurube 7 // Dai Mikurube
8 // 8 //
9 9
10 #include "deep-heap-profile.h" 10 #include "deep-heap-profile.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 238 }
239 // Write maps into "|filename_prefix_|.<pid>.|dump_count_|.maps". 239 // Write maps into "|filename_prefix_|.<pid>.|dump_count_|.maps".
240 WriteProcMaps(filename_prefix_, dump_count_, 240 WriteProcMaps(filename_prefix_, dump_count_,
241 kProfilerBufferSize, profiler_buffer_); 241 kProfilerBufferSize, profiler_buffer_);
242 242
243 // Reset committed sizes of buckets. 243 // Reset committed sizes of buckets.
244 deep_table_.ResetCommittedSize(); 244 deep_table_.ResetCommittedSize();
245 245
246 // Allocate a list for mmap'ed regions. 246 // Allocate a list for mmap'ed regions.
247 num_mmap_allocations_ = 0; 247 num_mmap_allocations_ = 0;
248 heap_profile_->mmap_address_map_->Iterate(CountMMap, this); 248 if (heap_profile_->mmap_address_map_) {
249 mmap_list_length_ = 0; 249 heap_profile_->mmap_address_map_->Iterate(CountMMap, this);
250 mmap_list_ = reinterpret_cast<MMapListEntry*>(heap_profile_->alloc_(
251 sizeof(MMapListEntry) * num_mmap_allocations_));
252 250
253 // Touch all the allocated pages. Touching is required to avoid new page 251 mmap_list_length_ = 0;
254 // commitment while filling the list in SnapshotProcMaps. 252 mmap_list_ = reinterpret_cast<MMapListEntry*>(heap_profile_->alloc_(
255 for (int i = 0; 253 sizeof(MMapListEntry) * num_mmap_allocations_));
256 i < num_mmap_allocations_; 254
257 i += getpagesize() / 2 / sizeof(MMapListEntry)) 255 // Touch all the allocated pages. Touching is required to avoid new page
258 mmap_list_[i].first_address = 0; 256 // commitment while filling the list in SnapshotProcMaps.
259 mmap_list_[num_mmap_allocations_ - 1].last_address = 0; 257 for (int i = 0;
258 i < num_mmap_allocations_;
259 i += getpagesize() / 2 / sizeof(MMapListEntry))
260 mmap_list_[i].first_address = 0;
261 mmap_list_[num_mmap_allocations_ - 1].last_address = 0;
262 }
260 263
261 stats_.SnapshotProcMaps(memory_residence_info_getter_, NULL, 0); 264 stats_.SnapshotProcMaps(memory_residence_info_getter_, NULL, 0);
262 265
263 // TODO(dmikurube): Eliminate dynamic memory allocation caused by snprintf. 266 // TODO(dmikurube): Eliminate dynamic memory allocation caused by snprintf.
264 // glibc's snprintf internally allocates memory by alloca normally, but it 267 // glibc's snprintf internally allocates memory by alloca normally, but it
265 // allocates memory by malloc if large memory is required. 268 // allocates memory by malloc if large memory is required.
266 269
267 // Record committed sizes. 270 // Record committed sizes.
268 stats_.SnapshotAllocations(this); 271 stats_.SnapshotAllocations(this);
269 272
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 void DeepHeapProfile::GlobalStats::SnapshotAllocations( 697 void DeepHeapProfile::GlobalStats::SnapshotAllocations(
695 DeepHeapProfile* deep_profile) { 698 DeepHeapProfile* deep_profile) {
696 profiled_mmap_.Initialize(); 699 profiled_mmap_.Initialize();
697 profiled_malloc_.Initialize(); 700 profiled_malloc_.Initialize();
698 701
699 // malloc allocations. 702 // malloc allocations.
700 deep_profile->heap_profile_->alloc_address_map_->Iterate(RecordAlloc, 703 deep_profile->heap_profile_->alloc_address_map_->Iterate(RecordAlloc,
701 deep_profile); 704 deep_profile);
702 705
703 // mmap allocations. 706 // mmap allocations.
704 deep_profile->heap_profile_->mmap_address_map_->Iterate(RecordMMap, 707 if (deep_profile->heap_profile_->mmap_address_map_) {
705 deep_profile); 708 deep_profile->heap_profile_->mmap_address_map_->Iterate(RecordMMap,
706 std::sort(deep_profile->mmap_list_, 709 deep_profile);
707 deep_profile->mmap_list_ + deep_profile->mmap_list_length_, 710 std::sort(deep_profile->mmap_list_,
708 ByFirstAddress); 711 deep_profile->mmap_list_ + deep_profile->mmap_list_length_,
712 ByFirstAddress);
713 }
709 } 714 }
710 715
711 void DeepHeapProfile::GlobalStats::Unparse(TextBuffer* buffer) { 716 void DeepHeapProfile::GlobalStats::Unparse(TextBuffer* buffer) {
712 RegionStats all_total; 717 RegionStats all_total;
713 RegionStats nonprofiled_total; 718 RegionStats nonprofiled_total;
714 for (int i = 0; i < NUMBER_OF_MAPS_REGION_TYPES; ++i) { 719 for (int i = 0; i < NUMBER_OF_MAPS_REGION_TYPES; ++i) {
715 all_total.AddAnotherRegionStat(all_[i]); 720 all_total.AddAnotherRegionStat(all_[i]);
716 nonprofiled_total.AddAnotherRegionStat(nonprofiled_[i]); 721 nonprofiled_total.AddAnotherRegionStat(nonprofiled_[i]);
717 } 722 }
718 723
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 } 856 }
852 857
853 DeepHeapProfile::~DeepHeapProfile() { 858 DeepHeapProfile::~DeepHeapProfile() {
854 } 859 }
855 860
856 int DeepHeapProfile::FillOrderedProfile(char raw_buffer[], int buffer_size) { 861 int DeepHeapProfile::FillOrderedProfile(char raw_buffer[], int buffer_size) {
857 return heap_profile_->FillOrderedProfile(raw_buffer, buffer_size); 862 return heap_profile_->FillOrderedProfile(raw_buffer, buffer_size);
858 } 863 }
859 864
860 #endif // DEEP_HEAP_PROFILE 865 #endif // DEEP_HEAP_PROFILE
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698