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 @@ ...@@ -6,6 +6,7 @@
#include "src/base/atomicops.h" #include "src/base/atomicops.h"
#include "src/base/bits.h" #include "src/base/bits.h"
#include "src/base/sys-info.h"
#include "src/code-stubs.h" #include "src/code-stubs.h"
#include "src/compilation-cache.h" #include "src/compilation-cache.h"
#include "src/cpu-profiler.h" #include "src/cpu-profiler.h"
...@@ -3370,13 +3371,24 @@ bool MarkCompactCollector::EvacuateLiveObjectsFromPage( ...@@ -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() { void MarkCompactCollector::EvacuatePagesInParallel() {
if (evacuation_candidates_.length() == 0) return; if (evacuation_candidates_.length() == 0) return;
int num_tasks = 1; const int num_tasks = NumberOfParallelCompactionTasks();
if (FLAG_parallel_compaction) {
num_tasks = NumberOfParallelCompactionTasks();
}
// Set up compaction spaces. // Set up compaction spaces.
CompactionSpaceCollection** compaction_spaces_for_tasks = CompactionSpaceCollection** compaction_spaces_for_tasks =
......
...@@ -709,11 +709,8 @@ class MarkCompactCollector { ...@@ -709,11 +709,8 @@ class MarkCompactCollector {
void EvacuatePagesInParallel(); void EvacuatePagesInParallel();
int NumberOfParallelCompactionTasks() { // The number of parallel compaction tasks, including the main thread.
// TODO(hpayer, mlippautz): Figure out some logic to determine the number int NumberOfParallelCompactionTasks();
// of compaction tasks.
return 1;
}
void WaitUntilCompactionCompleted(); 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