Commit a1cdff5e authored by primiano@chromium.org's avatar primiano@chromium.org

[tracing] Fix PartitionAlloc dumper reporting

- Fix virtual vs resident size reporting in the "size" column:
  Prior to this change the PartitionAlloc dumper was reporting the
  mmap-ed (virtual address spave) size in the "size" column.
  This is inconsistent with the rest of the dumpers, which strive
  to report an estimation of actually resident memory in the "size"
  column.
  This change moves the PA resident size into "size".   
- Remove the "thread_1234" sub-node: turns out that there can be at
  most one PartitionAlloc instance per-process, even in single-process
  mode.
- Improve reporting of allocated_objects:
  - Each bucket gets a column "allocated_objects_size", previously 
    called "active_size" (confusing), which reports the size of bytes
    requested by PA clients.
  - The per-bucket "allocated_objects" sub-rows are removed: they just
    added visual clutter and didn't add any extra information than an
    extra column.
  - A global allocated_objects node is introduced. This will be required
    by subsequent CLs to properly account memory reporter by other pieces
    of blink. This will be to avoid that WebCache memory that is 
    allocated via PA gets double-counted in the effective_size.
- Improve other column names for sake of clarity:
   - committed -> virtual_committed
   - num_{active,full,...} -> {active,full,...}_pages. The previous name
     didn't make it clear that they count pages and not objects.

BUG=488472

Review URL: https://codereview.chromium.org/1312843010

git-svn-id: svn://svn.chromium.org/blink/trunk@201972 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 10eeb774
......@@ -8,7 +8,6 @@
#include "public/platform/WebMemoryAllocatorDump.h"
#include "public/platform/WebProcessMemoryDump.h"
#include "wtf/Partitions.h"
#include "wtf/Threading.h"
namespace blink {
......@@ -16,9 +15,12 @@ namespace {
using namespace WTF;
const char kPartitionAllocDumpName[] = "partition_alloc";
const char kPartitionsDumpName[] = "partitions";
String getPartitionDumpName(const char* partitionName)
{
return String::format("partition_alloc/thread_%lu/%s", static_cast<unsigned long>(WTF::currentThread()), partitionName);
return String::format("%s/%s/%s", kPartitionAllocDumpName, kPartitionsDumpName, partitionName);
}
// This class is used to invert the dependency of PartitionAlloc on the
......@@ -28,38 +30,34 @@ class PartitionStatsDumperImpl final : public PartitionStatsDumper {
public:
PartitionStatsDumperImpl(WebProcessMemoryDump* memoryDump, WebMemoryDumpLevelOfDetail levelOfDetail)
: m_memoryDump(memoryDump)
, m_levelOfDetail(levelOfDetail)
, m_uid(0) { }
, m_uid(0)
, m_totalActiveBytes(0)
{
}
// PartitionStatsDumper implementation.
void partitionDumpTotals(const char* partitionName, const PartitionMemoryStats*) override;
void partitionsDumpBucketStats(const char* partitionName, const PartitionBucketMemoryStats*) override;
size_t totalActiveBytes() const { return m_totalActiveBytes; }
private:
WebProcessMemoryDump* m_memoryDump;
WebMemoryDumpLevelOfDetail m_levelOfDetail;
size_t m_uid;
unsigned long m_uid;
size_t m_totalActiveBytes;
};
void PartitionStatsDumperImpl::partitionDumpTotals(const char* partitionName, const PartitionMemoryStats* memoryStats)
{
m_totalActiveBytes += memoryStats->totalActiveBytes;
String dumpName = getPartitionDumpName(partitionName);
WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorDump(dumpName);
allocatorDump->AddScalar("size", "bytes", memoryStats->totalMmappedBytes);
allocatorDump->AddScalar("committed_size", "bytes", memoryStats->totalCommittedBytes);
allocatorDump->AddScalar("active_size", "bytes", memoryStats->totalActiveBytes);
allocatorDump->AddScalar("resident_size", "bytes", memoryStats->totalResidentBytes);
allocatorDump->AddScalar("size", "bytes", memoryStats->totalResidentBytes);
allocatorDump->AddScalar("allocated_objects_size", "bytes", memoryStats->totalActiveBytes);
allocatorDump->AddScalar("virtual_size", "bytes", memoryStats->totalMmappedBytes);
allocatorDump->AddScalar("virtual_committed_size", "bytes", memoryStats->totalCommittedBytes);
allocatorDump->AddScalar("decommittable_size", "bytes", memoryStats->totalDecommittableBytes);
allocatorDump->AddScalar("discardable_size", "bytes", memoryStats->totalDiscardableBytes);
// If detailed dumps, allocated_objects size will be aggregated from the
// children.
if (m_levelOfDetail == WebMemoryDumpLevelOfDetail::High)
return;
dumpName = dumpName + "/allocated_objects";
WebMemoryAllocatorDump* objectsDump = m_memoryDump->createMemoryAllocatorDump(dumpName);
objectsDump->AddScalar("size", "bytes", memoryStats->totalActiveBytes);
}
void PartitionStatsDumperImpl::partitionsDumpBucketStats(const char* partitionName, const PartitionBucketMemoryStats* memoryStats)
......@@ -67,26 +65,21 @@ void PartitionStatsDumperImpl::partitionsDumpBucketStats(const char* partitionNa
ASSERT(memoryStats->isValid);
String dumpName = getPartitionDumpName(partitionName);
if (memoryStats->isDirectMap)
dumpName.append(String::format("/directMap_%lu", static_cast<unsigned long>(++m_uid)));
dumpName.append(String::format("/directMap_%lu", ++m_uid));
else
dumpName.append(String::format("/bucket_%u", static_cast<unsigned>(memoryStats->bucketSlotSize)));
WebMemoryAllocatorDump* allocatorDump = m_memoryDump->createMemoryAllocatorDump(dumpName);
allocatorDump->AddScalar("size", "bytes", memoryStats->residentBytes);
allocatorDump->AddScalar("allocated_objects_size", "bytes", memoryStats->activeBytes);
allocatorDump->AddScalar("slot_size", "bytes", memoryStats->bucketSlotSize);
allocatorDump->AddScalar("active_size", "bytes", memoryStats->activeBytes);
allocatorDump->AddScalar("resident_size", "bytes", memoryStats->residentBytes);
allocatorDump->AddScalar("decommittable_size", "bytes", memoryStats->decommittableBytes);
allocatorDump->AddScalar("discardable_size", "bytes", memoryStats->discardableBytes);
allocatorDump->AddScalar("num_active", "objects", memoryStats->numActivePages);
allocatorDump->AddScalar("num_full", "objects", memoryStats->numFullPages);
allocatorDump->AddScalar("num_empty", "objects", memoryStats->numEmptyPages);
allocatorDump->AddScalar("num_decommitted", "objects", memoryStats->numDecommittedPages);
allocatorDump->AddScalar("page_size", "bytes", memoryStats->allocatedPageSize);
dumpName = dumpName + "/allocated_objects";
WebMemoryAllocatorDump* objectsDump = m_memoryDump->createMemoryAllocatorDump(dumpName);
objectsDump->AddScalar("size", "bytes", memoryStats->activeBytes);
allocatorDump->AddScalar("total_pages_size", "bytes", memoryStats->allocatedPageSize);
allocatorDump->AddScalar("active_pages", "objects", memoryStats->numActivePages);
allocatorDump->AddScalar("full_pages", "objects", memoryStats->numFullPages);
allocatorDump->AddScalar("empty_pages", "objects", memoryStats->numEmptyPages);
allocatorDump->AddScalar("decommitted_pages", "objects", memoryStats->numDecommittedPages);
}
} // namespace
......@@ -97,12 +90,21 @@ PartitionAllocMemoryDumpProvider* PartitionAllocMemoryDumpProvider::instance()
return &instance;
}
bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, blink::WebProcessMemoryDump* memoryDump)
bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcessMemoryDump* memoryDump)
{
PartitionStatsDumperImpl partitionStatsDumper(memoryDump, levelOfDetail);
WebMemoryAllocatorDump* partitionsDump = memoryDump->createMemoryAllocatorDump(
String::format("%s/%s", kPartitionAllocDumpName, kPartitionsDumpName));
// This method calls memoryStats.partitionsDumpBucketStats with memory statistics.
WTF::Partitions::dumpMemoryStats(levelOfDetail == WebMemoryDumpLevelOfDetail::Low, &partitionStatsDumper);
WebMemoryAllocatorDump* allocatedObjectsDump = memoryDump->createMemoryAllocatorDump(
String::format("%s/allocated_objects", kPartitionAllocDumpName));
allocatedObjectsDump->AddScalar("size", "bytes", partitionStatsDumper.totalActiveBytes());
memoryDump->AddOwnershipEdge(allocatedObjectsDump->guid(), partitionsDump->guid());
return true;
}
......
......@@ -118,10 +118,10 @@ void Partitions::dumpMemoryStats(bool isLightDump, PartitionStatsDumper* partiti
// accessed only on the main thread.
ASSERT(isMainThread());
partitionDumpStatsGeneric(fastMallocPartition(), "fast_malloc_partition", isLightDump, partitionStatsDumper);
partitionDumpStatsGeneric(bufferPartition(), "buffer_partition", isLightDump, partitionStatsDumper);
partitionDumpStats(nodePartition(), "node_partition", isLightDump, partitionStatsDumper);
partitionDumpStats(layoutPartition(), "layout_partition", isLightDump, partitionStatsDumper);
partitionDumpStatsGeneric(fastMallocPartition(), "fast_malloc", isLightDump, partitionStatsDumper);
partitionDumpStatsGeneric(bufferPartition(), "buffer", isLightDump, partitionStatsDumper);
partitionDumpStats(nodePartition(), "node", isLightDump, partitionStatsDumper);
partitionDumpStats(layoutPartition(), "layout", isLightDump, partitionStatsDumper);
}
static NEVER_INLINE void partitionsOutOfMemoryUsing2G()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment