Commit 59cf4f8b authored by Darius Mercadier's avatar Darius Mercadier Committed by Commit Bot

[heap] Remove sorting of map space before sweeping

Sorting is done in order to make compaction more efficient: by
sweeping pages with the most free bytes first, we make it more likely
that when evacuating a page, already swept pages will have enough free
bytes to hold the objects to move (and therefore, we won't need to
wait for more pages to be swept in order to move those objects).
Since maps don't move, there is no need to sort the pages from
MAP_SPACE before sweeping them.

Bug: v8:9093
Bug: v8:9329
Change-Id: I63964364d3cd0b64faf8570e87b5f75de6443902
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1736746
Commit-Queue: Darius Mercadier <dmercadier@google.com>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63086}
parent 9b24f6ec
......@@ -154,12 +154,21 @@ void Sweeper::StartSweeping() {
MajorNonAtomicMarkingState* marking_state =
heap_->mark_compact_collector()->non_atomic_marking_state();
ForAllSweepingSpaces([this, marking_state](AllocationSpace space) {
int space_index = GetSweepSpaceIndex(space);
std::sort(
sweeping_list_[space_index].begin(), sweeping_list_[space_index].end(),
[marking_state](Page* a, Page* b) {
return marking_state->live_bytes(a) > marking_state->live_bytes(b);
});
// Sorting is done in order to make compaction more efficient: by sweeping
// pages with the most free bytes first, we make it more likely that when
// evacuating a page, already swept pages will have enough free bytes to
// hold the objects to move (and therefore, we won't need to wait for more
// pages to be swept in order to move those objects).
// Since maps don't move, there is no need to sort the pages from MAP_SPACE
// before sweeping them.
if (space != MAP_SPACE) {
int space_index = GetSweepSpaceIndex(space);
std::sort(
sweeping_list_[space_index].begin(),
sweeping_list_[space_index].end(), [marking_state](Page* a, Page* b) {
return marking_state->live_bytes(a) > marking_state->live_bytes(b);
});
}
});
}
......
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