Commit f86985ad authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] Bound number of tasks by embedder limit instead of artificially capping

BUG=chromium:651354

Review-Url: https://codereview.chromium.org/2872063003
Cr-Commit-Position: refs/heads/master@{#45235}
parent 11a211ff
...@@ -335,32 +335,20 @@ class YoungGenerationEvacuationVerifier : public EvacuationVerifier { ...@@ -335,32 +335,20 @@ class YoungGenerationEvacuationVerifier : public EvacuationVerifier {
// MarkCompactCollectorBase, MinorMarkCompactCollector, MarkCompactCollector // MarkCompactCollectorBase, MinorMarkCompactCollector, MarkCompactCollector
// ============================================================================= // =============================================================================
int MarkCompactCollectorBase::NumberOfParallelCompactionTasks( int MarkCompactCollectorBase::NumberOfParallelCompactionTasks(int pages) {
int pages, intptr_t live_bytes) {
if (!FLAG_parallel_compaction) return 1; if (!FLAG_parallel_compaction) return 1;
// Compute the number of needed tasks based on a target compaction time, the const int available_cores = Max(
// profiled compaction speed and marked live memory. 1, static_cast<int>(
// V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads()));
// The number of parallel compaction tasks is limited by: return Min(available_cores, pages);
// - #evacuation pages }
// - #cores
const double kTargetCompactionTimeInMs = .5;
double compaction_speed =
heap()->tracer()->CompactionSpeedInBytesPerMillisecond();
int MarkCompactCollectorBase::NumberOfPointerUpdateTasks(int pages) {
if (!FLAG_parallel_pointer_update) return 1;
const int available_cores = Max( const int available_cores = Max(
1, static_cast<int>( 1, static_cast<int>(
V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads())); V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads()));
int tasks; return Min(available_cores, pages);
if (compaction_speed > 0) {
tasks = 1 + static_cast<int>(live_bytes / compaction_speed /
kTargetCompactionTimeInMs);
} else {
tasks = pages;
}
const int tasks_capped_pages = Min(pages, tasks);
return Min(available_cores, tasks_capped_pages);
} }
MarkCompactCollector::MarkCompactCollector(Heap* heap) MarkCompactCollector::MarkCompactCollector(Heap* heap)
...@@ -3740,7 +3728,7 @@ void MarkCompactCollectorBase::CreateAndExecuteEvacuationTasks( ...@@ -3740,7 +3728,7 @@ void MarkCompactCollectorBase::CreateAndExecuteEvacuationTasks(
ProfilingMigrationObserver profiling_observer(heap()); ProfilingMigrationObserver profiling_observer(heap());
const int wanted_num_tasks = const int wanted_num_tasks =
NumberOfParallelCompactionTasks(job->NumberOfPages(), live_bytes); NumberOfParallelCompactionTasks(job->NumberOfPages());
Evacuator** evacuators = new Evacuator*[wanted_num_tasks]; Evacuator** evacuators = new Evacuator*[wanted_num_tasks];
for (int i = 0; i < wanted_num_tasks; i++) { for (int i = 0; i < wanted_num_tasks; i++) {
evacuators[i] = new Evacuator(collector, record_visitor); evacuators[i] = new Evacuator(collector, record_visitor);
...@@ -4258,18 +4246,10 @@ class PointerUpdateJobTraits { ...@@ -4258,18 +4246,10 @@ class PointerUpdateJobTraits {
} }
}; };
int NumberOfPointerUpdateTasks(int pages) {
if (!FLAG_parallel_pointer_update) return 1;
const int available_cores = Max(
1, static_cast<int>(
V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads()));
const int kPagesPerTask = 4;
return Min(available_cores, (pages + kPagesPerTask - 1) / kPagesPerTask);
}
template <RememberedSetType type> template <RememberedSetType type>
void UpdatePointersInParallel(Heap* heap, base::Semaphore* semaphore, void MarkCompactCollectorBase::UpdatePointersInParallel(
const MarkCompactCollectorBase* collector) { Heap* heap, base::Semaphore* semaphore,
const MarkCompactCollectorBase* collector) {
PageParallelJob<PointerUpdateJobTraits<type> > job( PageParallelJob<PointerUpdateJobTraits<type> > job(
heap, heap->isolate()->cancelable_task_manager(), semaphore); heap, heap->isolate()->cancelable_task_manager(), semaphore);
RememberedSet<type>::IterateMemoryChunks( RememberedSet<type>::IterateMemoryChunks(
......
...@@ -327,6 +327,13 @@ class MarkCompactCollectorBase { ...@@ -327,6 +327,13 @@ class MarkCompactCollectorBase {
// Returns whether this page should be moved according to heuristics. // Returns whether this page should be moved according to heuristics.
bool ShouldMovePage(Page* p, intptr_t live_bytes); bool ShouldMovePage(Page* p, intptr_t live_bytes);
template <RememberedSetType type>
void UpdatePointersInParallel(Heap* heap, base::Semaphore* semaphore,
const MarkCompactCollectorBase* collector);
int NumberOfParallelCompactionTasks(int pages);
int NumberOfPointerUpdateTasks(int pages);
Heap* heap_; Heap* heap_;
}; };
......
...@@ -120,7 +120,7 @@ class PageParallelJob { ...@@ -120,7 +120,7 @@ class PageParallelJob {
} }
private: private:
static const int kMaxNumberOfTasks = 10; static const int kMaxNumberOfTasks = 32;
enum ProcessingState { kAvailable, kProcessing, kFinished, kFailed }; enum ProcessingState { kAvailable, kProcessing, kFinished, kFailed };
......
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