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

Side by Side Diff: src/heap/gc-idle-time-handler.h

Issue 1153043002: Version 4.4.63.2 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.4
Patch Set: Created 5 years, 6 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 | « include/v8-version.h ('k') | src/heap/gc-idle-time-handler.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #ifndef V8_HEAP_GC_IDLE_TIME_HANDLER_H_ 5 #ifndef V8_HEAP_GC_IDLE_TIME_HANDLER_H_
6 #define V8_HEAP_GC_IDLE_TIME_HANDLER_H_ 6 #define V8_HEAP_GC_IDLE_TIME_HANDLER_H_
7 7
8 #include "src/globals.h" 8 #include "src/globals.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 // Incremental marking step time. 142 // Incremental marking step time.
143 static const size_t kIncrementalMarkingStepTimeInMs = 1; 143 static const size_t kIncrementalMarkingStepTimeInMs = 1;
144 144
145 static const size_t kMinTimeForOverApproximatingWeakClosureInMs; 145 static const size_t kMinTimeForOverApproximatingWeakClosureInMs;
146 146
147 // The number of idle MarkCompact GCs to perform before transitioning to 147 // The number of idle MarkCompact GCs to perform before transitioning to
148 // the kDone mode. 148 // the kDone mode.
149 static const int kMaxIdleMarkCompacts = 3; 149 static const int kMaxIdleMarkCompacts = 3;
150 150
151 // The number of mutator GCs before transitioning to the kReduceLatency mode. 151 // The number of mutator MarkCompact GCs before transitioning to the
152 static const int kGCsBeforeMutatorIsActive = 7; 152 // kReduceLatency mode.
153 static const int kMarkCompactsBeforeMutatorIsActive = 1;
153 154
154 // Mutator is considered idle if 155 // Mutator is considered idle if
155 // 1) there is an idle notification with time >= kLargeLongIdleTime, 156 // 1) there are N idle notification with time >= kMinBackgroundIdleTime,
156 // 2) or there are kLongIdleNotificationsBeforeMutatorIsIdle idle 157 // 2) or there are M idle notifications with time >= kMinLongIdleTime
157 // notifications 158 // without any mutator GC in between.
158 // with time >= kMinLongIdleTime and without any mutator GC in between. 159 // Where N = kBackgroundIdleNotificationsBeforeMutatorIsIdle,
160 // M = kLongIdleNotificationsBeforeMutatorIsIdle
159 static const int kMinLongIdleTime = kMaxFrameRenderingIdleTime + 1; 161 static const int kMinLongIdleTime = kMaxFrameRenderingIdleTime + 1;
160 static const int kLargeLongIdleTime = 900; 162 static const int kMinBackgroundIdleTime = 900;
161 static const int kLongIdleNotificationsBeforeMutatorIsIdle = 20; 163 static const int kBackgroundIdleNotificationsBeforeMutatorIsIdle = 2;
162 164 static const int kLongIdleNotificationsBeforeMutatorIsIdle = 50;
165 // Number of times we will return a Nothing action in the current mode
166 // despite having idle time available before we returning a Done action to
167 // ensure we don't keep scheduling idle tasks and making no progress.
168 static const int kMaxNoProgressIdleTimesPerMode = 10;
163 169
164 class HeapState { 170 class HeapState {
165 public: 171 public:
166 void Print(); 172 void Print();
167 173
168 int contexts_disposed; 174 int contexts_disposed;
169 double contexts_disposal_rate; 175 double contexts_disposal_rate;
170 size_t size_of_objects; 176 size_t size_of_objects;
171 bool incremental_marking_stopped; 177 bool incremental_marking_stopped;
172 bool can_start_incremental_marking; 178 bool can_start_incremental_marking;
173 bool sweeping_in_progress; 179 bool sweeping_in_progress;
174 bool sweeping_completed; 180 bool sweeping_completed;
175 size_t mark_compact_speed_in_bytes_per_ms; 181 size_t mark_compact_speed_in_bytes_per_ms;
176 size_t incremental_marking_speed_in_bytes_per_ms; 182 size_t incremental_marking_speed_in_bytes_per_ms;
177 size_t final_incremental_mark_compact_speed_in_bytes_per_ms; 183 size_t final_incremental_mark_compact_speed_in_bytes_per_ms;
178 size_t scavenge_speed_in_bytes_per_ms; 184 size_t scavenge_speed_in_bytes_per_ms;
179 size_t used_new_space_size; 185 size_t used_new_space_size;
180 size_t new_space_capacity; 186 size_t new_space_capacity;
181 size_t new_space_allocation_throughput_in_bytes_per_ms; 187 size_t new_space_allocation_throughput_in_bytes_per_ms;
182 }; 188 };
183 189
184 GCIdleTimeHandler() 190 GCIdleTimeHandler()
185 : idle_mark_compacts_(0), 191 : idle_mark_compacts_(0),
186 mark_compacts_(0), 192 mark_compacts_(0),
187 scavenges_(0), 193 scavenges_(0),
188 long_idle_notifications_(0), 194 long_idle_notifications_(0),
195 background_idle_notifications_(0),
196 idle_times_which_made_no_progress_per_mode_(0),
189 mode_(kReduceLatency) {} 197 mode_(kReduceLatency) {}
190 198
191 GCIdleTimeAction Compute(double idle_time_in_ms, HeapState heap_state); 199 GCIdleTimeAction Compute(double idle_time_in_ms, HeapState heap_state);
192 200
193 void NotifyIdleMarkCompact() { ++idle_mark_compacts_; } 201 void NotifyIdleMarkCompact() { ++idle_mark_compacts_; }
194 202
195 void NotifyMarkCompact() { ++mark_compacts_; } 203 void NotifyMarkCompact() { ++mark_compacts_; }
196 204
197 void NotifyScavenge() { ++scavenges_; } 205 void NotifyScavenge() { ++scavenges_; }
198 206
(...skipping 23 matching lines...) Expand all
222 size_t idle_time_in_ms, size_t new_space_size, size_t used_new_space_size, 230 size_t idle_time_in_ms, size_t new_space_size, size_t used_new_space_size,
223 size_t scavenger_speed_in_bytes_per_ms, 231 size_t scavenger_speed_in_bytes_per_ms,
224 size_t new_space_allocation_throughput_in_bytes_per_ms); 232 size_t new_space_allocation_throughput_in_bytes_per_ms);
225 233
226 enum Mode { kReduceLatency, kReduceMemory, kDone }; 234 enum Mode { kReduceLatency, kReduceMemory, kDone };
227 235
228 Mode mode() { return mode_; } 236 Mode mode() { return mode_; }
229 237
230 private: 238 private:
231 bool IsMutatorActive(int contexts_disposed, int gcs); 239 bool IsMutatorActive(int contexts_disposed, int gcs);
232 bool IsMutatorIdle(int long_idle_notifications, int gcs); 240 bool IsMutatorIdle(int long_idle_notifications,
241 int background_idle_notifications, int gcs);
233 void UpdateCounters(double idle_time_in_ms); 242 void UpdateCounters(double idle_time_in_ms);
234 void ResetCounters(); 243 void ResetCounters();
235 Mode NextMode(const HeapState& heap_state); 244 Mode NextMode(const HeapState& heap_state);
236 GCIdleTimeAction Action(double idle_time_in_ms, const HeapState& heap_state, 245 GCIdleTimeAction Action(double idle_time_in_ms, const HeapState& heap_state,
237 bool reduce_memory); 246 bool reduce_memory);
247 GCIdleTimeAction NothingOrDone();
238 248
239 int idle_mark_compacts_; 249 int idle_mark_compacts_;
240 int mark_compacts_; 250 int mark_compacts_;
241 int scavenges_; 251 int scavenges_;
242 // The number of long idle notifications with no mutator GC happening 252 // The number of long idle notifications with no GC happening
243 // between the notifications. 253 // between the notifications.
244 int long_idle_notifications_; 254 int long_idle_notifications_;
255 // The number of background idle notifications with no GC happening
256 // between the notifications.
257 int background_idle_notifications_;
258 // Idle notifications with no progress in the current mode.
259 int idle_times_which_made_no_progress_per_mode_;
245 260
246 Mode mode_; 261 Mode mode_;
247 262
248 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); 263 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler);
249 }; 264 };
250 265
251 } // namespace internal 266 } // namespace internal
252 } // namespace v8 267 } // namespace v8
253 268
254 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ 269 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_
OLDNEW
« no previous file with comments | « include/v8-version.h ('k') | src/heap/gc-idle-time-handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698