Commit 660d4fa7 authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] Adjust number of parallel compaction tasks

This is a trivial spinoff of the more complicated CL splitting up memory:
  https://codereview.chromium.org/1365743003/

- Parallel compaction is still off.
- We now compute the number of parallel compaction tasks, depending on the
  evacuation candidate list, the number of cores, and some hard limit.

BUG=chromium:524425
LOG=N

Review URL: https://codereview.chromium.org/1371923002

Cr-Commit-Position: refs/heads/master@{#30965}
parent 6ca00aac
......@@ -6,6 +6,7 @@
#include "src/base/atomicops.h"
#include "src/base/bits.h"
#include "src/base/sys-info.h"
#include "src/code-stubs.h"
#include "src/compilation-cache.h"
#include "src/cpu-profiler.h"
......@@ -3370,13 +3371,24 @@ bool MarkCompactCollector::EvacuateLiveObjectsFromPage(
}
int MarkCompactCollector::NumberOfParallelCompactionTasks() {
if (!FLAG_parallel_compaction) return 1;
// We cap the number of parallel compaction tasks by
// - (#cores - 1)
// - a value depending on the list of evacuation candidates
// - a hard limit
const int kPagesPerCompactionTask = 4;
const int kMaxCompactionTasks = 8;
return Min(kMaxCompactionTasks,
Min(1 + evacuation_candidates_.length() / kPagesPerCompactionTask,
Max(1, base::SysInfo::NumberOfProcessors() - 1)));
}
void MarkCompactCollector::EvacuatePagesInParallel() {
if (evacuation_candidates_.length() == 0) return;
int num_tasks = 1;
if (FLAG_parallel_compaction) {
num_tasks = NumberOfParallelCompactionTasks();
}
const int num_tasks = NumberOfParallelCompactionTasks();
// Set up compaction spaces.
CompactionSpaceCollection** compaction_spaces_for_tasks =
......
......@@ -709,11 +709,8 @@ class MarkCompactCollector {
void EvacuatePagesInParallel();
int NumberOfParallelCompactionTasks() {
// TODO(hpayer, mlippautz): Figure out some logic to determine the number
// of compaction tasks.
return 1;
}
// The number of parallel compaction tasks, including the main thread.
int NumberOfParallelCompactionTasks();
void WaitUntilCompactionCompleted();
......
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