Commit 39cd76ce authored by Anton Bikineev's avatar Anton Bikineev Committed by V8 LUCI CQ

cppgc: Free up memory taken by SweptPageState

For large working set, the sweeper metadata can significantly increase.
Currently, the backing of swept_unfinalized_pages never gets freed,
which causes about 300KB of memory be occupied (checked on
Speedometer2). The CL makes sure to shrink (actually free) the backing
after each GC cycle.

Bug: chromium:1249550
Change-Id: I7c7e5248983960a498afc252a344fa71cb1444c3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3295347
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Auto-Submit: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78029}
parent 8f3e53b8
......@@ -611,9 +611,15 @@ class PrepareForSweepVisitor final
PrepareForSweepVisitor(SpaceStates* states,
CompactableSpaceHandling compactable_space_handling)
: states_(states),
compactable_space_handling_(compactable_space_handling) {}
compactable_space_handling_(compactable_space_handling) {
DCHECK_NOT_NULL(states);
}
void Run(RawHeap& raw_heap) { Traverse(raw_heap); }
void Run(RawHeap& raw_heap) {
DCHECK(states_->empty());
*states_ = SpaceStates(raw_heap.size());
Traverse(raw_heap);
}
protected:
bool VisitNormalPageSpace(NormalPageSpace& space) {
......@@ -655,9 +661,7 @@ class Sweeper::SweeperImpl final {
public:
SweeperImpl(RawHeap& heap, StatsCollector* stats_collector)
: heap_(heap),
stats_collector_(stats_collector),
space_states_(heap.size()) {}
: heap_(heap), stats_collector_(stats_collector) {}
~SweeperImpl() { CancelSweepers(); }
......@@ -777,6 +781,10 @@ class Sweeper::SweeperImpl final {
void FinalizeSweep() {
// Synchronize with the concurrent sweeper and call remaining finalizers.
SynchronizeAndFinalizeConcurrentSweeping();
// Clear space taken up by sweeper metadata.
space_states_.clear();
platform_ = nullptr;
is_in_progress_ = false;
notify_done_pending_ = true;
......
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