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

Side by Side Diff: src/heap/memory-reducer.cc

Issue 1261373006: Grow heap slowly after running memory reducer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « src/heap/memory-reducer.h ('k') | test/unittests/heap/memory-reducer-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/heap/memory-reducer.h" 5 #include "src/heap/memory-reducer.h"
6 6
7 #include "src/flags.h" 7 #include "src/flags.h"
8 #include "src/heap/heap.h" 8 #include "src/heap/heap.h"
9 #include "src/utils.h" 9 #include "src/utils.h"
10 #include "src/v8.h" 10 #include "src/v8.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 return State( 128 return State(
129 kWait, 0, event.time_ms + kLongDelayMs, 129 kWait, 0, event.time_ms + kLongDelayMs,
130 event.type == kMarkCompact ? event.time_ms : state.last_gc_time_ms); 130 event.type == kMarkCompact ? event.time_ms : state.last_gc_time_ms);
131 } 131 }
132 case kWait: 132 case kWait:
133 switch (event.type) { 133 switch (event.type) {
134 case kContextDisposed: 134 case kContextDisposed:
135 return state; 135 return state;
136 case kTimer: 136 case kTimer:
137 if (state.started_gcs >= kMaxNumberOfGCs) { 137 if (state.started_gcs >= kMaxNumberOfGCs) {
138 return State(kDone, 0, 0.0, state.last_gc_time_ms); 138 return State(kDone, kMaxNumberOfGCs, 0.0, state.last_gc_time_ms);
139 } else if (event.can_start_incremental_gc && 139 } else if (event.can_start_incremental_gc &&
140 (event.low_allocation_rate || WatchdogGC(state, event))) { 140 (event.low_allocation_rate || WatchdogGC(state, event))) {
141 if (state.next_gc_start_ms <= event.time_ms) { 141 if (state.next_gc_start_ms <= event.time_ms) {
142 return State(kRun, state.started_gcs + 1, 0.0, 142 return State(kRun, state.started_gcs + 1, 0.0,
143 state.last_gc_time_ms); 143 state.last_gc_time_ms);
144 } else { 144 } else {
145 return state; 145 return state;
146 } 146 }
147 } else { 147 } else {
148 return State(kWait, state.started_gcs, event.time_ms + kLongDelayMs, 148 return State(kWait, state.started_gcs, event.time_ms + kLongDelayMs,
(...skipping 13 matching lines...) Expand all
162 } 162 }
163 case kRun: 163 case kRun:
164 if (event.type != kMarkCompact) { 164 if (event.type != kMarkCompact) {
165 return state; 165 return state;
166 } else { 166 } else {
167 if (state.started_gcs < kMaxNumberOfGCs && 167 if (state.started_gcs < kMaxNumberOfGCs &&
168 (event.next_gc_likely_to_collect_more || state.started_gcs == 1)) { 168 (event.next_gc_likely_to_collect_more || state.started_gcs == 1)) {
169 return State(kWait, state.started_gcs, event.time_ms + kShortDelayMs, 169 return State(kWait, state.started_gcs, event.time_ms + kShortDelayMs,
170 event.time_ms); 170 event.time_ms);
171 } else { 171 } else {
172 return State(kDone, 0, 0.0, event.time_ms); 172 return State(kDone, kMaxNumberOfGCs, 0.0, event.time_ms);
173 } 173 }
174 } 174 }
175 } 175 }
176 UNREACHABLE(); 176 UNREACHABLE();
177 return State(kDone, 0, 0, 0.0); // Make the compiler happy. 177 return State(kDone, 0, 0, 0.0); // Make the compiler happy.
178 } 178 }
179 179
180 180
181 void MemoryReducer::ScheduleTimer(double delay_ms) { 181 void MemoryReducer::ScheduleTimer(double delay_ms) {
182 DCHECK(delay_ms > 0); 182 DCHECK(delay_ms > 0);
183 // Leave some room for precision error in task scheduler. 183 // Leave some room for precision error in task scheduler.
184 const double kSlackMs = 100; 184 const double kSlackMs = 100;
185 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap()->isolate()); 185 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap()->isolate());
186 auto timer_task = new MemoryReducer::TimerTask(this); 186 auto timer_task = new MemoryReducer::TimerTask(this);
187 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread( 187 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread(
188 isolate, timer_task, (delay_ms + kSlackMs) / 1000.0); 188 isolate, timer_task, (delay_ms + kSlackMs) / 1000.0);
189 } 189 }
190 190
191 191
192 void MemoryReducer::TearDown() { state_ = State(kDone, 0, 0, 0.0); } 192 void MemoryReducer::TearDown() { state_ = State(kDone, 0, 0, 0.0); }
193 193
194 } // internal 194 } // internal
195 } // v8 195 } // v8
OLDNEW
« no previous file with comments | « src/heap/memory-reducer.h ('k') | test/unittests/heap/memory-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698