Commit 5c6e407d authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Spawn parallel scavenging task per page in the from space

This makes the heuristic for computing the number of parallel tasks
in Scavenger consistent with that in Mark-Compactor.

The patch helps mobile devices where even 1 MB new space can take
10ms to scavenge.

Change-Id: I979de5e8485b93808ea079af2756f53d9b720e10
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1685612Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62566}
parent 1db33e5f
......@@ -362,11 +362,9 @@ void ScavengerCollector::MergeSurvivingNewLargeObjects(
int ScavengerCollector::NumberOfScavengeTasks() {
if (!FLAG_parallel_scavenge) return 1;
const int num_scavenge_tasks =
static_cast<int>(heap_->new_space()->TotalCapacity()) / MB;
static int num_cores = V8::GetCurrentPlatform()->NumberOfWorkerThreads() + 1;
int tasks =
Max(1, Min(Min(num_scavenge_tasks, kMaxScavengerTasks), num_cores));
const int num_pages = heap_->new_space()->from_space().pages_used();
const int num_cores = V8::GetCurrentPlatform()->NumberOfWorkerThreads() + 1;
int tasks = Max(1, Min(Min(num_pages, kMaxScavengerTasks), num_cores));
if (!heap_->CanExpandOldGeneration(
static_cast<size_t>(tasks * Page::kPageSize))) {
// Optimize for memory usage near the heap limit.
......
......@@ -2826,6 +2826,7 @@ void SemiSpace::Swap(SemiSpace* from, SemiSpace* to) {
std::swap(from->current_page_, to->current_page_);
std::swap(from->external_backing_store_bytes_,
to->external_backing_store_bytes_);
std::swap(from->pages_used_, to->pages_used_);
to->FixPagesFlags(saved_to_space_flags, Page::kCopyOnFlipFlagsMask);
from->FixPagesFlags(0, 0);
......
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