Commit 371c7a38 authored by ulan's avatar ulan Committed by Commit bot

[heap] Add histogram counters to track GC reasons.

BUG=chromium:644713
LOG=NO

Review-Url: https://codereview.chromium.org/2322453002
Cr-Commit-Position: refs/heads/master@{#39250}
parent 5e6a1abf
...@@ -835,6 +835,9 @@ class RuntimeCallStats { ...@@ -835,6 +835,9 @@ class RuntimeCallStats {
HR(code_cache_reject_reason, V8.CodeCacheRejectReason, 1, 6, 6) \ HR(code_cache_reject_reason, V8.CodeCacheRejectReason, 1, 6, 6) \
HR(errors_thrown_per_context, V8.ErrorsThrownPerContext, 0, 200, 20) \ HR(errors_thrown_per_context, V8.ErrorsThrownPerContext, 0, 200, 20) \
HR(debug_feature_usage, V8.DebugFeatureUsage, 1, 7, 7) \ HR(debug_feature_usage, V8.DebugFeatureUsage, 1, 7, 7) \
HR(incremental_marking_reason, V8.GCIncrementalMarkingReason, 0, 21, 22) \
HR(mark_compact_reason, V8.GCMarkCompactReason, 0, 21, 22) \
HR(scavenge_reason, V8.GCScavengeReason, 0, 21, 22) \
/* Asm/Wasm. */ \ /* Asm/Wasm. */ \
HR(wasm_functions_per_module, V8.WasmFunctionsPerModule, 1, 10000, 51) HR(wasm_functions_per_module, V8.WasmFunctionsPerModule, 1, 10000, 51)
......
...@@ -205,10 +205,17 @@ void GCTracer::Start(GarbageCollector collector, ...@@ -205,10 +205,17 @@ void GCTracer::Start(GarbageCollector collector,
int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB); int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB);
int used_memory = static_cast<int>(current_.start_object_size / KB); int used_memory = static_cast<int>(current_.start_object_size / KB);
heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample(
start_time, committed_memory); Counters* counters = heap_->isolate()->counters();
heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample(
start_time, used_memory); if (collector == SCAVENGER) {
counters->scavenge_reason()->AddSample(static_cast<int>(gc_reason));
} else {
counters->mark_compact_reason()->AddSample(static_cast<int>(gc_reason));
}
counters->aggregated_memory_heap_committed()->AddSample(start_time,
committed_memory);
counters->aggregated_memory_heap_used()->AddSample(start_time, used_memory);
// TODO(cbruni): remove once we fully moved to a trace-based system. // TODO(cbruni): remove once we fully moved to a trace-based system.
if (FLAG_runtime_call_stats) { if (FLAG_runtime_call_stats) {
RuntimeCallStats::Enter(heap_->isolate()->counters()->runtime_call_stats(), RuntimeCallStats::Enter(heap_->isolate()->counters()->runtime_call_stats(),
......
...@@ -349,28 +349,31 @@ enum class ClearRecordedSlots { kYes, kNo }; ...@@ -349,28 +349,31 @@ enum class ClearRecordedSlots { kYes, kNo };
enum class ClearBlackArea { kYes, kNo }; enum class ClearBlackArea { kYes, kNo };
enum class GarbageCollectionReason { enum class GarbageCollectionReason {
kUnknown, kUnknown = 0,
kAllocationFailure, kAllocationFailure = 1,
kAllocationLimit, kAllocationLimit = 2,
kContextDisposal, kContextDisposal = 3,
kCountersExtension, kCountersExtension = 4,
kDebugger, kDebugger = 5,
kDeserializer, kDeserializer = 6,
kExternalMemoryPressure, kExternalMemoryPressure = 7,
kFinalizeMarkingViaStackGuard, kFinalizeMarkingViaStackGuard = 8,
kFinalizeMarkingViaTask, kFinalizeMarkingViaTask = 9,
kFullHashtable, kFullHashtable = 10,
kHeapProfiler, kHeapProfiler = 11,
kIdleTask, kIdleTask = 12,
kLastResort, kLastResort = 13,
kLowMemoryNotification, kLowMemoryNotification = 14,
kMakeHeapIterable, kMakeHeapIterable = 15,
kMemoryPressure, kMemoryPressure = 16,
kMemoryReducer, kMemoryReducer = 17,
kRuntime, kRuntime = 18,
kSamplingProfiler, kSamplingProfiler = 19,
kSnapshotCreator, kSnapshotCreator = 20,
kTesting kTesting = 21
// If you add new items here, then update the incremental_marking_reason,
// mark_compact_reason, and scavenge_reason counters in counters.h.
// Also update src/tools/metrics/histograms/histograms.xml in chromium.
}; };
// A queue of objects promoted during scavenge. Each object is accompanied by // A queue of objects promoted during scavenge. Each object is accompanied by
......
...@@ -515,8 +515,12 @@ void IncrementalMarking::Start(GarbageCollectionReason gc_reason) { ...@@ -515,8 +515,12 @@ void IncrementalMarking::Start(GarbageCollectionReason gc_reason) {
DCHECK(heap_->gc_state() == Heap::NOT_IN_GC); DCHECK(heap_->gc_state() == Heap::NOT_IN_GC);
DCHECK(!heap_->isolate()->serializer_enabled()); DCHECK(!heap_->isolate()->serializer_enabled());
Counters* counters = heap_->isolate()->counters();
counters->incremental_marking_reason()->AddSample(
static_cast<int>(gc_reason));
HistogramTimerScope incremental_marking_scope( HistogramTimerScope incremental_marking_scope(
heap_->isolate()->counters()->gc_incremental_marking_start()); counters->gc_incremental_marking_start());
TRACE_EVENT0("v8", "V8.GCIncrementalMarkingStart"); TRACE_EVENT0("v8", "V8.GCIncrementalMarkingStart");
ResetStepCounters(); ResetStepCounters();
heap_->tracer()->NotifyIncrementalMarkingStart(); heap_->tracer()->NotifyIncrementalMarkingStart();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment