Reviewers: ulan, Erik Corry Chromium.org,
Description:
Make sure that idle scavenges are just performed when enough objects are
allocated in new space.
BUG=
Please review this at https://codereview.chromium.org/1138643003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+24, -2 lines):
M src/heap/gc-idle-time-handler.h
M src/heap/gc-idle-time-handler.cc
M test/unittests/heap/gc-idle-time-handler-unittest.cc
Index: src/heap/gc-idle-time-handler.cc
diff --git a/src/heap/gc-idle-time-handler.cc
b/src/heap/gc-idle-time-handler.cc
index
19c9dab668299b13b14fdf05c0dfd106d25f5a4c..ba456cf13e70f6f82550ab1ff35a0f836bb17e80
100644
--- a/src/heap/gc-idle-time-handler.cc
+++ b/src/heap/gc-idle-time-handler.cc
@@ -131,10 +131,17 @@ bool GCIdleTimeHandler::ShouldDoScavenge(
// 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 *
kTimeUntilNextIdleEvent;
- if (adjust_limit > new_space_allocation_limit)
+ if (adjust_limit > new_space_allocation_limit) {
new_space_allocation_limit = 0;
- else
+ } else {
new_space_allocation_limit -= adjust_limit;
+ }
+ }
+
+ // The allocated new space limit to trigger a Scavange has to be at least
+ // kMinimumNewSpaceSizeToPerformScavenge.
+ if (new_space_allocation_limit < kMinimumNewSpaceSizeToPerformScavenge) {
+ new_space_allocation_limit = kMinimumNewSpaceSizeToPerformScavenge;
}
if (scavenge_speed_in_bytes_per_ms == 0) {
Index: src/heap/gc-idle-time-handler.h
diff --git a/src/heap/gc-idle-time-handler.h
b/src/heap/gc-idle-time-handler.h
index
3beee164f449ff25d8623f204f05696dd10b34bd..e76178b7e676b547dcddf4d4b0e5b0d83f23cde4
100644
--- a/src/heap/gc-idle-time-handler.h
+++ b/src/heap/gc-idle-time-handler.h
@@ -136,6 +136,9 @@ class GCIdleTimeHandler {
// lower bound for the scavenger speed.
static const size_t kInitialConservativeScavengeSpeed = 100 * KB;
+ // The minimum size of allocated new space objects to trigger a scavenge.
+ static const size_t kMinimumNewSpaceSizeToPerformScavenge = MB / 2;
+
// If contexts are disposed at a higher rate a full gc is triggered.
static const double kHighContextDisposalRate;
Index: test/unittests/heap/gc-idle-time-handler-unittest.cc
diff --git a/test/unittests/heap/gc-idle-time-handler-unittest.cc
b/test/unittests/heap/gc-idle-time-handler-unittest.cc
index
011fdc0c7849c91f359d1cf45fa25a404717028f..357b08f88108117d8c74d91ddbf6c42df215708c
100644
--- a/test/unittests/heap/gc-idle-time-handler-unittest.cc
+++ b/test/unittests/heap/gc-idle-time-handler-unittest.cc
@@ -219,6 +219,18 @@ TEST_F(GCIdleTimeHandlerTest,
DoScavengeHighScavengeSpeed) {
}
+TEST_F(GCIdleTimeHandlerTest, DoNotScavengeSmallNewSpaceSize) {
+ GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
+ heap_state.used_new_space_size = (MB / 2) - 1;
+ heap_state.scavenge_speed_in_bytes_per_ms = kNewSpaceCapacity;
+ int idle_time_ms = 16;
+ EXPECT_FALSE(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, ShouldDoMarkCompact) {
size_t idle_time_ms = GCIdleTimeHandler::kMaxScheduledIdleTime;
EXPECT_TRUE(GCIdleTimeHandler::ShouldDoMarkCompact(idle_time_ms, 0, 0));
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.