Commit 651a7901 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Limit the number of parallel evacuation tasks near OOM.

Launching too many parallel tasks near OOM increases risk of allocation
failure during GC and OOM crash.

Bug: chromium:824214, v8:7605
Change-Id: I336d1f01e4005fb2a8e16ef92f40532b8ed83f2c
TBR: mlippautz@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/983919
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52282}
parent d0302e1a
......@@ -1997,7 +1997,13 @@ int Heap::NumberOfScavengeTasks() {
const int num_scavenge_tasks =
static_cast<int>(new_space()->TotalCapacity()) / MB;
static int num_cores = V8::GetCurrentPlatform()->NumberOfWorkerThreads() + 1;
return Max(1, Min(Min(num_scavenge_tasks, kMaxScavengerTasks), num_cores));
int tasks =
Max(1, Min(Min(num_scavenge_tasks, kMaxScavengerTasks), num_cores));
if (!CanExpandOldGeneration(static_cast<size_t>(tasks * Page::kPageSize))) {
// Optimize for memory usage near the heap limit.
tasks = 1;
}
return tasks;
}
void Heap::Scavenge() {
......
......@@ -473,7 +473,14 @@ int NumberOfAvailableCores() {
int MarkCompactCollectorBase::NumberOfParallelCompactionTasks(int pages) {
DCHECK_GT(pages, 0);
return FLAG_parallel_compaction ? Min(NumberOfAvailableCores(), pages) : 1;
int tasks =
FLAG_parallel_compaction ? Min(NumberOfAvailableCores(), pages) : 1;
if (!heap_->CanExpandOldGeneration(
static_cast<size_t>(tasks * Page::kPageSize))) {
// Optimize for memory usage near the heap limit.
tasks = 1;
}
return tasks;
}
int MarkCompactCollectorBase::NumberOfParallelPointerUpdateTasks(int pages,
......
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