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

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

Issue 1211573006: Oilpan: Count # of collected Persistent handles and use it to estimate the live object size (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 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 546add8179f655f9560cac1df1c84a47a33bf37c..0b2c390988763b7e8b6485eb6e97b87ff8edabe0 100644
--- a/Source/platform/heap/Heap.cpp
+++ b/Source/platform/heap/Heap.cpp
@@ -886,6 +886,11 @@ Address NormalPageHeap::outOfLineAllocate(size_t allocationSize, size_t gcInfoIn
threadState()->snapshotFreeListIfNecessary();
#endif
+ // Ideally we want to update the persistent count every time a persistent
+ // handle is created or destructed, but that is heavy. So we do the update
+ // only in outOfLineAllocate().
+ threadState()->updatePersistentCounters();
+
// 1. If this allocation is big enough, allocate a large object.
if (allocationSize >= largeObjectSizeThreshold) {
// TODO(sof): support eagerly finalized large objects, if ever needed.
@@ -1914,9 +1919,20 @@ void Heap::init()
s_heapDoesNotContainCache = new HeapDoesNotContainCache();
s_freePagePool = new FreePagePool();
s_orphanedPagePool = new OrphanedPagePool();
- s_allocatedObjectSize = 0;
s_allocatedSpace = 0;
+ s_allocatedObjectSize = 0;
s_markedObjectSize = 0;
+ s_persistentCount = 0;
+ s_persistentCountAtLastGC = 0;
+ s_collectedPersistentCount = 0;
+ // We don't want to use 0 KB for the initial value because it may end up
+ // triggering the first GC too prematurely.
+ s_liveObjectSizeAtLastSweep = 1024 * 1024;
+ // Initially, the total heap size is very small. Thus we'll hit the GC
+ // condition (i.e., 50% increase on the heap size etc) even if we don't
+ // take into account the memory usage explained by the collected persistent
+ // handles. So it is OK to set a large initial value.
+ s_heapSizePerPersistent = 1024 * 1024;
s_estimatedMarkingTimePerByte = 0.0;
GCInfoTable::init();
@@ -2377,7 +2393,7 @@ void Heap::reportMemoryUsageForTracing()
{
// These values are divided by 1024 to avoid overflow in practical cases (TRACE_COUNTER values are 32-bit ints).
// They are capped to INT_MAX just in case.
- TRACE_COUNTER1("blink_gc", "Heap::estimatedLiveObjectSizeKB", std::min(Heap::estimatedLiveObjectSize() / 1024, static_cast<size_t>(INT_MAX)));
+ TRACE_COUNTER1("blink_gc", "Heap::liveObjectSizeAtLastSweepKB", std::min(Heap::liveObjectSizeAtLastSweep() / 1024, static_cast<size_t>(INT_MAX)));
TRACE_COUNTER1("blink_gc", "Heap::allocatedObjectSizeKB", std::min(Heap::allocatedObjectSize() / 1024, static_cast<size_t>(INT_MAX)));
TRACE_COUNTER1("blink_gc", "Heap::markedObjectSizeKB", std::min(Heap::markedObjectSize() / 1024, static_cast<size_t>(INT_MAX)));
TRACE_COUNTER1("blink_gc", "Partitions::totalSizeOfCommittedPagesKB", std::min(WTF::Partitions::totalSizeOfCommittedPages() / 1024, static_cast<size_t>(INT_MAX)));
@@ -2495,7 +2511,8 @@ void Heap::resetHeapCounters()
s_allocatedObjectSize = 0;
s_markedObjectSize = 0;
- s_externalObjectSizeAtLastGC = WTF::Partitions::totalSizeOfCommittedPages();
+ s_persistentCountAtLastGC = s_persistentCount;
+ s_collectedPersistentCount = 0;
}
CallbackStack* Heap::s_markingStack;
@@ -2507,13 +2524,14 @@ bool Heap::s_shutdownCalled = false;
FreePagePool* Heap::s_freePagePool;
OrphanedPagePool* Heap::s_orphanedPagePool;
Heap::RegionTree* Heap::s_regionTree = nullptr;
-size_t Heap::s_allocatedObjectSize = 0;
size_t Heap::s_allocatedSpace = 0;
+size_t Heap::s_allocatedObjectSize = 0;
size_t Heap::s_markedObjectSize = 0;
-// We don't want to use 0 KB for the initial value because it may end up
-// triggering the first GC of some thread too prematurely.
-size_t Heap::s_estimatedLiveObjectSize = 512 * 1024;
-size_t Heap::s_externalObjectSizeAtLastGC = 0;
+size_t Heap::s_persistentCount = 0;
+size_t Heap::s_persistentCountAtLastGC = 0;
+size_t Heap::s_collectedPersistentCount = 0;
+size_t Heap::s_liveObjectSizeAtLastSweep = 0;
+size_t Heap::s_heapSizePerPersistent = 0;
double Heap::s_estimatedMarkingTimePerByte = 0.0;
} // namespace blink
« 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