heap: Fix metric around corner case of fast marking

Bug: v8:10956
Change-Id: Iab17e3f0163aa81cfb978d72e0f0cd9b15c14743
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2454716
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70371}
This commit is contained in:
Michael Lippautz 2020-10-07 11:11:58 +02:00 committed by Commit Bot
parent f3a666d694
commit 12776afce9

View File

@ -1229,22 +1229,27 @@ void GCTracer::RecordGCPhasesHistograms(TimedHistogram* gc_timer) {
heap_->isolate()->counters()->gc_marking_sum()->AddSample(
static_cast<int>(overall_marking_time));
// Filter out samples where
// - we don't have high-resolution timers;
// - size of marked objects is very small;
// - marking time is rounded to 0;
constexpr size_t kMinObjectSizeForReportingThroughput = 1024 * 1024;
if (base::TimeTicks::IsHighResolution() &&
heap_->SizeOfObjects() > kMinObjectSizeForReportingThroughput) {
DCHECK_GT(overall_marking_time, 0.0);
heap_->SizeOfObjects() > kMinObjectSizeForReportingThroughput &&
overall_marking_time > 0) {
const double overall_v8_marking_time =
overall_marking_time -
current_.scopes[Scope::MC_MARK_EMBEDDER_TRACING];
DCHECK_GT(overall_v8_marking_time, 0.0);
const int main_thread_marking_throughput_mb_per_s =
static_cast<int>(static_cast<double>(heap_->SizeOfObjects()) /
overall_v8_marking_time * 1000 / 1024 / 1024);
heap_->isolate()
->counters()
->gc_main_thread_marking_throughput()
->AddSample(
static_cast<int>(main_thread_marking_throughput_mb_per_s));
if (overall_v8_marking_time > 0) {
const int main_thread_marking_throughput_mb_per_s =
static_cast<int>(static_cast<double>(heap_->SizeOfObjects()) /
overall_v8_marking_time * 1000 / 1024 / 1024);
heap_->isolate()
->counters()
->gc_main_thread_marking_throughput()
->AddSample(
static_cast<int>(main_thread_marking_throughput_mb_per_s));
}
}
DCHECK_EQ(Scope::LAST_TOP_MC_SCOPE, Scope::MC_SWEEP);