Commit 3caa3cc3 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] Consider global memory when bailing out of incremental marking

Previously, the early bailout for incremental marking only considered
V8's memory which does not work when a big porition of memory is
actually allocated globally.

Bug: chromium:948807
Change-Id: Ie85c3c68f2b677ef87aba9e70ae74e65783a1fac
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1680542Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62420}
parent ad68a376
......@@ -4684,8 +4684,7 @@ Heap::IncrementalMarkingLimit Heap::IncrementalMarkingLimitReached() {
if (FLAG_stress_incremental_marking) {
return IncrementalMarkingLimit::kHardLimit;
}
if (OldGenerationSizeOfObjects() <=
IncrementalMarking::kActivationThreshold) {
if (incremental_marking()->IsBelowActivationThresholds()) {
// Incremental marking is disabled or it is too early to start.
return IncrementalMarkingLimit::kNoLimit;
}
......
......@@ -1703,6 +1703,8 @@ class Heap {
return old_generation_allocation_limit_;
}
size_t global_allocation_limit() const { return global_allocation_limit_; }
bool always_allocate() { return always_allocate_scope_count_ != 0; }
V8_EXPORT_PRIVATE bool CanExpandOldGeneration(size_t size);
......
......@@ -246,6 +246,10 @@ bool IncrementalMarking::CanBeActivated() {
!heap_->isolate()->serializer_enabled();
}
bool IncrementalMarking::IsBelowActivationThresholds() const {
return heap_->OldGenerationSizeOfObjects() <= kV8ActivationThreshold &&
heap_->GlobalSizeOfObjects() <= kGlobalActivationThreshold;
}
void IncrementalMarking::Deactivate() {
DeactivateIncrementalWriteBarrier();
......@@ -253,16 +257,23 @@ void IncrementalMarking::Deactivate() {
void IncrementalMarking::Start(GarbageCollectionReason gc_reason) {
if (FLAG_trace_incremental_marking) {
int old_generation_size_mb =
static_cast<int>(heap()->OldGenerationSizeOfObjects() / MB);
int old_generation_limit_mb =
static_cast<int>(heap()->old_generation_allocation_limit() / MB);
const size_t old_generation_size_mb =
heap()->OldGenerationSizeOfObjects() / MB;
const size_t old_generation_limit_mb =
heap()->old_generation_allocation_limit() / MB;
const size_t global_size_mb = heap()->GlobalSizeOfObjects() / MB;
const size_t global_limit_mb = heap()->global_allocation_limit() / MB;
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Start (%s): old generation %dMB, limit %dMB, "
"slack %dMB\n",
"[IncrementalMarking] Start (%s): (size/limit/slack) v8: %zuMB / %zuMB "
"/ %zuMB global: %zuMB / %zuMB / %zuMB\n",
Heap::GarbageCollectionReasonToString(gc_reason),
old_generation_size_mb, old_generation_limit_mb,
Max(0, old_generation_limit_mb - old_generation_size_mb));
old_generation_size_mb > old_generation_limit_mb
? 0
: old_generation_limit_mb - old_generation_size_mb,
global_size_mb, global_limit_mb,
global_size_mb > global_limit_mb ? 0
: global_limit_mb - global_size_mb);
}
DCHECK(FLAG_incremental_marking);
DCHECK(state_ == STOPPED);
......
......@@ -79,9 +79,11 @@ class V8_EXPORT_PRIVATE IncrementalMarking {
static constexpr double kMaxStepSizeInMs = 5;
#ifndef DEBUG
static const intptr_t kActivationThreshold = 8 * MB;
static constexpr size_t kV8ActivationThreshold = 8 * MB;
static constexpr size_t kGlobalActivationThreshold = 16 * MB;
#else
static const intptr_t kActivationThreshold = 0;
static constexpr size_t kV8ActivationThreshold = 0;
static constexpr size_t kGlobalActivationThreshold = 0;
#endif
#ifdef V8_CONCURRENT_MARKING
......@@ -248,6 +250,8 @@ class V8_EXPORT_PRIVATE IncrementalMarking {
// generation.
void EnsureBlackAllocated(Address allocated, size_t size);
bool IsBelowActivationThresholds() const;
private:
class Observer : public AllocationObserver {
public:
......
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