Commit 8b5d4de3 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Add UMA histograms for memory measurement delay and GC

This adds two new histograms:
- V8.MeasureMemoryDelayMilliseconds measures how long it takes to
  serve a memory measurement request
- V8.GCFinalizeMCMeasureMemory is a variant of the existing GC pause
  histogram that used when GC runs in memory measurement mode.

Additionally this CL lowers the maximum measurement delay to 10 seconds.

Bug: chromium:1049093
Change-Id: I97cbf443da514a69d6cf8c1d74d2757098e60acd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2089937Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66606}
parent 62d2b9d0
......@@ -1287,17 +1287,18 @@ TimedHistogram* Heap::GCTypePriorityTimer(GarbageCollector collector) {
TimedHistogram* Heap::GCTypeTimer(GarbageCollector collector) {
if (IsYoungGenerationCollector(collector)) {
return isolate_->counters()->gc_scavenger();
} else {
if (!incremental_marking()->IsStopped()) {
if (ShouldReduceMemory()) {
return isolate_->counters()->gc_finalize_reduce_memory();
} else {
return isolate_->counters()->gc_finalize();
}
} else {
return isolate_->counters()->gc_compactor();
}
}
if (incremental_marking()->IsStopped()) {
return isolate_->counters()->gc_compactor();
}
if (ShouldReduceMemory()) {
return isolate_->counters()->gc_finalize_reduce_memory();
}
if (incremental_marking()->IsMarking() &&
incremental_marking()->marking_worklists()->IsPerContextMode()) {
return isolate_->counters()->gc_finalize_measure_memory();
}
return isolate_->counters()->gc_finalize();
}
void Heap::CollectAllGarbage(int flags, GarbageCollectionReason gc_reason,
......
......@@ -13,6 +13,7 @@
#include "src/heap/factory.h"
#include "src/heap/incremental-marking.h"
#include "src/heap/marking-worklist.h"
#include "src/logging/counters.h"
#include "src/objects/js-promise-inl.h"
#include "src/objects/js-promise.h"
#include "src/tasks/task-utils.h"
......@@ -178,8 +179,12 @@ bool MemoryMeasurement::EnqueueRequest(
}
Handle<WeakFixedArray> global_weak_contexts =
isolate_->global_handles()->Create(*weak_contexts);
Request request = {std::move(delegate), global_weak_contexts,
std::vector<size_t>(length), 0u};
Request request = {std::move(delegate),
global_weak_contexts,
std::vector<size_t>(length),
0u,
{}};
request.timer.Start();
received_.push_back(std::move(request));
ScheduleGCTask(execution);
return true;
......@@ -303,6 +308,8 @@ void MemoryMeasurement::ReportResults() {
sizes.push_back(std::make_pair(context, request.sizes[i]));
}
request.delegate->MeasurementComplete(sizes, request.shared);
isolate_->counters()->measure_memory_delay_ms()->AddSample(
static_cast<int>(request.timer.Elapsed().InMilliseconds()));
}
}
......
......@@ -8,6 +8,7 @@
#include <list>
#include <unordered_map>
#include "src/base/platform/elapsed-timer.h"
#include "src/common/globals.h"
#include "src/objects/contexts.h"
#include "src/objects/map.h"
......@@ -34,12 +35,13 @@ class MemoryMeasurement {
Handle<JSPromise> promise, v8::MeasureMemoryMode mode);
private:
static const int kGCTaskDelayInSeconds = 60;
static const int kGCTaskDelayInSeconds = 10;
struct Request {
std::unique_ptr<v8::MeasureMemoryDelegate> delegate;
Handle<WeakFixedArray> contexts;
std::vector<size_t> sizes;
size_t shared;
base::ElapsedTimer timer;
};
void ScheduleReportingTask();
void ReportResults();
......
......@@ -123,6 +123,8 @@ namespace internal {
HT(gc_finalize, V8.GCFinalizeMC, 10000, MILLISECOND) \
HT(gc_finalize_background, V8.GCFinalizeMCBackground, 10000, MILLISECOND) \
HT(gc_finalize_foreground, V8.GCFinalizeMCForeground, 10000, MILLISECOND) \
HT(gc_finalize_measure_memory, V8.GCFinalizeMCMeasureMemory, 10000, \
MILLISECOND) \
HT(gc_finalize_reduce_memory, V8.GCFinalizeMCReduceMemory, 10000, \
MILLISECOND) \
HT(gc_finalize_reduce_memory_background, \
......@@ -132,6 +134,8 @@ namespace internal {
HT(gc_scavenger, V8.GCScavenger, 10000, MILLISECOND) \
HT(gc_scavenger_background, V8.GCScavengerBackground, 10000, MILLISECOND) \
HT(gc_scavenger_foreground, V8.GCScavengerForeground, 10000, MILLISECOND) \
HT(measure_memory_delay_ms, V8.MeasureMemoryDelayMilliseconds, 100000, \
MILLISECOND) \
/* TurboFan timers. */ \
HT(turbofan_optimize_prepare, V8.TurboFanOptimizePrepare, 1000000, \
MICROSECOND) \
......
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