Commit 5ae7258c authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

heap: Fix marking regression when not using embedder heap tracer

When not being embedded, there's no need to try to share time with the
embedder.

Additionally, avoid too small step sizes.

Bug: chromium:1044630, chromium:1048631
Change-Id: I227bfd120b5ce1976935d27c2140263f7364eb51
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2036085
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66115}
parent 28abde86
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace {
constexpr double kMinSharableStepSizeInBytes = 4 * KB;
}
void IncrementalMarking::Observer::Step(int bytes_allocated, Address addr, void IncrementalMarking::Observer::Step(int bytes_allocated, Address addr,
size_t size) { size_t size) {
Heap* heap = incremental_marking_->heap(); Heap* heap = incremental_marking_->heap();
...@@ -1086,14 +1090,22 @@ StepResult IncrementalMarking::Step(double max_step_size_in_ms, ...@@ -1086,14 +1090,22 @@ StepResult IncrementalMarking::Step(double max_step_size_in_ms,
max_step_size_in_ms, max_step_size_in_ms,
heap()->tracer()->IncrementalMarkingSpeedInBytesPerMillisecond()); heap()->tracer()->IncrementalMarkingSpeedInBytesPerMillisecond());
bytes_to_process = Min(ComputeStepSizeInBytes(step_origin), max_step_size); bytes_to_process = Min(ComputeStepSizeInBytes(step_origin), max_step_size);
const bool only_single_step = bytes_to_process == 0;
bytes_to_process = Max(bytes_to_process, kMinStepSizeInBytes); bytes_to_process = Max(bytes_to_process, kMinStepSizeInBytes);
size_t remaining_bytes = bytes_to_process; size_t remaining_bytes = bytes_to_process;
const bool using_embedder_tracer =
heap_->local_embedder_heap_tracer()->InUse();
StepResult embedder_result, v8_result; StepResult embedder_result, v8_result;
do { do {
v8_result = embedder_result = StepResult::kMoreWorkRemaining; v8_result = StepResult::kMoreWorkRemaining;
embedder_result = using_embedder_tracer ? StepResult::kMoreWorkRemaining
: StepResult::kNoImmediateWork;
const size_t v8_bytes_to_process =
using_embedder_tracer && remaining_bytes > kMinSharableStepSizeInBytes
? remaining_bytes / 2
: remaining_bytes;
size_t v8_bytes_processed_step = size_t v8_bytes_processed_step =
collector_->ProcessMarkingWorklist(remaining_bytes / 2); collector_->ProcessMarkingWorklist(v8_bytes_to_process);
v8_bytes_processed += v8_bytes_processed_step; v8_bytes_processed += v8_bytes_processed_step;
remaining_bytes = remaining_bytes > v8_bytes_processed_step remaining_bytes = remaining_bytes > v8_bytes_processed_step
? remaining_bytes - v8_bytes_processed_step ? remaining_bytes - v8_bytes_processed_step
...@@ -1103,7 +1115,7 @@ StepResult IncrementalMarking::Step(double max_step_size_in_ms, ...@@ -1103,7 +1115,7 @@ StepResult IncrementalMarking::Step(double max_step_size_in_ms,
: StepResult::kMoreWorkRemaining; : StepResult::kMoreWorkRemaining;
// Allow the embedder to make marking progress, assuming it gets a share // Allow the embedder to make marking progress, assuming it gets a share
// of the time for handling |bytes_to_process|. // of the time for handling |bytes_to_process|.
if (remaining_bytes > 0) { if (using_embedder_tracer && remaining_bytes > 0) {
const double marking_speed = const double marking_speed =
heap_->tracer()->IncrementalMarkingSpeedInBytesPerMillisecond(); heap_->tracer()->IncrementalMarkingSpeedInBytesPerMillisecond();
double step_duration; double step_duration;
...@@ -1119,10 +1131,10 @@ StepResult IncrementalMarking::Step(double max_step_size_in_ms, ...@@ -1119,10 +1131,10 @@ StepResult IncrementalMarking::Step(double max_step_size_in_ms,
} else { } else {
break; break;
} }
} while ((v8_result == StepResult::kMoreWorkRemaining || } while (!only_single_step &&
(v8_result == StepResult::kMoreWorkRemaining ||
embedder_result == StepResult::kMoreWorkRemaining) && embedder_result == StepResult::kMoreWorkRemaining) &&
remaining_bytes > 0); (remaining_bytes > 0));
bytes_marked_ += v8_bytes_processed; bytes_marked_ += v8_bytes_processed;
combined_result = CombineStepResults(v8_result, embedder_result); combined_result = CombineStepResults(v8_result, embedder_result);
......
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