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

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

Issue 883233003: Oilpan: Add free list profiler. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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
Index: Source/platform/heap/Heap.cpp
diff --git a/Source/platform/heap/Heap.cpp b/Source/platform/heap/Heap.cpp
index 6290a6d9ba803928b7d8350fb51f1a3d58a8c7d2..dd15f11b9873544ebf1648d09002225c5656789d 100644
--- a/Source/platform/heap/Heap.cpp
+++ b/Source/platform/heap/Heap.cpp
@@ -548,6 +548,13 @@ ThreadHeap::ThreadHeap(ThreadState* state, int index)
, m_threadState(state)
, m_index(index)
, m_promptlyFreedSize(0)
+#if ENABLE(GC_PROFILING)
+ , m_totalAllocationSize(0.0)
haraken 2015/02/04 07:30:00 Where is this used?
+ , m_allocationCount(0)
haraken 2015/02/04 07:30:00 Ditto.
+ , m_inlineAllocationCount(0)
haraken 2015/02/04 07:30:00 Ditto.
+ , m_allocationPointSizeSum(0)
+ , m_setAllocationPointCount(0)
+#endif
{
clearFreeLists();
}
@@ -604,6 +611,10 @@ void ThreadHeap::setAllocationPoint(Address point, size_t size)
ASSERT(size <= static_cast<HeapPage*>(page)->payloadSize());
}
#endif
+#if ENABLE(GC_PROFILING)
+ m_allocationPointSizeSum += size;
+ ++m_setAllocationPointCount;
+#endif
if (hasCurrentAllocationArea())
addToFreeList(currentAllocationPoint(), remainingAllocationSize());
updateRemainingAllocationSize();
@@ -616,6 +627,10 @@ Address ThreadHeap::outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex)
ASSERT(allocationSize > remainingAllocationSize());
ASSERT(allocationSize >= allocationGranularity);
+#if ENABLE(GC_PROFILING)
+ m_threadState->snapshotFreeListIfNecessary();
+#endif
+
// 1. If this allocation is big enough, allocate a large object.
if (allocationSize >= largeObjectSizeThreshold)
return allocateLargeObject(allocationSize, gcInfoIndex);
@@ -1493,6 +1508,43 @@ void ThreadHeap::clearFreeLists()
m_freeList.clear();
}
+#if ENABLE(GC_PROFILING)
+void ThreadHeap::snapshotFreeList(TracedValue& json)
+{
+ json.setDouble("totalAllocationSize", m_totalAllocationSize);
keishi 2015/02/04 06:58:26 nit: I think this could be renamed to cummulativeA
Yuta Kitamura 2015/02/04 09:45:42 Fixed. Can you fix your dashboard code, too?
keishi 2015/02/04 11:05:39 Done.
+ json.setDouble("inlineAllocationRate", static_cast<double>(m_inlineAllocationCount) / m_allocationCount);
+ json.setInteger("inlineAllocationCount", m_inlineAllocationCount);
+ json.setInteger("allocationCount", m_allocationCount);
+ if (m_setAllocationPointCount > 0)
+ json.setDouble("averageAllocationPointSize", static_cast<double>(m_allocationPointSizeSum) / m_setAllocationPointCount);
keishi 2015/02/04 06:58:26 averageAllocationPointSize hasn't been a useful me
haraken 2015/02/04 07:30:00 Agreed. Also I'm not sure how helpful m_setAllocat
Yuta Kitamura 2015/02/04 09:45:42 Done, m_allocationPointSizeSum and m_setAllocation
+ m_allocationPointSizeSum = 0;
+ m_setAllocationPointCount = 0;
+ size_t pageCount = 0;
+ size_t totalPageSize = 0;
+ for (HeapPage* page = m_firstPage; page; page = page->next()) {
+ ++pageCount;
+ totalPageSize += page->payloadSize();
+ }
+ json.setInteger("pageCount", pageCount);
+ json.setInteger("totalPageSize", totalPageSize);
+ size_t bucketSizes[blinkPageSizeLog2];
+ size_t bucketTotalSizes[blinkPageSizeLog2];
keishi 2015/02/04 06:58:26 I'm sorry. bucketSizes and bucketTotalSizes were h
Yuta Kitamura 2015/02/04 09:45:42 Fixed, can you take another look at this version?
keishi 2015/02/04 11:05:39 Thanks, this is much better. Done.
+ size_t freeSize;
+ m_freeList.countBucketSizes(bucketSizes, bucketTotalSizes, freeSize);
+ json.setInteger("freeSize", freeSize);
+
+ json.beginArray("bucketSizes");
+ for (size_t i = 0; i < blinkPageSizeLog2; ++i)
+ json.pushInteger(bucketSizes[i]);
+ json.endArray();
+
+ json.beginArray("bucketTotalSizes");
+ for (size_t i = 0; i < blinkPageSizeLog2; ++i)
+ json.pushInteger(bucketTotalSizes[i]);
+ json.endArray();
+}
+#endif
+
void FreeList::clear()
{
m_biggestFreeListIndex = 0;
@@ -1511,6 +1563,22 @@ int FreeList::bucketIndexForSize(size_t size)
return index;
}
+#if ENABLE(GC_PROFILING)
+void FreeList::countBucketSizes(size_t sizes[], size_t totalSizes[], size_t& freeSize) const
+{
+ freeSize = 0;
+ for (size_t i = 0; i < blinkPageSizeLog2; i++) {
+ sizes[i] = 0;
+ totalSizes[i] = 0;
+ for (FreeListEntry* entry = m_freeLists[i]; entry; entry = entry->next()) {
+ ++sizes[i];
+ freeSize += entry->size();
+ totalSizes[i] += entry->size();
+ }
+ }
+}
+#endif
+
HeapPage::HeapPage(PageMemory* storage, ThreadHeap* heap)
: BaseHeapPage(storage, heap)
, m_next(nullptr)

Powered by Google App Engine
This is Rietveld 408576698