| OLD | NEW |
| 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 "Source/platform/PartitionAllocMemoryDumpProvider.h" | 6 #include "Source/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 | 12 |
| 12 namespace blink { | 13 namespace blink { |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 using namespace WTF; | 17 using namespace WTF; |
| 17 | 18 |
| 18 // This class is used to invert the dependency of PartitionAlloc on the | 19 // This class is used to invert the dependency of PartitionAlloc on the |
| 19 // PartitionAllocMemoryDumpProvider. This implements an interface that will | 20 // PartitionAllocMemoryDumpProvider. This implements an interface that will |
| 20 // be called with memory statistics for each bucket in the allocator. | 21 // be called with memory statistics for each bucket in the allocator. |
| 21 class PartitionStatsDumperImpl final : public PartitionStatsDumper { | 22 class PartitionStatsDumperImpl final : public PartitionStatsDumper { |
| 22 public: | 23 public: |
| 23 explicit PartitionStatsDumperImpl(WebProcessMemoryDump* memoryDump) | 24 explicit PartitionStatsDumperImpl(WebProcessMemoryDump* memoryDump) |
| 24 : m_memoryDump(memoryDump), m_uid(0) { } | 25 : m_memoryDump(memoryDump), m_uid(0) { } |
| 25 | 26 |
| 26 // PartitionStatsDumper implementation. | 27 // PartitionStatsDumper implementation. |
| 27 void partitionsDumpBucketStats(const char* partitionName, const PartitionBuc
ketMemoryStats*) override; | 28 void partitionsDumpBucketStats(const char* partitionName, const PartitionBuc
ketMemoryStats*) override; |
| 28 | 29 |
| 29 private: | 30 private: |
| 30 WebProcessMemoryDump* m_memoryDump; | 31 WebProcessMemoryDump* m_memoryDump; |
| 31 size_t m_uid; | 32 size_t m_uid; |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 void PartitionStatsDumperImpl::partitionsDumpBucketStats(const char* partitionNa
me, const PartitionBucketMemoryStats* memoryStats) | 35 void PartitionStatsDumperImpl::partitionsDumpBucketStats(const char* partitionNa
me, const PartitionBucketMemoryStats* memoryStats) |
| 35 { | 36 { |
| 36 ASSERT(memoryStats->isValid); | 37 ASSERT(memoryStats->isValid); |
| 37 String dumpName; | 38 String dumpName; |
| 38 if (memoryStats->isDirectMap) | 39 if (memoryStats->isDirectMap) |
| 39 dumpName = String::format("partition_alloc/%s/directMap_%zu", partitionN
ame, ++m_uid); | 40 dumpName = String::format("partition_alloc/thread_%lu/%s/directMap_%lu",
static_cast<unsigned long>(WTF::currentThread()), partitionName, static_cast<un
signed long>(++m_uid)); |
| 40 else | 41 else |
| 41 dumpName = String::format("partition_alloc/%s/bucket_%zu", partitionName
, static_cast<size_t>(memoryStats->bucketSlotSize)); | 42 dumpName = String::format("partition_alloc/thread_%lu/%s/bucket_%u", sta
tic_cast<unsigned long>(WTF::currentThread()), partitionName, static_cast<unsign
ed>(memoryStats->bucketSlotSize)); |
| 42 | 43 |
| 43 WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorD
ump(dumpName); | 44 WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorD
ump(dumpName); |
| 44 allocatorDump->AddScalar("size", "bytes", memoryStats->residentBytes); | 45 allocatorDump->AddScalar("size", "bytes", memoryStats->residentBytes); |
| 45 allocatorDump->AddScalar("slot_size", "bytes", memoryStats->bucketSlotSize); | 46 allocatorDump->AddScalar("slot_size", "bytes", memoryStats->bucketSlotSize); |
| 46 allocatorDump->AddScalar("active_size", "bytes", memoryStats->activeBytes); | 47 allocatorDump->AddScalar("active_size", "bytes", memoryStats->activeBytes); |
| 47 allocatorDump->AddScalar("resident_size", "bytes", memoryStats->residentByte
s); | 48 allocatorDump->AddScalar("resident_size", "bytes", memoryStats->residentByte
s); |
| 48 allocatorDump->AddScalar("decommittable_size", "bytes", memoryStats->decommi
ttableBytes); | 49 allocatorDump->AddScalar("decommittable_size", "bytes", memoryStats->decommi
ttableBytes); |
| 49 allocatorDump->AddScalar("discardable_size", "bytes", memoryStats->discardab
leBytes); | 50 allocatorDump->AddScalar("discardable_size", "bytes", memoryStats->discardab
leBytes); |
| 50 allocatorDump->AddScalar("num_active", "objects", memoryStats->numActivePage
s); | 51 allocatorDump->AddScalar("num_active", "objects", memoryStats->numActivePage
s); |
| 51 allocatorDump->AddScalar("num_full", "objects", memoryStats->numFullPages); | 52 allocatorDump->AddScalar("num_full", "objects", memoryStats->numFullPages); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 77 | 78 |
| 78 PartitionAllocMemoryDumpProvider::PartitionAllocMemoryDumpProvider() | 79 PartitionAllocMemoryDumpProvider::PartitionAllocMemoryDumpProvider() |
| 79 { | 80 { |
| 80 } | 81 } |
| 81 | 82 |
| 82 PartitionAllocMemoryDumpProvider::~PartitionAllocMemoryDumpProvider() | 83 PartitionAllocMemoryDumpProvider::~PartitionAllocMemoryDumpProvider() |
| 83 { | 84 { |
| 84 } | 85 } |
| 85 | 86 |
| 86 } // namespace blink | 87 } // namespace blink |
| OLD | NEW |