From 2c75616028e75883e28df2c6d8dd2a6bfe47f718 Mon Sep 17 00:00:00 2001 From: Ulan Degenbaev Date: Thu, 5 Oct 2017 15:11:37 +0200 Subject: [PATCH] [heap] Ensure progress in unmapping memory chunks. If sweeping is not making progress and there are many young generation GCs happening, then this can lead to accumulation of memory chunks in the unmapper queue. Bug: chromium:771966 Change-Id: Ief73ada0d17198a80b668850c6d2e7ea413113e7 Reviewed-on: https://chromium-review.googlesource.com/702479 Reviewed-by: Michael Lippautz Commit-Queue: Ulan Degenbaev Cr-Commit-Position: refs/heads/master@{#48312} --- src/heap/heap.cc | 6 ++++++ src/heap/spaces.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/heap/heap.cc b/src/heap/heap.cc index eab9dfaa6c..25061d544b 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -1935,6 +1935,12 @@ void Heap::Scavenge() { IncrementalMarking::PauseBlackAllocationScope pause_black_allocation( incremental_marking()); + if (mark_compact_collector()->sweeper().sweeping_in_progress() && + memory_allocator_->unmapper()->NumberOfDelayedChunks() > + kMaxSemiSpaceSizeInKB / Page::kPageSize) { + mark_compact_collector()->EnsureSweepingCompleted(); + } + mark_compact_collector()->sweeper().EnsureNewSpaceCompleted(); SetGCState(SCAVENGE); diff --git a/src/heap/spaces.h b/src/heap/spaces.h index 63241ab2b5..9080763633 100644 --- a/src/heap/spaces.h +++ b/src/heap/spaces.h @@ -1196,6 +1196,11 @@ class V8_EXPORT_PRIVATE MemoryAllocator { bool has_delayed_chunks() { return delayed_regular_chunks_.size() > 0; } + int NumberOfDelayedChunks() { + base::LockGuard guard(&mutex_); + return static_cast(delayed_regular_chunks_.size()); + } + private: static const int kReservedQueueingSlots = 64; static const int kMaxUnmapperTasks = 24;