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 {
HR(code_cache_reject_reason, V8.CodeCacheRejectReason, 1, 6, 6) \
HR(errors_thrown_per_context, V8.ErrorsThrownPerContext, 0, 200, 20) \
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. */ \
HR(wasm_functions_per_module, V8.WasmFunctionsPerModule, 1, 10000, 51)
......
......@@ -205,10 +205,17 @@ void GCTracer::Start(GarbageCollector collector,
int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB);
int used_memory = static_cast<int>(current_.start_object_size / KB);
heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample(
start_time, committed_memory);
heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample(
start_time, used_memory);
Counters* counters = heap_->isolate()->counters();
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.
if (FLAG_runtime_call_stats) {
RuntimeCallStats::Enter(heap_->isolate()->counters()->runtime_call_stats(),
......
......@@ -349,28 +349,31 @@ enum class ClearRecordedSlots { kYes, kNo };
enum class ClearBlackArea { kYes, kNo };
enum class GarbageCollectionReason {
kUnknown,
kAllocationFailure,
kAllocationLimit,
kContextDisposal,
kCountersExtension,
kDebugger,
kDeserializer,
kExternalMemoryPressure,
kFinalizeMarkingViaStackGuard,
kFinalizeMarkingViaTask,
kFullHashtable,
kHeapProfiler,
kIdleTask,
kLastResort,
kLowMemoryNotification,
kMakeHeapIterable,
kMemoryPressure,
kMemoryReducer,
kRuntime,
kSamplingProfiler,
kSnapshotCreator,
kTesting
kUnknown = 0,
kAllocationFailure = 1,
kAllocationLimit = 2,
kContextDisposal = 3,
kCountersExtension = 4,
kDebugger = 5,
kDeserializer = 6,
kExternalMemoryPressure = 7,
kFinalizeMarkingViaStackGuard = 8,
kFinalizeMarkingViaTask = 9,
kFullHashtable = 10,
kHeapProfiler = 11,
kIdleTask = 12,
kLastResort = 13,
kLowMemoryNotification = 14,
kMakeHeapIterable = 15,
kMemoryPressure = 16,
kMemoryReducer = 17,
kRuntime = 18,
kSamplingProfiler = 19,
kSnapshotCreator = 20,
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
......
......@@ -515,8 +515,12 @@ void IncrementalMarking::Start(GarbageCollectionReason gc_reason) {
DCHECK(heap_->gc_state() == Heap::NOT_IN_GC);
DCHECK(!heap_->isolate()->serializer_enabled());
Counters* counters = heap_->isolate()->counters();
counters->incremental_marking_reason()->AddSample(
static_cast<int>(gc_reason));
HistogramTimerScope incremental_marking_scope(
heap_->isolate()->counters()->gc_incremental_marking_start());
counters->gc_incremental_marking_start());
TRACE_EVENT0("v8", "V8.GCIncrementalMarkingStart");
ResetStepCounters();
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