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

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: const size_t ... meh 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') | no next file with comments »
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"
12 11
13 namespace blink { 12 namespace blink {
14 13
15 namespace { 14 namespace {
16 15
17 using namespace WTF; 16 using namespace WTF;
18 17
18 const char kPartitionAllocDumpName[] = "partition_alloc";
19 const char kPartitionsDumpName[] = "partitions";
20
19 String getPartitionDumpName(const char* partitionName) 21 String getPartitionDumpName(const char* partitionName)
20 { 22 {
21 return String::format("partition_alloc/thread_%lu/%s", static_cast<unsigned long>(WTF::currentThread()), partitionName); 23 return String::format("%s/%s/%s", kPartitionAllocDumpName, kPartitionsDumpNa me, partitionName);
22 } 24 }
23 25
24 // This class is used to invert the dependency of PartitionAlloc on the 26 // This class is used to invert the dependency of PartitionAlloc on the
25 // PartitionAllocMemoryDumpProvider. This implements an interface that will 27 // PartitionAllocMemoryDumpProvider. This implements an interface that will
26 // be called with memory statistics for each bucket in the allocator. 28 // be called with memory statistics for each bucket in the allocator.
27 class PartitionStatsDumperImpl final : public PartitionStatsDumper { 29 class PartitionStatsDumperImpl final : public PartitionStatsDumper {
28 public: 30 public:
29 PartitionStatsDumperImpl(WebProcessMemoryDump* memoryDump, WebMemoryDumpLeve lOfDetail levelOfDetail) 31 PartitionStatsDumperImpl(WebProcessMemoryDump* memoryDump, WebMemoryDumpLeve lOfDetail levelOfDetail)
30 : m_memoryDump(memoryDump) 32 : m_memoryDump(memoryDump)
31 , m_levelOfDetail(levelOfDetail) 33 , m_uid(0)
32 , m_uid(0) { } 34 , m_totalActiveBytes(0)
35 {
36 }
33 37
34 // PartitionStatsDumper implementation. 38 // PartitionStatsDumper implementation.
35 void partitionDumpTotals(const char* partitionName, const PartitionMemorySta ts*) override; 39 void partitionDumpTotals(const char* partitionName, const PartitionMemorySta ts*) override;
36 void partitionsDumpBucketStats(const char* partitionName, const PartitionBuc ketMemoryStats*) override; 40 void partitionsDumpBucketStats(const char* partitionName, const PartitionBuc ketMemoryStats*) override;
37 41
42 size_t totalActiveBytes() const { return m_totalActiveBytes; }
43
38 private: 44 private:
39 WebProcessMemoryDump* m_memoryDump; 45 WebProcessMemoryDump* m_memoryDump;
40 WebMemoryDumpLevelOfDetail m_levelOfDetail; 46 unsigned long m_uid;
41 size_t m_uid; 47 size_t m_totalActiveBytes;
42 }; 48 };
43 49
44 void PartitionStatsDumperImpl::partitionDumpTotals(const char* partitionName, co nst PartitionMemoryStats* memoryStats) 50 void PartitionStatsDumperImpl::partitionDumpTotals(const char* partitionName, co nst PartitionMemoryStats* memoryStats)
45 { 51 {
52 m_totalActiveBytes += memoryStats->totalActiveBytes;
46 String dumpName = getPartitionDumpName(partitionName); 53 String dumpName = getPartitionDumpName(partitionName);
47 WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorD ump(dumpName); 54 WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorD ump(dumpName);
48 allocatorDump->AddScalar("size", "bytes", memoryStats->totalMmappedBytes); 55 allocatorDump->AddScalar("size", "bytes", memoryStats->totalResidentBytes);
49 allocatorDump->AddScalar("committed_size", "bytes", memoryStats->totalCommit tedBytes); 56 allocatorDump->AddScalar("allocated_objects_size", "bytes", memoryStats->tot alActiveBytes);
50 allocatorDump->AddScalar("active_size", "bytes", memoryStats->totalActiveByt es); 57 allocatorDump->AddScalar("virtual_size", "bytes", memoryStats->totalMmappedB ytes);
51 allocatorDump->AddScalar("resident_size", "bytes", memoryStats->totalResiden tBytes); 58 allocatorDump->AddScalar("virtual_committed_size", "bytes", memoryStats->tot alCommittedBytes);
52 allocatorDump->AddScalar("decommittable_size", "bytes", memoryStats->totalDe committableBytes); 59 allocatorDump->AddScalar("decommittable_size", "bytes", memoryStats->totalDe committableBytes);
53 allocatorDump->AddScalar("discardable_size", "bytes", memoryStats->totalDisc ardableBytes); 60 allocatorDump->AddScalar("discardable_size", "bytes", memoryStats->totalDisc ardableBytes);
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 } 61 }
64 62
65 void PartitionStatsDumperImpl::partitionsDumpBucketStats(const char* partitionNa me, const PartitionBucketMemoryStats* memoryStats) 63 void PartitionStatsDumperImpl::partitionsDumpBucketStats(const char* partitionNa me, const PartitionBucketMemoryStats* memoryStats)
66 { 64 {
67 ASSERT(memoryStats->isValid); 65 ASSERT(memoryStats->isValid);
68 String dumpName = getPartitionDumpName(partitionName); 66 String dumpName = getPartitionDumpName(partitionName);
69 if (memoryStats->isDirectMap) 67 if (memoryStats->isDirectMap)
70 dumpName.append(String::format("/directMap_%lu", static_cast<unsigned lo ng>(++m_uid))); 68 dumpName.append(String::format("/directMap_%lu", ++m_uid));
71 else 69 else
72 dumpName.append(String::format("/bucket_%u", static_cast<unsigned>(memor yStats->bucketSlotSize))); 70 dumpName.append(String::format("/bucket_%u", static_cast<unsigned>(memor yStats->bucketSlotSize)));
73 71
74 WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorD ump(dumpName); 72 WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorD ump(dumpName);
75 allocatorDump->AddScalar("size", "bytes", memoryStats->residentBytes); 73 allocatorDump->AddScalar("size", "bytes", memoryStats->residentBytes);
74 allocatorDump->AddScalar("allocated_objects_size", "bytes", memoryStats->act iveBytes);
76 allocatorDump->AddScalar("slot_size", "bytes", memoryStats->bucketSlotSize); 75 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); 76 allocatorDump->AddScalar("decommittable_size", "bytes", memoryStats->decommi ttableBytes);
80 allocatorDump->AddScalar("discardable_size", "bytes", memoryStats->discardab leBytes); 77 allocatorDump->AddScalar("discardable_size", "bytes", memoryStats->discardab leBytes);
81 allocatorDump->AddScalar("num_active", "objects", memoryStats->numActivePage s); 78 allocatorDump->AddScalar("total_pages_size", "bytes", memoryStats->allocated PageSize);
82 allocatorDump->AddScalar("num_full", "objects", memoryStats->numFullPages); 79 allocatorDump->AddScalar("active_pages", "objects", memoryStats->numActivePa ges);
83 allocatorDump->AddScalar("num_empty", "objects", memoryStats->numEmptyPages) ; 80 allocatorDump->AddScalar("full_pages", "objects", memoryStats->numFullPages) ;
84 allocatorDump->AddScalar("num_decommitted", "objects", memoryStats->numDecom mittedPages); 81 allocatorDump->AddScalar("empty_pages", "objects", memoryStats->numEmptyPage s);
85 allocatorDump->AddScalar("page_size", "bytes", memoryStats->allocatedPageSiz e); 82 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 } 83 }
91 84
92 } // namespace 85 } // namespace
93 86
94 PartitionAllocMemoryDumpProvider* PartitionAllocMemoryDumpProvider::instance() 87 PartitionAllocMemoryDumpProvider* PartitionAllocMemoryDumpProvider::instance()
95 { 88 {
96 DEFINE_STATIC_LOCAL(PartitionAllocMemoryDumpProvider, instance, ()); 89 DEFINE_STATIC_LOCAL(PartitionAllocMemoryDumpProvider, instance, ());
97 return &instance; 90 return &instance;
98 } 91 }
99 92
100 bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail l evelOfDetail, blink::WebProcessMemoryDump* memoryDump) 93 bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail l evelOfDetail, WebProcessMemoryDump* memoryDump)
101 { 94 {
102 PartitionStatsDumperImpl partitionStatsDumper(memoryDump, levelOfDetail); 95 PartitionStatsDumperImpl partitionStatsDumper(memoryDump, levelOfDetail);
103 96
97 WebMemoryAllocatorDump* partitionsDump = memoryDump->createMemoryAllocatorDu mp(
98 String::format("%s/%s", kPartitionAllocDumpName, kPartitionsDumpName));
99
104 // This method calls memoryStats.partitionsDumpBucketStats with memory stati stics. 100 // This method calls memoryStats.partitionsDumpBucketStats with memory stati stics.
105 WTF::Partitions::dumpMemoryStats(levelOfDetail == WebMemoryDumpLevelOfDetail ::Low, &partitionStatsDumper); 101 WTF::Partitions::dumpMemoryStats(levelOfDetail == WebMemoryDumpLevelOfDetail ::Low, &partitionStatsDumper);
102
103 WebMemoryAllocatorDump* allocatedObjectsDump = memoryDump->createMemoryAlloc atorDump(
104 String::format("%s/allocated_objects", kPartitionAllocDumpName));
105 allocatedObjectsDump->AddScalar("size", "bytes", partitionStatsDumper.totalA ctiveBytes());
106 memoryDump->AddOwnershipEdge(allocatedObjectsDump->guid(), partitionsDump->g uid());
107
106 return true; 108 return true;
107 } 109 }
108 110
109 PartitionAllocMemoryDumpProvider::PartitionAllocMemoryDumpProvider() 111 PartitionAllocMemoryDumpProvider::PartitionAllocMemoryDumpProvider()
110 { 112 {
111 } 113 }
112 114
113 PartitionAllocMemoryDumpProvider::~PartitionAllocMemoryDumpProvider() 115 PartitionAllocMemoryDumpProvider::~PartitionAllocMemoryDumpProvider()
114 { 116 {
115 } 117 }
116 118
117 } // namespace blink 119 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/wtf/Partitions.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698