Commit 52708b63 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Avoid full GC for large heaps.

BUG=chromium:738031

Change-Id: I98d1015caadd7214a7076f7b39a4514bfd908061
Reviewed-on: https://chromium-review.googlesource.com/555971Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46345}
parent 6407a3c0
......@@ -73,9 +73,11 @@ double GCIdleTimeHandler::EstimateFinalIncrementalMarkCompactTime(
}
bool GCIdleTimeHandler::ShouldDoContextDisposalMarkCompact(
int contexts_disposed, double contexts_disposal_rate) {
int contexts_disposed, double contexts_disposal_rate,
size_t size_of_objects) {
return contexts_disposed > 0 && contexts_disposal_rate > 0 &&
contexts_disposal_rate < kHighContextDisposalRate;
contexts_disposal_rate < kHighContextDisposalRate &&
size_of_objects <= kMaxHeapSizeForContextDisposalMarkCompact;
}
bool GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact(
......@@ -123,9 +125,9 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(double idle_time_in_ms,
GCIdleTimeHeapState heap_state) {
if (static_cast<int>(idle_time_in_ms) <= 0) {
if (heap_state.incremental_marking_stopped) {
if (ShouldDoContextDisposalMarkCompact(
heap_state.contexts_disposed,
heap_state.contexts_disposal_rate)) {
if (ShouldDoContextDisposalMarkCompact(heap_state.contexts_disposed,
heap_state.contexts_disposal_rate,
heap_state.size_of_objects)) {
return GCIdleTimeAction::FullGC();
}
}
......@@ -135,7 +137,8 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(double idle_time_in_ms,
// We are in a context disposal GC scenario. Don't do anything if we do not
// get the right idle signal.
if (ShouldDoContextDisposalMarkCompact(heap_state.contexts_disposed,
heap_state.contexts_disposal_rate)) {
heap_state.contexts_disposal_rate,
heap_state.size_of_objects)) {
return NothingOrDone(idle_time_in_ms);
}
......
......@@ -107,6 +107,8 @@ class V8_EXPORT_PRIVATE GCIdleTimeHandler {
// considered low
static const size_t kLowAllocationThroughput = 1000;
static const size_t kMaxHeapSizeForContextDisposalMarkCompact = 100 * MB;
// If contexts are disposed at a higher rate a full gc is triggered.
static const double kHighContextDisposalRate;
......@@ -136,7 +138,8 @@ class V8_EXPORT_PRIVATE GCIdleTimeHandler {
size_t size_of_objects, double mark_compact_speed_in_bytes_per_ms);
static bool ShouldDoContextDisposalMarkCompact(int context_disposed,
double contexts_disposal_rate);
double contexts_disposal_rate,
size_t size_of_objects);
static bool ShouldDoFinalIncrementalMarkCompact(
double idle_time_in_ms, size_t size_of_objects,
......
......@@ -24,6 +24,7 @@ class GCIdleTimeHandlerTest : public ::testing::Test {
result.contexts_disposed = 0;
result.contexts_disposal_rate = GCIdleTimeHandler::kHighContextDisposalRate;
result.incremental_marking_stopped = false;
result.size_of_objects = kSizeOfObjects;
return result;
}
......@@ -149,6 +150,17 @@ TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime2) {
EXPECT_EQ(DO_INCREMENTAL_STEP, action.type);
}
TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeLargeHeap) {
if (!handler()->Enabled()) return;
GCIdleTimeHeapState heap_state = DefaultHeapState();
heap_state.contexts_disposed = 1;
heap_state.contexts_disposal_rate = 1.0;
heap_state.incremental_marking_stopped = true;
heap_state.size_of_objects = 101 * MB;
double idle_time_ms = 0;
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
EXPECT_EQ(DO_NOTHING, action.type);
}
TEST_F(GCIdleTimeHandlerTest, IncrementalMarking1) {
if (!handler()->Enabled()) return;
......
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