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

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

Issue 965283002: Oilpan: Implement marking time estimation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 5 years, 9 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') | no next file » | 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 0b61bbfc8468f184ca4c6f9f14b96e3a754843d9..e5416afff7609fd1753ee895c34ea2c744f7e383 100644
--- a/Source/platform/heap/Heap.cpp
+++ b/Source/platform/heap/Heap.cpp
@@ -2203,6 +2203,7 @@ void Heap::init()
s_allocatedObjectSize = 0;
s_allocatedSpace = 0;
s_markedObjectSize = 0;
+ s_markingTimeInLastGC = 0.0;
GCInfoTable::init();
}
@@ -2524,8 +2525,11 @@ void Heap::collectGarbage(ThreadState::StackState stackState, ThreadState::GCTyp
static_cast<MarkingVisitor<GlobalMarking>*>(s_markingVisitor)->reportStats();
#endif
+ double markingTimeInMilliseconds = WTF::currentTimeMS() - timeStamp;
+ s_markingTimeInLastGC = markingTimeInMilliseconds / 1000;
+
if (Platform::current()) {
- Platform::current()->histogramCustomCounts("BlinkGC.CollectGarbage", WTF::currentTimeMS() - timeStamp, 0, 10 * 1000, 50);
+ Platform::current()->histogramCustomCounts("BlinkGC.CollectGarbage", markingTimeInMilliseconds, 0, 10 * 1000, 50);
Platform::current()->histogramCustomCounts("BlinkGC.TotalObjectSpace", Heap::allocatedObjectSize() / 1024, 0, 4 * 1024 * 1024, 50);
Platform::current()->histogramCustomCounts("BlinkGC.TotalAllocatedSpace", Heap::allocatedSpace() / 1024, 0, 4 * 1024 * 1024, 50);
Platform::current()->histogramEnumeration("BlinkGC.GCReason", reason, NumberOfGCReasonForTracing);
@@ -2636,8 +2640,22 @@ void Heap::collectAllGarbage()
double Heap::estimatedMarkingTime()
{
- // FIXME: Implement heuristics
- return 0.0;
+ ASSERT(ThreadState::current()->isMainThread());
+
+ // Marking algorithm takes O(N_live_objs), so the next marking time can be estimated as:
+ // ~ N_live_objs
+ // t_next = t_last * ------------------
+ // N_last_live_objs
+ // By estimating N_{,last}_live_objs ratio using object size ratio, we get:
+ // ~ (Size_new_objs + Size_last_marked_objs) * Rate_alive
+ // t_next = t_last * ------------------------------------------------------
+ // Size_last_marked_objs
+
+ double estimatedObjectCountIncreaseRatio = 1.0;
+ if (Heap::markedObjectSize() > 0)
+ estimatedObjectCountIncreaseRatio = (Heap::allocatedObjectSize() + Heap::markedObjectSize()) * ThreadState::current()->collectionRate() / Heap::markedObjectSize();
+
+ return s_markingTimeInLastGC * estimatedObjectCountIncreaseRatio;
}
size_t Heap::objectPayloadSizeForTesting()
@@ -2899,5 +2917,6 @@ size_t Heap::s_markedObjectSize = 0;
size_t Heap::s_externallyAllocatedBytes = 0;
size_t Heap::s_externallyAllocatedBytesAlive = 0;
unsigned Heap::s_requestedUrgentGC = false;
+double Heap::s_markingTimeInLastGC = 0.0;
} // namespace blink
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698