From 305c3e30c6aea9c05a1abec35eb5f7e09f716348 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Mon, 13 Jun 2022 18:46:37 +0000 Subject: [PATCH] [vm, gc] Remove the growth policy's hard limit when concurrent marking is available. Instead, impose back-pressure by making mutators assist with marking as they allocate. Synchronous marking may still occur if the heap grows to --old_gen_heap_size or the OS is out of memory. TEST=ci Bug: https://github.com/dart-lang/sdk/issues/47492 Change-Id: I2538f9e9b6d67bbbca0951d5162075a950658380 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246180 Reviewed-by: Siva Annamalai Reviewed-by: Martin Kustermann Commit-Queue: Ryan Macnak --- runtime/vm/heap/heap.cc | 7 ++++++- runtime/vm/heap/pages.cc | 20 +++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/runtime/vm/heap/heap.cc b/runtime/vm/heap/heap.cc index 9475b4f28ed..0c943fadebe 100644 --- a/runtime/vm/heap/heap.cc +++ b/runtime/vm/heap/heap.cc @@ -565,7 +565,12 @@ void Heap::CheckConcurrentMarking(Thread* thread, GCReason reason) { switch (phase) { case PageSpace::kMarking: - // TODO(rmacnak): Have this thread help with marking. + // TODO(rmacnak): Make the allocator of a large page mark size equals to + // the large page? + COMPILE_ASSERT(kOldPageSize == 512 * KB); + COMPILE_ASSERT(kNewPageSize == 512 * KB); + old_space_.IncrementalMarkWithSizeBudget(512 * KB); + return; case PageSpace::kSweepingLarge: case PageSpace::kSweepingRegular: return; // Busy. diff --git a/runtime/vm/heap/pages.cc b/runtime/vm/heap/pages.cc index e7f1933ffee..dbd960ac5f1 100644 --- a/runtime/vm/heap/pages.cc +++ b/runtime/vm/heap/pages.cc @@ -1674,19 +1674,17 @@ void PageSpaceController::RecordUpdate(SpaceUsage before, after.CombinedUsedInWords() + (kOldPageSizeInWords * growth_in_pages); #if defined(TARGET_ARCH_IA32) - // No concurrent marking. - soft_gc_threshold_in_words_ = threshold; - hard_gc_threshold_in_words_ = threshold; + bool concurrent_mark = false; #else - // Start concurrent marking when old-space has less than half of new-space - // available or less than 5% available. - // Note that heap_ can be null in some unit tests. - const intptr_t new_space = - heap_ == nullptr ? 0 : heap_->new_space()->CapacityInWords(); - const intptr_t headroom = Utils::Maximum(new_space / 2, threshold / 20); - soft_gc_threshold_in_words_ = threshold; - hard_gc_threshold_in_words_ = threshold + headroom; + bool concurrent_mark = FLAG_concurrent_mark && (FLAG_marker_tasks != 0); #endif + if (concurrent_mark) { + soft_gc_threshold_in_words_ = threshold; + hard_gc_threshold_in_words_ = kIntptrMax / kWordSize; + } else { + soft_gc_threshold_in_words_ = kIntptrMax / kWordSize; + hard_gc_threshold_in_words_ = threshold; + } // Set a tight idle threshold. idle_gc_threshold_in_words_ =