Skip to content

Commit

Permalink
deps: cherry-pick 2c75616 from upstream V8
Browse files Browse the repository at this point in the history
Original commit message:

    [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 <mlippautz@chromium.org>
    Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#48312}

Refs: v8/v8@2c75616
Refs: nodejs/help#917 (comment)
Refs: https://bugs.chromium.org/p/chromium/issues/detail?id=771966

PR-URL: #16490
Backport-PR-URL: #16413
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
targos authored and gibfahn committed Feb 18, 2018
1 parent 0b690a9 commit 16a980b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions deps/v8/src/heap/heap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1885,6 +1885,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);
Expand Down
5 changes: 5 additions & 0 deletions deps/v8/src/heap/spaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,11 @@ class V8_EXPORT_PRIVATE MemoryAllocator {

bool has_delayed_chunks() { return delayed_regular_chunks_.size() > 0; }

int NumberOfDelayedChunks() {
base::LockGuard<base::Mutex> guard(&mutex_);
return static_cast<int>(delayed_regular_chunks_.size());
}

private:
static const int kReservedQueueingSlots = 64;
static const int kMaxUnmapperTasks = 24;
Expand Down

0 comments on commit 16a980b

Please sign in to comment.