Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Unified Diff: src/heap/gc-idle-time-handler-unittest.cc

Issue 573943004: Use allocation throughput to estimate next scavenge event in idle notification. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/gc-idle-time-handler.cc ('k') | src/heap/heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/gc-idle-time-handler-unittest.cc
diff --git a/src/heap/gc-idle-time-handler-unittest.cc b/src/heap/gc-idle-time-handler-unittest.cc
index 6a3a00b79feb71140275026311e4c7d7f03b825e..195a88dcc1fe79630b4ffae6ea67607479b57563 100644
--- a/src/heap/gc-idle-time-handler-unittest.cc
+++ b/src/heap/gc-idle-time-handler-unittest.cc
@@ -31,6 +31,8 @@ class GCIdleTimeHandlerTest : public ::testing::Test {
result.scavenge_speed_in_bytes_per_ms = kScavengeSpeed;
result.available_new_space_memory = kNewSpaceCapacity;
result.new_space_capacity = kNewSpaceCapacity;
+ result.new_space_allocation_throughput_in_bytes_per_ms =
+ kNewSpaceAllocationThroughput;
return result;
}
@@ -39,6 +41,7 @@ class GCIdleTimeHandlerTest : public ::testing::Test {
static const size_t kMarkingSpeed = 200 * KB;
static const size_t kScavengeSpeed = 100 * KB;
static const size_t kNewSpaceCapacity = 1 * MB;
+ static const size_t kNewSpaceAllocationThroughput = 10 * KB;
private:
GCIdleTimeHandler handler_;
@@ -121,6 +124,26 @@ TEST(GCIdleTimeHandler, EstimateScavengeTimeNonZero) {
}
+TEST(GCIdleTimeHandler, ScavangeMayHappenSoonInitial) {
+ size_t available = 100 * KB;
+ EXPECT_FALSE(GCIdleTimeHandler::ScavangeMayHappenSoon(available, 0));
+}
+
+
+TEST(GCIdleTimeHandler, ScavangeMayHappenSoonNonZeroFalse) {
+ size_t available = (GCIdleTimeHandler::kMaxFrameRenderingIdleTime + 1) * KB;
+ size_t speed = 1 * KB;
+ EXPECT_FALSE(GCIdleTimeHandler::ScavangeMayHappenSoon(available, speed));
+}
+
+
+TEST(GCIdleTimeHandler, ScavangeMayHappenSoonNonZeroTrue) {
+ size_t available = GCIdleTimeHandler::kMaxFrameRenderingIdleTime * KB;
+ size_t speed = 1 * KB;
+ EXPECT_TRUE(GCIdleTimeHandler::ScavangeMayHappenSoon(available, speed));
+}
+
+
TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeLargeIdleTime) {
GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
heap_state.contexts_disposed = 1;
@@ -267,5 +290,30 @@ TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop2) {
EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
}
+
+TEST_F(GCIdleTimeHandlerTest, Scavenge) {
+ GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
+ int idle_time_ms = 10;
+ heap_state.available_new_space_memory =
+ kNewSpaceAllocationThroughput * idle_time_ms;
+ GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
+ EXPECT_EQ(DO_SCAVENGE, action.type);
+}
+
+
+TEST_F(GCIdleTimeHandlerTest, ScavengeAndDone) {
+ GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
+ int idle_time_ms = 10;
+ heap_state.can_start_incremental_marking = false;
+ heap_state.incremental_marking_stopped = true;
+ heap_state.available_new_space_memory =
+ kNewSpaceAllocationThroughput * idle_time_ms;
+ GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
+ EXPECT_EQ(DO_SCAVENGE, action.type);
+ heap_state.available_new_space_memory = kNewSpaceCapacity;
+ action = handler()->Compute(idle_time_ms, heap_state);
+ EXPECT_EQ(DO_NOTHING, action.type);
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/heap/gc-idle-time-handler.cc ('k') | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698