Commit 9df592c1 authored by hpayer's avatar hpayer Committed by Commit bot

When allocation rate is low and we are close to the new space limit, we should...

When allocation rate is low and we are close to the new space limit, we should perform a scavenge during idle time.

BUG=chromium:517395
LOG=n

Review URL: https://codereview.chromium.org/1272573006

Cr-Commit-Position: refs/heads/master@{#30044}
parent d2bd9517
...@@ -129,10 +129,7 @@ bool GCIdleTimeHandler::ShouldDoScavenge( ...@@ -129,10 +129,7 @@ bool GCIdleTimeHandler::ShouldDoScavenge(
// We do not know the allocation throughput before the first scavenge. // We do not know the allocation throughput before the first scavenge.
// TODO(hpayer): Estimate allocation throughput before the first scavenge. // TODO(hpayer): Estimate allocation throughput before the first scavenge.
if (new_space_allocation_throughput_in_bytes_per_ms == 0) { if (new_space_allocation_throughput_in_bytes_per_ms > 0) {
new_space_allocation_limit =
static_cast<size_t>(new_space_size * kConservativeTimeRatio);
} else {
// We have to trigger scavenge before we reach the end of new space. // We have to trigger scavenge before we reach the end of new space.
size_t adjust_limit = new_space_allocation_throughput_in_bytes_per_ms * size_t adjust_limit = new_space_allocation_throughput_in_bytes_per_ms *
kTimeUntilNextIdleEvent; kTimeUntilNextIdleEvent;
...@@ -143,6 +140,13 @@ bool GCIdleTimeHandler::ShouldDoScavenge( ...@@ -143,6 +140,13 @@ bool GCIdleTimeHandler::ShouldDoScavenge(
} }
} }
if (new_space_allocation_throughput_in_bytes_per_ms <
kLowAllocationThroughput) {
new_space_allocation_limit =
Min(new_space_allocation_limit,
static_cast<size_t>(new_space_size * kConservativeTimeRatio));
}
// The allocated new space limit to trigger a scavange has to be at least // The allocated new space limit to trigger a scavange has to be at least
// kMinimumNewSpaceSizeToPerformScavenge. // kMinimumNewSpaceSizeToPerformScavenge.
if (new_space_allocation_limit < kMinimumNewSpaceSizeToPerformScavenge) { if (new_space_allocation_limit < kMinimumNewSpaceSizeToPerformScavenge) {
......
...@@ -124,6 +124,10 @@ class GCIdleTimeHandler { ...@@ -124,6 +124,10 @@ class GCIdleTimeHandler {
// no idle notification happens. // no idle notification happens.
static const size_t kTimeUntilNextIdleEvent = 100; static const size_t kTimeUntilNextIdleEvent = 100;
// An allocation throughput below kLowAllocationThroughput bytes/ms is
// considered low
static const size_t kLowAllocationThroughput = 1000;
// If we haven't recorded any scavenger events yet, we use a conservative // If we haven't recorded any scavenger events yet, we use a conservative
// lower bound for the scavenger speed. // lower bound for the scavenger speed.
static const size_t kInitialConservativeScavengeSpeed = 100 * KB; static const size_t kInitialConservativeScavengeSpeed = 100 * KB;
......
...@@ -156,6 +156,19 @@ TEST_F(GCIdleTimeHandlerTest, DoScavengeLowScavengeSpeed) { ...@@ -156,6 +156,19 @@ TEST_F(GCIdleTimeHandlerTest, DoScavengeLowScavengeSpeed) {
} }
TEST_F(GCIdleTimeHandlerTest, DoScavengeLowAllocationRate) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
heap_state.used_new_space_size = kNewSpaceCapacity;
heap_state.new_space_allocation_throughput_in_bytes_per_ms =
GCIdleTimeHandler::kLowAllocationThroughput - 1;
int idle_time_ms = 16;
EXPECT_TRUE(GCIdleTimeHandler::ShouldDoScavenge(
idle_time_ms, heap_state.new_space_capacity,
heap_state.used_new_space_size, heap_state.scavenge_speed_in_bytes_per_ms,
heap_state.new_space_allocation_throughput_in_bytes_per_ms));
}
TEST_F(GCIdleTimeHandlerTest, DoScavengeHighScavengeSpeed) { TEST_F(GCIdleTimeHandlerTest, DoScavengeHighScavengeSpeed) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
heap_state.used_new_space_size = kNewSpaceCapacity; heap_state.used_new_space_size = kNewSpaceCapacity;
......
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