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/ThreadState.cpp

Issue 903033003: Oilpan: Implement mark/sweep stats collection for 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
« Source/platform/heap/Heap.cpp ('K') | « Source/platform/heap/ThreadState.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/ThreadState.cpp
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp
index be833d48df1d3d438cf739bb075f529a3b73b55b..131b6afdda68f89849f4416e59320b4756a3aa33 100644
--- a/Source/platform/heap/ThreadState.cpp
+++ b/Source/platform/heap/ThreadState.cpp
@@ -670,6 +670,12 @@ void ThreadState::snapshot()
TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("blink_gc", "ThreadState", this, json.release());
}
+
+void ThreadState::incrementMarkedObjectsAge()
+{
+ for (int i = 0; i < NumberOfHeaps; ++i)
+ m_heaps[i]->incrementMarkedObjectsAge();
+}
#endif
void ThreadState::pushWeakPointerCallback(void* object, WeakPointerCallback callback)
@@ -990,6 +996,25 @@ void ThreadState::preGC()
void ThreadState::postGC(GCType gcType)
{
ASSERT(isInGC());
+
+#if ENABLE(GC_PROFILING)
+ // We snapshot the heap prior to sweeping to get numbers for both resources
+ // that have been allocated since the last GC and for resources that are
+ // going to be freed.
+ bool gcTracingEnabled;
+ TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled);
+
+ if (gcTracingEnabled) {
+ bool disabledByDefaultGCTracingEnabled;
+ TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink_gc"), &disabledByDefaultGCTracingEnabled);
+
+ snapshot();
+ if (disabledByDefaultGCTracingEnabled)
+ collectAndReportMarkSweepStats();
+ incrementMarkedObjectsAge();
+ }
+#endif
+
setGCState(gcType == GCWithSweep ? EagerSweepScheduled : LazySweepScheduled);
for (int i = 0; i < NumberOfHeaps; i++)
m_heaps[i]->prepareForSweep();
@@ -1130,16 +1155,6 @@ void ThreadState::postGCProcessing()
m_didV8GCAfterLastGC = false;
-#if ENABLE(GC_PROFILING)
- // We snapshot the heap prior to sweeping to get numbers for both resources
- // that have been allocated since the last GC and for resources that are
- // going to be freed.
- bool gcTracingEnabled;
- TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled);
- if (gcTracingEnabled)
- snapshot();
-#endif
-
{
if (isMainThread())
ScriptForbiddenScope::enter();
@@ -1300,6 +1315,34 @@ void ThreadState::snapshotFreeList()
TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "FreeList", this, json.release());
}
+
+void ThreadState::collectAndReportMarkSweepStats() const
+{
+ if (!isMainThread())
haraken 2015/02/06 06:39:20 Why do we need to have the isMainThread check? Thr
Yuta Kitamura 2015/02/06 07:45:45 The reason is that data from non-main thread makes
haraken 2015/02/06 07:51:50 Thanks, makes sense.
keishi 2015/02/06 08:21:07 All records in the trace json file have tid fields
+ return;
+
+ ClassAgeCountsMap markingClassAgeCounts;
+ for (int i = 0; i < NumberOfHeaps; ++i)
+ m_heaps[i]->countMarkedObjects(markingClassAgeCounts);
+ reportMarkSweepStats("MarkingStats", markingClassAgeCounts);
+
+ ClassAgeCountsMap sweepingClassAgeCounts;
+ for (int i = 0; i < NumberOfHeaps; ++i)
+ m_heaps[i]->countObjectsToSweep(sweepingClassAgeCounts);
+ reportMarkSweepStats("SweepingStats", sweepingClassAgeCounts);
+}
+
+void ThreadState::reportMarkSweepStats(const char* statsName, const ClassAgeCountsMap& classAgeCounts) const
+{
+ RefPtr<TracedValue> json = TracedValue::create();
+ for (ClassAgeCountsMap::const_iterator it = classAgeCounts.begin(), end = classAgeCounts.end(); it != end; ++it) {
+ json->beginArray(it->key.ascii().data());
+ for (size_t age = 0; age <= maxHeapObjectAge; ++age)
+ json->pushInteger(it->value.ages[age]);
+ json->endArray();
+ }
+ TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), statsName, this, json.release());
+}
#endif
} // namespace blink
« Source/platform/heap/Heap.cpp ('K') | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698