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

Unified Diff: test/unittests/heap/memory-reducer-unittest.cc

Issue 1262363002: Ensure the memory reduces makes progress. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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/memory-reducer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/heap/memory-reducer-unittest.cc
diff --git a/test/unittests/heap/memory-reducer-unittest.cc b/test/unittests/heap/memory-reducer-unittest.cc
index 6a2bf2a87f327a2317160fa82c398e452f1b9d6d..ce11c4714035bc7bd33c1b6246b1f58a4c3b7361 100644
--- a/test/unittests/heap/memory-reducer-unittest.cc
+++ b/test/unittests/heap/memory-reducer-unittest.cc
@@ -12,19 +12,19 @@ namespace v8 {
namespace internal {
MemoryReducer::State DoneState() {
- return MemoryReducer::State(MemoryReducer::kDone, 0, 0.0);
+ return MemoryReducer::State(MemoryReducer::kDone, 0, 0.0, 1.0);
}
MemoryReducer::State WaitState(int started_gcs, double next_gc_start_ms) {
return MemoryReducer::State(MemoryReducer::kWait, started_gcs,
- next_gc_start_ms);
+ next_gc_start_ms, 1.0);
}
MemoryReducer::State RunState(int started_gcs, double next_gc_start_ms) {
return MemoryReducer::State(MemoryReducer::kRun, started_gcs,
- next_gc_start_ms);
+ next_gc_start_ms, 1.0);
}
@@ -114,20 +114,23 @@ TEST(MemoryReducer, FromDoneToWait) {
MemoryReducer::State state0(DoneState()), state1(DoneState());
- state1 = MemoryReducer::Step(state0, MarkCompactEventGarbageLeft(0));
+ state1 = MemoryReducer::Step(state0, MarkCompactEventGarbageLeft(2));
EXPECT_EQ(MemoryReducer::kWait, state1.action);
- EXPECT_EQ(MemoryReducer::kLongDelayMs, state1.next_gc_start_ms);
+ EXPECT_EQ(MemoryReducer::kLongDelayMs + 2, state1.next_gc_start_ms);
EXPECT_EQ(0, state1.started_gcs);
+ EXPECT_EQ(2, state1.last_gc_time_ms);
- state1 = MemoryReducer::Step(state0, MarkCompactEventNoGarbageLeft(0));
+ state1 = MemoryReducer::Step(state0, MarkCompactEventNoGarbageLeft(2));
EXPECT_EQ(MemoryReducer::kWait, state1.action);
- EXPECT_EQ(MemoryReducer::kLongDelayMs, state1.next_gc_start_ms);
+ EXPECT_EQ(MemoryReducer::kLongDelayMs + 2, state1.next_gc_start_ms);
EXPECT_EQ(0, state1.started_gcs);
+ EXPECT_EQ(2, state1.last_gc_time_ms);
state1 = MemoryReducer::Step(state0, ContextDisposedEvent(0));
EXPECT_EQ(MemoryReducer::kWait, state1.action);
EXPECT_EQ(MemoryReducer::kLongDelayMs, state1.next_gc_start_ms);
EXPECT_EQ(0, state1.started_gcs);
+ EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms);
}
@@ -161,11 +164,13 @@ TEST(MemoryReducer, FromWaitToWait) {
EXPECT_EQ(MemoryReducer::kWait, state1.action);
EXPECT_EQ(2000 + MemoryReducer::kLongDelayMs, state1.next_gc_start_ms);
EXPECT_EQ(state0.started_gcs, state1.started_gcs);
+ EXPECT_EQ(2000, state1.last_gc_time_ms);
state1 = MemoryReducer::Step(state0, MarkCompactEventNoGarbageLeft(2000));
EXPECT_EQ(MemoryReducer::kWait, state1.action);
EXPECT_EQ(2000 + MemoryReducer::kLongDelayMs, state1.next_gc_start_ms);
EXPECT_EQ(state0.started_gcs, state1.started_gcs);
+ EXPECT_EQ(2000, state1.last_gc_time_ms);
state1 = MemoryReducer::Step(state0, BackgroundIdleNotificationEvent(2000));
EXPECT_EQ(MemoryReducer::kWait, state1.action);
@@ -178,6 +183,23 @@ TEST(MemoryReducer, FromWaitToWait) {
EXPECT_EQ(state0.next_gc_start_ms, state1.next_gc_start_ms);
EXPECT_EQ(state0.started_gcs, state1.started_gcs);
+ state0.last_gc_time_ms = 0;
+ state1 = MemoryReducer::Step(
+ state0,
+ TimerEventHighAllocationRate(MemoryReducer::kWatchdogDelayMs + 1));
+ EXPECT_EQ(MemoryReducer::kWait, state1.action);
+ EXPECT_EQ(MemoryReducer::kWatchdogDelayMs + 1 + MemoryReducer::kLongDelayMs,
+ state1.next_gc_start_ms);
+ EXPECT_EQ(state0.started_gcs, state1.started_gcs);
+ EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms);
+
+ state0.last_gc_time_ms = 1;
+ state1 = MemoryReducer::Step(state0, TimerEventHighAllocationRate(2000));
+ EXPECT_EQ(MemoryReducer::kWait, state1.action);
+ EXPECT_EQ(2000 + MemoryReducer::kLongDelayMs, state1.next_gc_start_ms);
+ EXPECT_EQ(state0.started_gcs, state1.started_gcs);
+ EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms);
+
state0.started_gcs = MemoryReducer::kMaxNumberOfGCs;
state1 = MemoryReducer::Step(state0, BackgroundIdleNotificationEvent(2000));
EXPECT_EQ(MemoryReducer::kWait, state1.action);
@@ -196,6 +218,14 @@ TEST(MemoryReducer, FromWaitToRun) {
EXPECT_EQ(MemoryReducer::kRun, state1.action);
EXPECT_EQ(0, state1.next_gc_start_ms);
EXPECT_EQ(state0.started_gcs + 1, state1.started_gcs);
+
+ state1 = MemoryReducer::Step(
+ state0,
+ TimerEventHighAllocationRate(MemoryReducer::kWatchdogDelayMs + 2));
+ EXPECT_EQ(MemoryReducer::kRun, state1.action);
+ EXPECT_EQ(0, state1.next_gc_start_ms);
+ EXPECT_EQ(state0.started_gcs + 1, state1.started_gcs);
+ EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms);
}
@@ -210,16 +240,19 @@ TEST(MemoryReducer, FromWaitToDone) {
EXPECT_EQ(MemoryReducer::kDone, state1.action);
EXPECT_EQ(0, state1.next_gc_start_ms);
EXPECT_EQ(0, state1.started_gcs);
+ EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms);
state1 = MemoryReducer::Step(state0, TimerEventHighAllocationRate(2000));
EXPECT_EQ(MemoryReducer::kDone, state1.action);
EXPECT_EQ(0, state1.next_gc_start_ms);
EXPECT_EQ(0, state1.started_gcs);
+ EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms);
state1 = MemoryReducer::Step(state0, TimerEventPendingGC(2000));
EXPECT_EQ(MemoryReducer::kDone, state1.action);
EXPECT_EQ(0, state1.next_gc_start_ms);
EXPECT_EQ(0, state1.started_gcs);
+ EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms);
}
@@ -232,21 +265,25 @@ TEST(MemoryReducer, FromRunToRun) {
EXPECT_EQ(MemoryReducer::kRun, state1.action);
EXPECT_EQ(state0.next_gc_start_ms, state1.next_gc_start_ms);
EXPECT_EQ(state0.started_gcs, state1.started_gcs);
+ EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms);
state1 = MemoryReducer::Step(state0, TimerEventHighAllocationRate(2000));
EXPECT_EQ(MemoryReducer::kRun, state1.action);
EXPECT_EQ(state0.next_gc_start_ms, state1.next_gc_start_ms);
EXPECT_EQ(state0.started_gcs, state1.started_gcs);
+ EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms);
state1 = MemoryReducer::Step(state0, TimerEventPendingGC(2000));
EXPECT_EQ(MemoryReducer::kRun, state1.action);
EXPECT_EQ(state0.next_gc_start_ms, state1.next_gc_start_ms);
EXPECT_EQ(state0.started_gcs, state1.started_gcs);
+ EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms);
state1 = MemoryReducer::Step(state0, ContextDisposedEvent(2000));
EXPECT_EQ(MemoryReducer::kRun, state1.action);
EXPECT_EQ(state0.next_gc_start_ms, state1.next_gc_start_ms);
EXPECT_EQ(state0.started_gcs, state1.started_gcs);
+ EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms);
}
@@ -259,13 +296,14 @@ TEST(MemoryReducer, FromRunToDone) {
EXPECT_EQ(MemoryReducer::kDone, state1.action);
EXPECT_EQ(0, state1.next_gc_start_ms);
EXPECT_EQ(0, state1.started_gcs);
+ EXPECT_EQ(2000, state1.last_gc_time_ms);
state0.started_gcs = MemoryReducer::kMaxNumberOfGCs;
state1 = MemoryReducer::Step(state0, MarkCompactEventGarbageLeft(2000));
EXPECT_EQ(MemoryReducer::kDone, state1.action);
EXPECT_EQ(0, state1.next_gc_start_ms);
- EXPECT_EQ(0, state1.started_gcs);
+ EXPECT_EQ(2000, state1.last_gc_time_ms);
}
@@ -278,6 +316,7 @@ TEST(MemoryReducer, FromRunToWait) {
EXPECT_EQ(MemoryReducer::kWait, state1.action);
EXPECT_EQ(2000 + MemoryReducer::kShortDelayMs, state1.next_gc_start_ms);
EXPECT_EQ(state0.started_gcs, state1.started_gcs);
+ EXPECT_EQ(2000, state1.last_gc_time_ms);
state0.started_gcs = 1;
@@ -285,6 +324,7 @@ TEST(MemoryReducer, FromRunToWait) {
EXPECT_EQ(MemoryReducer::kWait, state1.action);
EXPECT_EQ(2000 + MemoryReducer::kShortDelayMs, state1.next_gc_start_ms);
EXPECT_EQ(state0.started_gcs, state1.started_gcs);
+ EXPECT_EQ(2000, state1.last_gc_time_ms);
}
} // namespace internal
« no previous file with comments | « src/heap/memory-reducer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698