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

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

Issue 12575008: Dump stats of memory pages which are hooked, but absent from /proc/<pid>/maps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 uint64 last_address_of_unhooked; 697 uint64 last_address_of_unhooked;
698 // If the next mmap entry is away from the current maps line. 698 // If the next mmap entry is away from the current maps line.
699 if (mmap_iter == MemoryRegionMap::EndRegionLocked() || 699 if (mmap_iter == MemoryRegionMap::EndRegionLocked() ||
700 mmap_iter->start_addr > last_address) { 700 mmap_iter->start_addr > last_address) {
701 last_address_of_unhooked = last_address; 701 last_address_of_unhooked = last_address;
702 } else { 702 } else {
703 last_address_of_unhooked = mmap_iter->start_addr - 1; 703 last_address_of_unhooked = mmap_iter->start_addr - 1;
704 } 704 }
705 705
706 if (last_address_of_unhooked + 1 > cursor) { 706 if (last_address_of_unhooked + 1 > cursor) {
707 RAW_CHECK(cursor >= first_address,
708 "Wrong calculation for unhooked");
709 RAW_CHECK(last_address_of_unhooked <= last_address,
710 "Wrong calculation for unhooked");
707 uint64 committed_size = unhooked_[type].Record( 711 uint64 committed_size = unhooked_[type].Record(
708 memory_residence_info_getter, 712 memory_residence_info_getter,
709 cursor, 713 cursor,
710 last_address_of_unhooked); 714 last_address_of_unhooked);
711 if (mmap_dump_buffer) { 715 if (mmap_dump_buffer) {
712 mmap_dump_buffer->AppendString(" ", 0); 716 mmap_dump_buffer->AppendString(" ", 0);
713 mmap_dump_buffer->AppendPtr(cursor, 0); 717 mmap_dump_buffer->AppendPtr(cursor, 0);
714 mmap_dump_buffer->AppendString(" - ", 0); 718 mmap_dump_buffer->AppendString(" - ", 0);
715 mmap_dump_buffer->AppendPtr(last_address_of_unhooked + 1, 0); 719 mmap_dump_buffer->AppendPtr(last_address_of_unhooked + 1, 0);
716 mmap_dump_buffer->AppendString(" unhooked ", 0); 720 mmap_dump_buffer->AppendString(" unhooked ", 0);
(...skipping 24 matching lines...) Expand all
741 mmap_dump_buffer->AppendInt(deep_bucket->id, 0); 745 mmap_dump_buffer->AppendInt(deep_bucket->id, 0);
742 } else { 746 } else {
743 mmap_dump_buffer->AppendInt(0, 0); 747 mmap_dump_buffer->AppendInt(0, 0);
744 } 748 }
745 mmap_dump_buffer->AppendString("\n", 0); 749 mmap_dump_buffer->AppendString("\n", 0);
746 } 750 }
747 } while (mmap_iter != MemoryRegionMap::EndRegionLocked() && 751 } while (mmap_iter != MemoryRegionMap::EndRegionLocked() &&
748 mmap_iter->end_addr - 1 <= last_address); 752 mmap_iter->end_addr - 1 <= last_address);
749 } 753 }
750 } 754 }
755
756 // TODO(dmikurube): Investigate and fix http://crbug.com/189114.
757 //
758 // The total committed memory usage in all_ (from /proc/<pid>/maps) is
759 // sometimes smaller than the sum of the committed mmap'ed addresses and
760 // unhooked regions. Within our observation, the difference was only 4KB
761 // in committed usage, zero in reserved virtual addresses
762 //
763 // A guess is that an uncommitted (but reserved) page may become committed
764 // during counting memory usage in the loop above.
765 //
766 // The difference is accounted as "ABSENT" to investigate such cases.
767
768 RegionStats all_total;
769 RegionStats unhooked_total;
770 for (int i = 0; i < NUMBER_OF_MAPS_REGION_TYPES; ++i) {
771 all_total.AddAnotherRegionStat(all_[i]);
772 unhooked_total.AddAnotherRegionStat(unhooked_[i]);
773 }
774
775 size_t absent_virtual = profiled_mmap_.virtual_bytes() +
776 unhooked_total.virtual_bytes() -
777 all_total.virtual_bytes();
778 if (absent_virtual > 0)
779 all_[ABSENT].AddToVirtualBytes(absent_virtual);
780
781 size_t absent_committed = profiled_mmap_.committed_bytes() +
782 unhooked_total.committed_bytes() -
783 all_total.committed_bytes();
784 if (absent_committed > 0)
785 all_[ABSENT].AddToCommittedBytes(absent_committed);
751 } 786 }
752 787
753 void DeepHeapProfile::GlobalStats::SnapshotAllocations( 788 void DeepHeapProfile::GlobalStats::SnapshotAllocations(
754 DeepHeapProfile* deep_profile) { 789 DeepHeapProfile* deep_profile) {
755 profiled_malloc_.Initialize(); 790 profiled_malloc_.Initialize();
756 791
757 deep_profile->heap_profile_->address_map_->Iterate(RecordAlloc, deep_profile); 792 deep_profile->heap_profile_->address_map_->Iterate(RecordAlloc, deep_profile);
758 } 793 }
759 794
760 void DeepHeapProfile::GlobalStats::Unparse(TextBuffer* buffer) { 795 void DeepHeapProfile::GlobalStats::Unparse(TextBuffer* buffer) {
(...skipping 18 matching lines...) Expand all
779 buffer->AppendString(")\n", 0); 814 buffer->AppendString(")\n", 0);
780 815
781 // " virtual committed" 816 // " virtual committed"
782 buffer->AppendString("", 26); 817 buffer->AppendString("", 26);
783 buffer->AppendString(kVirtualLabel, 12); 818 buffer->AppendString(kVirtualLabel, 12);
784 buffer->AppendChar(' '); 819 buffer->AppendChar(' ');
785 buffer->AppendString(kCommittedLabel, 12); 820 buffer->AppendString(kCommittedLabel, 12);
786 buffer->AppendString("\n", 0); 821 buffer->AppendString("\n", 0);
787 822
788 all_total.Unparse("total", buffer); 823 all_total.Unparse("total", buffer);
824 all_[ABSENT].Unparse("absent", buffer);
789 all_[FILE_EXEC].Unparse("file-exec", buffer); 825 all_[FILE_EXEC].Unparse("file-exec", buffer);
790 all_[FILE_NONEXEC].Unparse("file-nonexec", buffer); 826 all_[FILE_NONEXEC].Unparse("file-nonexec", buffer);
791 all_[ANONYMOUS].Unparse("anonymous", buffer); 827 all_[ANONYMOUS].Unparse("anonymous", buffer);
792 all_[STACK].Unparse("stack", buffer); 828 all_[STACK].Unparse("stack", buffer);
793 all_[OTHER].Unparse("other", buffer); 829 all_[OTHER].Unparse("other", buffer);
794 unhooked_total.Unparse("nonprofiled-total", buffer); 830 unhooked_total.Unparse("nonprofiled-total", buffer);
795 unhooked_[ABSENT].Unparse("nonprofiled-absent", buffer); 831 unhooked_[ABSENT].Unparse("nonprofiled-absent", buffer);
796 unhooked_[ANONYMOUS].Unparse("nonprofiled-anonymous", buffer); 832 unhooked_[ANONYMOUS].Unparse("nonprofiled-anonymous", buffer);
797 unhooked_[FILE_EXEC].Unparse("nonprofiled-file-exec", buffer); 833 unhooked_[FILE_EXEC].Unparse("nonprofiled-file-exec", buffer);
798 unhooked_[FILE_NONEXEC].Unparse("nonprofiled-file-nonexec", buffer); 834 unhooked_[FILE_NONEXEC].Unparse("nonprofiled-file-nonexec", buffer);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 } 884 }
849 885
850 DeepHeapProfile::~DeepHeapProfile() { 886 DeepHeapProfile::~DeepHeapProfile() {
851 } 887 }
852 888
853 int DeepHeapProfile::FillOrderedProfile(char raw_buffer[], int buffer_size) { 889 int DeepHeapProfile::FillOrderedProfile(char raw_buffer[], int buffer_size) {
854 return heap_profile_->FillOrderedProfile(raw_buffer, buffer_size); 890 return heap_profile_->FillOrderedProfile(raw_buffer, buffer_size);
855 } 891 }
856 892
857 #endif // DEEP_HEAP_PROFILE 893 #endif // DEEP_HEAP_PROFILE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698