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

Unified Diff: Source/platform/heap/Heap.cpp

Issue 1203493004: [tracing] Adding class-wise memory statistics to blink gc memory dumps (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | Source/platform/heap/ThreadState.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Heap.cpp
diff --git a/Source/platform/heap/Heap.cpp b/Source/platform/heap/Heap.cpp
index 77edb3bf7afa908f3e56529d1346c997e9afd1d1..181fe881aff02c5b41691d05fc0ecc19f05b123e 100644
--- a/Source/platform/heap/Heap.cpp
+++ b/Source/platform/heap/Heap.cpp
@@ -259,14 +259,15 @@ void BaseHeap::cleanupPages()
m_firstPage = nullptr;
}
-void BaseHeap::takeSnapshot(const String& dumpBaseName)
+void BaseHeap::takeSnapshot(const String& dumpBaseName, ThreadState::GCSnapshotInfo& info)
{
- size_t pageCount = 0;
+ WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(dumpBaseName);
+ size_t pageIndex = 0;
for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) {
- pageCount++;
+ page->takeSnapshot(dumpBaseName, pageIndex, info);
+ pageIndex++;
}
- WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(dumpBaseName);
- allocatorDump->AddScalar("blink_page_count", "objects", pageCount);
+ allocatorDump->AddScalar("blink_page_count", "objects", pageIndex);
}
#if ENABLE(ASSERT) || ENABLE(GC_PROFILING)
@@ -568,6 +569,11 @@ bool NormalPageHeap::pagesToBeSweptContains(Address address)
}
#endif
+void NormalPageHeap::takeFreelistSnapshot(const String& dumpName)
+{
+ m_freeList.takeSnapshot(dumpName);
+}
+
#if ENABLE(GC_PROFILING)
void NormalPageHeap::snapshotFreeList(TracedValue& json)
{
@@ -1126,6 +1132,23 @@ int FreeList::bucketIndexForSize(size_t size)
return index;
}
+void FreeList::takeSnapshot(const String& dumpBaseName)
+{
+ for (size_t i = 0; i < blinkPageSizeLog2; ++i) {
+ size_t entryCount = 0;
+ size_t freeSize = 0;
+ for (FreeListEntry* entry = m_freeLists[i]; entry; entry = entry->next()) {
+ ++entryCount;
+ freeSize += entry->size();
+ }
+
+ String dumpName = dumpBaseName + String::format("/buckets/bucket_%lu", static_cast<unsigned long>(1 << i));
+ WebMemoryAllocatorDump* bucketDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(dumpName);
+ bucketDump->AddScalar("freelist_entry_count", "objects", entryCount);
+ bucketDump->AddScalar("free_size", "bytes", freeSize);
+ }
+}
+
#if ENABLE(GC_PROFILING)
void FreeList::getFreeSizeStats(PerBucketFreeListStats bucketStats[], size_t& totalFreeSize) const
{
@@ -1457,6 +1480,47 @@ void NormalPage::markOrphaned()
BasePage::markOrphaned();
}
+void NormalPage::takeSnapshot(String dumpName, size_t pageIndex, ThreadState::GCSnapshotInfo& info)
+{
+ dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long>(pageIndex)));
+ WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(dumpName);
+
+ HeapObjectHeader* header = nullptr;
+ size_t liveCount = 0;
+ size_t deadCount = 0;
+ size_t freeCount = 0;
+ size_t liveSize = 0;
+ size_t deadSize = 0;
+ size_t freeSize = 0;
+ for (Address headerAddress = payload(); headerAddress < payloadEnd(); headerAddress += header->size()) {
+ header = reinterpret_cast<HeapObjectHeader*>(headerAddress);
+ size_t tag = info.getClassTag(Heap::gcInfo(header->gcInfoIndex()));
haraken 2015/06/23 12:59:47 header->gcInfoIndex() is available only when the h
ssid 2015/06/23 19:40:02 Ah, I see. Thanks :)
+
+ if (header->isFree()) {
+ freeCount++;
+ freeSize += header->size();
+ } else if (header->isMarked()) {
+ liveCount++;
+ liveSize += header->size();
+ info.liveCount[tag]++;
+ info.liveSize[tag] += header->size();
+ } else {
+ deadCount++;
+ deadSize += header->size();
+ info.deadCount[tag]++;
+ info.deadSize[tag] += header->size();
+ }
+ }
+
+ pageDump->AddScalar("live_count", "objects", liveCount);
+ pageDump->AddScalar("dead_count", "objects", deadCount);
+ pageDump->AddScalar("free_count", "objects", freeCount);
+ pageDump->AddScalar("live_size", "bytes", liveSize);
+ pageDump->AddScalar("dead_size", "bytes", deadSize);
+ pageDump->AddScalar("free_size", "bytes", freeSize);
+
+}
+
#if ENABLE(GC_PROFILING)
const GCInfo* NormalPage::findGCInfo(Address address)
{
@@ -1632,6 +1696,35 @@ void LargeObjectPage::markOrphaned()
BasePage::markOrphaned();
}
+void LargeObjectPage::takeSnapshot(String dumpName, size_t pageIndex, ThreadState::GCSnapshotInfo& info)
+{
+ dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long>(pageIndex)));
+ WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(dumpName);
+
+ size_t liveSize = 0;
+ size_t deadSize = 0;
+ size_t liveCount = 0;
+ size_t deadCount = 0;
+ HeapObjectHeader* header = heapObjectHeader();
+ size_t tag = info.getClassTag(Heap::gcInfo(header->gcInfoIndex()));
+ if (header->isMarked()) {
+ liveCount = 1;
+ liveSize += header->size();
+ info.liveCount[tag]++;
+ info.liveSize[tag] += header->size();
+ } else {
+ deadCount = 1;
+ deadSize += header->size();
+ info.deadCount[tag]++;
+ info.deadSize[tag] += header->size();
+ }
+
+ pageDump->AddScalar("live_count", "objects", liveCount);
+ pageDump->AddScalar("dead_count", "objects", deadCount);
+ pageDump->AddScalar("live_size", "bytes", liveSize);
+ pageDump->AddScalar("dead_size", "bytes", deadSize);
+}
+
#if ENABLE(GC_PROFILING)
const GCInfo* LargeObjectPage::findGCInfo(Address address)
{
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | Source/platform/heap/ThreadState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698