Commit 5a779ecd authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[heap] Finish sweeping only for particular space

Instead of completely finishing sweeping in the slow path of allocation,
just sweep all pages for the current PagedSpace. This will help
in making main thread allocation concurrent, since there is no need
anymore to lock the allocation mutexes of other PagedSpaces.

Bug: v8:10315
Change-Id: I1cf76d94fa7a22e726fc71f49c2d5669e4a0598c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2292306
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68822}
parent e87484c6
......@@ -622,6 +622,12 @@ void MarkCompactCollector::EnsureSweepingCompleted() {
#endif
}
void MarkCompactCollector::DrainSweepingWorklistForSpace(
AllocationSpace space) {
if (!sweeper()->sweeping_in_progress()) return;
sweeper()->DrainSweepingWorklistForSpace(space);
}
void MarkCompactCollector::ComputeEvacuationHeuristics(
size_t area_size, int* target_fragmentation_percent,
size_t* max_evacuated_bytes) {
......
......@@ -516,6 +516,7 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
//
// Note: Can only be called safely from main thread.
V8_EXPORT_PRIVATE void EnsureSweepingCompleted();
void DrainSweepingWorklistForSpace(AllocationSpace space);
// Checks if sweeping is in progress right now on any space.
bool sweeping_in_progress() const { return sweeper_->sweeping_in_progress(); }
......
......@@ -858,8 +858,9 @@ bool PagedSpace::EnsureSweptAndRetryAllocation(int size_in_bytes,
DCHECK(!is_local_space());
MarkCompactCollector* collector = heap()->mark_compact_collector();
if (collector->sweeping_in_progress()) {
// Wait for the sweeper threads here and complete the sweeping phase.
collector->EnsureSweepingCompleted();
// Complete sweeping for this space.
collector->DrainSweepingWorklistForSpace(identity());
RefillFreeList();
// After waiting for the sweeper threads, there may be new free-list
// entries.
......@@ -920,7 +921,7 @@ bool PagedSpace::RawSlowRefillLinearAllocationArea(int size_in_bytes,
if (collector->sweeping_in_progress()) {
if (FLAG_concurrent_sweeping && !is_compaction_space() &&
!collector->sweeper()->AreSweeperTasksRunning()) {
collector->EnsureSweepingCompleted();
collector->DrainSweepingWorklistForSpace(identity());
}
// First try to refill the free-list, concurrent sweeper threads
......
......@@ -247,6 +247,11 @@ void Sweeper::EnsureCompleted() {
sweeping_in_progress_ = false;
}
void Sweeper::DrainSweepingWorklistForSpace(AllocationSpace space) {
if (!sweeping_in_progress_) return;
ParallelSweepSpace(space, 0);
}
void Sweeper::SupportConcurrentSweeping() {
ForAllSweepingSpaces([this](AllocationSpace space) {
const int kMaxPagesToSweepPerSpace = 1;
......
......@@ -106,6 +106,7 @@ class Sweeper {
void StartSweeping();
V8_EXPORT_PRIVATE void StartSweeperTasks();
void EnsureCompleted();
void DrainSweepingWorklistForSpace(AllocationSpace space);
bool AreSweeperTasksRunning();
// Support concurrent sweepers from main thread
......
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