Commit 4f9aba5c authored by Etienne Pierre-doray's avatar Etienne Pierre-doray Committed by V8 LUCI CQ

[gc] Delay start of memory reducer.

Creates a feature (flag): transition from Done -> Wait
schedules a timer after 30s instead of 8s.
In local benchmark, this reduces by 50% cpu time spent doing
incremental marking and sweeping.

Bug: chromium:1330940
Change-Id: Iff9121243b88d0ed87d0b921e285ece52a83eaa9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3696168
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81283}
parent dd7a9e31
...@@ -1416,6 +1416,9 @@ DEFINE_BOOL( ...@@ -1416,6 +1416,9 @@ DEFINE_BOOL(
DEFINE_BOOL(gc_experiment_less_compaction, false, DEFINE_BOOL(gc_experiment_less_compaction, false,
"less compaction in non-memory reducing mode") "less compaction in non-memory reducing mode")
DEFINE_INT(gc_memory_reducer_start_delay_ms, 8000,
"Delay before memory reducer start")
DEFINE_BOOL(disable_abortjs, false, "disables AbortJS runtime function") DEFINE_BOOL(disable_abortjs, false, "disables AbortJS runtime function")
DEFINE_BOOL(randomize_all_allocations, false, DEFINE_BOOL(randomize_all_allocations, false,
......
...@@ -156,17 +156,14 @@ MemoryReducer::State MemoryReducer::Step(const State& state, ...@@ -156,17 +156,14 @@ MemoryReducer::State MemoryReducer::Step(const State& state,
state.committed_memory_at_last_run + kCommittedMemoryDelta)) { state.committed_memory_at_last_run + kCommittedMemoryDelta)) {
return state; return state;
} else { } else {
return State(kWait, 0, event.time_ms + kLongDelayMs, return State(kWait, 0, event.time_ms + kLongDelayMs, event.time_ms,
event.type == kMarkCompact ? event.time_ms
: state.last_gc_time_ms,
0); 0);
} }
} else { } else {
DCHECK_EQ(kPossibleGarbage, event.type); DCHECK_EQ(kPossibleGarbage, event.type);
return State( return State(kWait, 0,
kWait, 0, event.time_ms + kLongDelayMs, event.time_ms + FLAG_gc_memory_reducer_start_delay_ms,
event.type == kMarkCompact ? event.time_ms : state.last_gc_time_ms, state.last_gc_time_ms, 0);
0);
} }
case kWait: case kWait:
switch (event.type) { switch (event.type) {
......
...@@ -166,6 +166,7 @@ class V8_EXPORT_PRIVATE MemoryReducer { ...@@ -166,6 +166,7 @@ class V8_EXPORT_PRIVATE MemoryReducer {
State state_; State state_;
unsigned int js_calls_counter_; unsigned int js_calls_counter_;
double js_calls_sample_time_ms_; double js_calls_sample_time_ms_;
int start_delay_ms_ = false;
// Used in cctest. // Used in cctest.
friend class heap::HeapTester; friend class heap::HeapTester;
......
...@@ -123,7 +123,7 @@ TEST(MemoryReducer, FromDoneToWait) { ...@@ -123,7 +123,7 @@ TEST(MemoryReducer, FromDoneToWait) {
state0, state0,
MarkCompactEventGarbageLeft(2, MemoryReducer::kCommittedMemoryDelta)); MarkCompactEventGarbageLeft(2, MemoryReducer::kCommittedMemoryDelta));
EXPECT_EQ(MemoryReducer::kWait, state1.action); EXPECT_EQ(MemoryReducer::kWait, state1.action);
EXPECT_EQ(MemoryReducer::kLongDelayMs + 2, state1.next_gc_start_ms); EXPECT_EQ(FLAG_gc_memory_reducer_start_delay_ms + 2, state1.next_gc_start_ms);
EXPECT_EQ(0, state1.started_gcs); EXPECT_EQ(0, state1.started_gcs);
EXPECT_EQ(2, state1.last_gc_time_ms); EXPECT_EQ(2, state1.last_gc_time_ms);
...@@ -131,13 +131,13 @@ TEST(MemoryReducer, FromDoneToWait) { ...@@ -131,13 +131,13 @@ TEST(MemoryReducer, FromDoneToWait) {
state0, state0,
MarkCompactEventNoGarbageLeft(2, MemoryReducer::kCommittedMemoryDelta)); MarkCompactEventNoGarbageLeft(2, MemoryReducer::kCommittedMemoryDelta));
EXPECT_EQ(MemoryReducer::kWait, state1.action); EXPECT_EQ(MemoryReducer::kWait, state1.action);
EXPECT_EQ(MemoryReducer::kLongDelayMs + 2, state1.next_gc_start_ms); EXPECT_EQ(FLAG_gc_memory_reducer_start_delay_ms + 2, state1.next_gc_start_ms);
EXPECT_EQ(0, state1.started_gcs); EXPECT_EQ(0, state1.started_gcs);
EXPECT_EQ(2, state1.last_gc_time_ms); EXPECT_EQ(2, state1.last_gc_time_ms);
state1 = MemoryReducer::Step(state0, PossibleGarbageEvent(0)); state1 = MemoryReducer::Step(state0, PossibleGarbageEvent(0));
EXPECT_EQ(MemoryReducer::kWait, state1.action); EXPECT_EQ(MemoryReducer::kWait, state1.action);
EXPECT_EQ(MemoryReducer::kLongDelayMs, state1.next_gc_start_ms); EXPECT_EQ(FLAG_gc_memory_reducer_start_delay_ms, state1.next_gc_start_ms);
EXPECT_EQ(0, state1.started_gcs); EXPECT_EQ(0, state1.started_gcs);
EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms); EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms);
...@@ -147,7 +147,7 @@ TEST(MemoryReducer, FromDoneToWait) { ...@@ -147,7 +147,7 @@ TEST(MemoryReducer, FromDoneToWait) {
2, static_cast<size_t>( 2, static_cast<size_t>(
1000 * MB * MemoryReducer::kCommittedMemoryFactor))); 1000 * MB * MemoryReducer::kCommittedMemoryFactor)));
EXPECT_EQ(MemoryReducer::kWait, state1.action); EXPECT_EQ(MemoryReducer::kWait, state1.action);
EXPECT_EQ(MemoryReducer::kLongDelayMs + 2, state1.next_gc_start_ms); EXPECT_EQ(FLAG_gc_memory_reducer_start_delay_ms + 2, state1.next_gc_start_ms);
EXPECT_EQ(0, state1.started_gcs); EXPECT_EQ(0, state1.started_gcs);
EXPECT_EQ(2, state1.last_gc_time_ms); EXPECT_EQ(2, state1.last_gc_time_ms);
} }
......
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