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

Side by Side Diff: Source/platform/PartitionAllocMemoryDumpProvider.cpp

Issue 1312843010: [tracing] Fix PartitionAlloc dumper reporting (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | Source/wtf/Partitions.cpp » ('j') | Source/wtf/Partitions.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "config.h" 5 #include "config.h"
6 #include "platform/PartitionAllocMemoryDumpProvider.h" 6 #include "platform/PartitionAllocMemoryDumpProvider.h"
7 7
8 #include "public/platform/WebMemoryAllocatorDump.h" 8 #include "public/platform/WebMemoryAllocatorDump.h"
9 #include "public/platform/WebProcessMemoryDump.h" 9 #include "public/platform/WebProcessMemoryDump.h"
10 #include "wtf/Partitions.h" 10 #include "wtf/Partitions.h"
11 #include "wtf/Threading.h" 11 #include "wtf/Threading.h"
ssid 2015/09/07 15:59:26 this can be removed now.
Primiano Tucci (use gerrit) 2015/09/08 07:56:56 Done.
12 12
13 namespace blink { 13 namespace blink {
14 14
15 namespace { 15 namespace {
16 16
17 using namespace WTF; 17 using namespace WTF;
18 18
19 const char kPartitionAllocDumpName[] = "partition_alloc";
20 const char kPartitionsDumpName[] = "partitions";
21
19 String getPartitionDumpName(const char* partitionName) 22 String getPartitionDumpName(const char* partitionName)
20 { 23 {
21 return String::format("partition_alloc/thread_%lu/%s", static_cast<unsigned long>(WTF::currentThread()), partitionName); 24 return String::format("%s/%s/%s", kPartitionAllocDumpName, kPartitionsDumpNa me, partitionName);
22 } 25 }
23 26
24 // This class is used to invert the dependency of PartitionAlloc on the 27 // This class is used to invert the dependency of PartitionAlloc on the
25 // PartitionAllocMemoryDumpProvider. This implements an interface that will 28 // PartitionAllocMemoryDumpProvider. This implements an interface that will
26 // be called with memory statistics for each bucket in the allocator. 29 // be called with memory statistics for each bucket in the allocator.
27 class PartitionStatsDumperImpl final : public PartitionStatsDumper { 30 class PartitionStatsDumperImpl final : public PartitionStatsDumper {
28 public: 31 public:
29 PartitionStatsDumperImpl(WebProcessMemoryDump* memoryDump, WebMemoryDumpLeve lOfDetail levelOfDetail) 32 PartitionStatsDumperImpl(WebProcessMemoryDump* memoryDump, WebMemoryDumpLeve lOfDetail levelOfDetail)
30 : m_memoryDump(memoryDump) 33 : m_memoryDump(memoryDump)
31 , m_levelOfDetail(levelOfDetail) 34 , m_uid(0)
32 , m_uid(0) { } 35 , m_totalActiveBytes(0) { }
33 36
34 // PartitionStatsDumper implementation. 37 // PartitionStatsDumper implementation.
35 void partitionDumpTotals(const char* partitionName, const PartitionMemorySta ts*) override; 38 void partitionDumpTotals(const char* partitionName, const PartitionMemorySta ts*) override;
36 void partitionsDumpBucketStats(const char* partitionName, const PartitionBuc ketMemoryStats*) override; 39 void partitionsDumpBucketStats(const char* partitionName, const PartitionBuc ketMemoryStats*) override;
37 40
41 const size_t totalActiveBytes() const { return m_totalActiveBytes; }
42
38 private: 43 private:
39 WebProcessMemoryDump* m_memoryDump; 44 WebProcessMemoryDump* m_memoryDump;
40 WebMemoryDumpLevelOfDetail m_levelOfDetail; 45 unsigned long m_uid;
41 size_t m_uid; 46 size_t m_totalActiveBytes;
42 }; 47 };
43 48
44 void PartitionStatsDumperImpl::partitionDumpTotals(const char* partitionName, co nst PartitionMemoryStats* memoryStats) 49 void PartitionStatsDumperImpl::partitionDumpTotals(const char* partitionName, co nst PartitionMemoryStats* memoryStats)
45 { 50 {
51 m_totalActiveBytes += memoryStats->totalActiveBytes;
46 String dumpName = getPartitionDumpName(partitionName); 52 String dumpName = getPartitionDumpName(partitionName);
47 WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorD ump(dumpName); 53 WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorD ump(dumpName);
48 allocatorDump->AddScalar("size", "bytes", memoryStats->totalMmappedBytes); 54 allocatorDump->AddScalar("size", "bytes", memoryStats->totalResidentBytes);
haraken 2015/09/07 23:24:26 Sorry for repeating the discussion again: Do we re
Primiano Tucci (use gerrit) 2015/09/08 07:56:56 No worries, better to spend time to make sure we m
haraken 2015/09/08 08:07:33 When PA commits 1 MB of system pages but doesn't y
Primiano Tucci (use gerrit) 2015/09/08 10:22:28 Let me check if I am getting this right. You are t
49 allocatorDump->AddScalar("committed_size", "bytes", memoryStats->totalCommit tedBytes); 55 allocatorDump->AddScalar("allocated_objects_size", "bytes", memoryStats->tot alActiveBytes);
50 allocatorDump->AddScalar("active_size", "bytes", memoryStats->totalActiveByt es); 56 allocatorDump->AddScalar("virtual_size", "bytes", memoryStats->totalMmappedB ytes);
51 allocatorDump->AddScalar("resident_size", "bytes", memoryStats->totalResiden tBytes); 57 allocatorDump->AddScalar("virtual_committed_size", "bytes", memoryStats->tot alCommittedBytes);
52 allocatorDump->AddScalar("decommittable_size", "bytes", memoryStats->totalDe committableBytes); 58 allocatorDump->AddScalar("decommittable_size", "bytes", memoryStats->totalDe committableBytes);
53 allocatorDump->AddScalar("discardable_size", "bytes", memoryStats->totalDisc ardableBytes); 59 allocatorDump->AddScalar("freeable_size", "bytes", memoryStats->totalDiscard ableBytes);
haraken 2015/09/07 23:24:26 Keep "discardable". We consistently use "discardab
Primiano Tucci (use gerrit) 2015/09/08 07:56:56 Hmm ok reverted. I just fear that it might be conf
54
55 // If detailed dumps, allocated_objects size will be aggregated from the
56 // children.
57 if (m_levelOfDetail == WebMemoryDumpLevelOfDetail::High)
58 return;
59
60 dumpName = dumpName + "/allocated_objects";
61 WebMemoryAllocatorDump* objectsDump = m_memoryDump->createMemoryAllocatorDum p(dumpName);
62 objectsDump->AddScalar("size", "bytes", memoryStats->totalActiveBytes);
63 } 60 }
64 61
65 void PartitionStatsDumperImpl::partitionsDumpBucketStats(const char* partitionNa me, const PartitionBucketMemoryStats* memoryStats) 62 void PartitionStatsDumperImpl::partitionsDumpBucketStats(const char* partitionNa me, const PartitionBucketMemoryStats* memoryStats)
66 { 63 {
67 ASSERT(memoryStats->isValid); 64 ASSERT(memoryStats->isValid);
68 String dumpName = getPartitionDumpName(partitionName); 65 String dumpName = getPartitionDumpName(partitionName);
69 if (memoryStats->isDirectMap) 66 if (memoryStats->isDirectMap)
70 dumpName.append(String::format("/directMap_%lu", static_cast<unsigned lo ng>(++m_uid))); 67 dumpName.append(String::format("/directMap_%lu", ++m_uid));
71 else 68 else
72 dumpName.append(String::format("/bucket_%u", static_cast<unsigned>(memor yStats->bucketSlotSize))); 69 dumpName.append(String::format("/bucket_%u", static_cast<unsigned>(memor yStats->bucketSlotSize)));
73 70
74 WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorD ump(dumpName); 71 WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorD ump(dumpName);
75 allocatorDump->AddScalar("size", "bytes", memoryStats->residentBytes); 72 allocatorDump->AddScalar("size", "bytes", memoryStats->residentBytes);
73 allocatorDump->AddScalar("allocated_objects_size", "bytes", memoryStats->act iveBytes);
76 allocatorDump->AddScalar("slot_size", "bytes", memoryStats->bucketSlotSize); 74 allocatorDump->AddScalar("slot_size", "bytes", memoryStats->bucketSlotSize);
77 allocatorDump->AddScalar("active_size", "bytes", memoryStats->activeBytes);
78 allocatorDump->AddScalar("resident_size", "bytes", memoryStats->residentByte s);
79 allocatorDump->AddScalar("decommittable_size", "bytes", memoryStats->decommi ttableBytes); 75 allocatorDump->AddScalar("decommittable_size", "bytes", memoryStats->decommi ttableBytes);
80 allocatorDump->AddScalar("discardable_size", "bytes", memoryStats->discardab leBytes); 76 allocatorDump->AddScalar("freeable_size", "bytes", memoryStats->discardableB ytes);
81 allocatorDump->AddScalar("num_active", "objects", memoryStats->numActivePage s); 77 allocatorDump->AddScalar("total_pages_size", "bytes", memoryStats->allocated PageSize);
82 allocatorDump->AddScalar("num_full", "objects", memoryStats->numFullPages); 78 allocatorDump->AddScalar("active_pages", "objects", memoryStats->numActivePa ges);
83 allocatorDump->AddScalar("num_empty", "objects", memoryStats->numEmptyPages) ; 79 allocatorDump->AddScalar("full_pages", "objects", memoryStats->numFullPages) ;
84 allocatorDump->AddScalar("num_decommitted", "objects", memoryStats->numDecom mittedPages); 80 allocatorDump->AddScalar("empty_pages", "objects", memoryStats->numEmptyPage s);
85 allocatorDump->AddScalar("page_size", "bytes", memoryStats->allocatedPageSiz e); 81 allocatorDump->AddScalar("decommitted_pages", "objects", memoryStats->numDec ommittedPages);
86
87 dumpName = dumpName + "/allocated_objects";
88 WebMemoryAllocatorDump* objectsDump = m_memoryDump->createMemoryAllocatorDum p(dumpName);
89 objectsDump->AddScalar("size", "bytes", memoryStats->activeBytes);
90 } 82 }
91 83
92 } // namespace 84 } // namespace
93 85
94 PartitionAllocMemoryDumpProvider* PartitionAllocMemoryDumpProvider::instance() 86 PartitionAllocMemoryDumpProvider* PartitionAllocMemoryDumpProvider::instance()
95 { 87 {
96 DEFINE_STATIC_LOCAL(PartitionAllocMemoryDumpProvider, instance, ()); 88 DEFINE_STATIC_LOCAL(PartitionAllocMemoryDumpProvider, instance, ());
97 return &instance; 89 return &instance;
98 } 90 }
99 91
100 bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail l evelOfDetail, blink::WebProcessMemoryDump* memoryDump) 92 bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail l evelOfDetail, WebProcessMemoryDump* memoryDump)
101 { 93 {
102 PartitionStatsDumperImpl partitionStatsDumper(memoryDump, levelOfDetail); 94 PartitionStatsDumperImpl partitionStatsDumper(memoryDump, levelOfDetail);
103 95
96 WebMemoryAllocatorDump* partitionsDump = memoryDump->createMemoryAllocatorDu mp(
97 String::format("%s/%s", kPartitionAllocDumpName, kPartitionsDumpName));
98
104 // This method calls memoryStats.partitionsDumpBucketStats with memory stati stics. 99 // This method calls memoryStats.partitionsDumpBucketStats with memory stati stics.
105 WTF::Partitions::dumpMemoryStats(levelOfDetail == WebMemoryDumpLevelOfDetail ::Low, &partitionStatsDumper); 100 WTF::Partitions::dumpMemoryStats(levelOfDetail == WebMemoryDumpLevelOfDetail ::Low, &partitionStatsDumper);
101
102 WebMemoryAllocatorDump* allocatedObjectsDump = memoryDump->createMemoryAlloc atorDump(
103 String::format("%s/allocated_objects", kPartitionAllocDumpName));
ssid 2015/09/07 14:48:21 Just wondering if the format is right here (12 spa
Primiano Tucci (use gerrit) 2015/09/07 15:23:20 Looking at other files (and git cl format) this se
104 allocatedObjectsDump->AddScalar("size", "bytes", partitionStatsDumper.totalA ctiveBytes());
105 memoryDump->AddOwnershipEdge(allocatedObjectsDump->guid(), partitionsDump->g uid());
106
106 return true; 107 return true;
107 } 108 }
108 109
109 PartitionAllocMemoryDumpProvider::PartitionAllocMemoryDumpProvider() 110 PartitionAllocMemoryDumpProvider::PartitionAllocMemoryDumpProvider()
110 { 111 {
111 } 112 }
112 113
113 PartitionAllocMemoryDumpProvider::~PartitionAllocMemoryDumpProvider() 114 PartitionAllocMemoryDumpProvider::~PartitionAllocMemoryDumpProvider()
114 { 115 {
115 } 116 }
116 117
117 } // namespace blink 118 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/wtf/Partitions.cpp » ('j') | Source/wtf/Partitions.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698