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

Side by Side Diff: src/heap/incremental-marking.h

Issue 2290333002: [heap] Simplify heuristics for incremental step size. (Closed)
Patch Set: x Created 4 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 unified diff | Download patch
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/incremental-marking.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_INCREMENTAL_MARKING_H_ 5 #ifndef V8_HEAP_INCREMENTAL_MARKING_H_
6 #define V8_HEAP_INCREMENTAL_MARKING_H_ 6 #define V8_HEAP_INCREMENTAL_MARKING_H_
7 7
8 #include "src/cancelable-task.h" 8 #include "src/cancelable-task.h"
9 #include "src/execution.h" 9 #include "src/execution.h"
10 #include "src/heap/heap.h" 10 #include "src/heap/heap.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 StepActions step_actions); 116 StepActions step_actions);
117 117
118 // It's hard to know how much work the incremental marker should do to make 118 // It's hard to know how much work the incremental marker should do to make
119 // progress in the face of the mutator creating new work for it. We start 119 // progress in the face of the mutator creating new work for it. We start
120 // of at a moderate rate of work and gradually increase the speed of the 120 // of at a moderate rate of work and gradually increase the speed of the
121 // incremental marker until it completes. 121 // incremental marker until it completes.
122 // Do some marking every time this much memory has been allocated or that many 122 // Do some marking every time this much memory has been allocated or that many
123 // heavy (color-checking) write barriers have been invoked. 123 // heavy (color-checking) write barriers have been invoked.
124 static const intptr_t kAllocatedThreshold = 65536; 124 static const intptr_t kAllocatedThreshold = 65536;
125 static const intptr_t kWriteBarriersInvokedThreshold = 32768; 125 static const intptr_t kWriteBarriersInvokedThreshold = 32768;
126 // Start off by marking this many times more memory than has been allocated. 126 // Cap the write barrier counter to avoid overflows.
127 static const intptr_t kInitialMarkingSpeed = 1; 127 static const intptr_t kMaxWriteBarrierCounter = 1 << 20;
128 // But if we are promoting a lot of data we need to mark faster to keep up 128 // These constants are arbitrary and chosen based on benchmarks.
129 // with the data that is entering the old space through promotion. 129 static const intptr_t kBytesToMarkPerAllocatedByte = 3;
130 static const intptr_t kFastMarking = 3; 130 static const intptr_t kBytesToMarkPerWriteBarrier = 10;
131 // After this many steps we increase the marking/allocating factor. 131 static const intptr_t kMinIncrementalStepDurationInMs = 1;
132 static const intptr_t kMarkingSpeedAccellerationInterval = 1024;
133 // This is how much we increase the marking/allocating factor by.
134 static const intptr_t kMarkingSpeedAccelleration = 2;
135 static const intptr_t kMaxMarkingSpeed = 1000;
136 132
137 // This is the upper bound for how many times we allow finalization of 133 // This is the upper bound for how many times we allow finalization of
138 // incremental marking to be postponed. 134 // incremental marking to be postponed.
139 static const size_t kMaxIdleMarkingDelayCounter = 3; 135 static const size_t kMaxIdleMarkingDelayCounter = 3;
140 136
141 void FinalizeSweeping(); 137 void FinalizeSweeping();
142 138
143 void OldSpaceStep(intptr_t allocated); 139 void OldSpaceStep(intptr_t allocated);
144 140
145 intptr_t Step(intptr_t allocated, CompletionAction action, 141 intptr_t Step(intptr_t allocated, CompletionAction action,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 176 }
181 177
182 inline void SetNewSpacePageFlags(Page* chunk) { 178 inline void SetNewSpacePageFlags(Page* chunk) {
183 SetNewSpacePageFlags(chunk, IsMarking()); 179 SetNewSpacePageFlags(chunk, IsMarking());
184 } 180 }
185 181
186 bool IsCompacting() { return IsMarking() && is_compacting_; } 182 bool IsCompacting() { return IsMarking() && is_compacting_; }
187 183
188 void ActivateGeneratedStub(Code* stub); 184 void ActivateGeneratedStub(Code* stub);
189 185
190 void NotifyOfHighPromotionRate();
191
192 void NotifyIncompleteScanOfObject(int unscanned_bytes) { 186 void NotifyIncompleteScanOfObject(int unscanned_bytes) {
193 unscanned_bytes_of_large_object_ = unscanned_bytes; 187 unscanned_bytes_of_large_object_ = unscanned_bytes;
194 } 188 }
195 189
196 void ClearIdleMarkingDelayCounter(); 190 void ClearIdleMarkingDelayCounter();
197 191
198 bool IsIdleMarkingDelayCounterLimitReached(); 192 bool IsIdleMarkingDelayCounterLimitReached();
199 193
200 static void MarkGrey(Heap* heap, HeapObject* object); 194 static void MarkGrey(Heap* heap, HeapObject* object);
201 195
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 incremental_marking_.Step(bytes_allocated, 242 incremental_marking_.Step(bytes_allocated,
249 IncrementalMarking::GC_VIA_STACK_GUARD); 243 IncrementalMarking::GC_VIA_STACK_GUARD);
250 } 244 }
251 245
252 private: 246 private:
253 IncrementalMarking& incremental_marking_; 247 IncrementalMarking& incremental_marking_;
254 }; 248 };
255 249
256 int64_t SpaceLeftInOldSpace(); 250 int64_t SpaceLeftInOldSpace();
257 251
258 void SpeedUp();
259
260 void ResetStepCounters(); 252 void ResetStepCounters();
261 253
262 void StartMarking(); 254 void StartMarking();
263 255
264 void StartBlackAllocation(); 256 void StartBlackAllocation();
265 void FinishBlackAllocation(); 257 void FinishBlackAllocation();
266 258
267 void MarkRoots(); 259 void MarkRoots();
268 void MarkObjectGroups(); 260 void MarkObjectGroups();
269 void ProcessWeakCells(); 261 void ProcessWeakCells();
(...skipping 24 matching lines...) Expand all
294 286
295 void IncrementIdleMarkingDelayCounter(); 287 void IncrementIdleMarkingDelayCounter();
296 288
297 Heap* heap_; 289 Heap* heap_;
298 290
299 Observer observer_; 291 Observer observer_;
300 292
301 State state_; 293 State state_;
302 bool is_compacting_; 294 bool is_compacting_;
303 295
304 int steps_count_;
305 int64_t old_generation_space_available_at_start_of_incremental_;
306 int64_t old_generation_space_used_at_start_of_incremental_;
307 int64_t bytes_rescanned_;
308 bool should_hurry_; 296 bool should_hurry_;
309 int marking_speed_;
310 intptr_t bytes_scanned_;
311 intptr_t allocated_; 297 intptr_t allocated_;
312 intptr_t write_barriers_invoked_since_last_step_; 298 intptr_t write_barriers_invoked_since_last_step_;
313 size_t idle_marking_delay_counter_; 299 size_t idle_marking_delay_counter_;
314 300
315 int unscanned_bytes_of_large_object_; 301 int unscanned_bytes_of_large_object_;
316 302
317 bool was_activated_; 303 bool was_activated_;
318 304
319 bool black_allocation_; 305 bool black_allocation_;
320 306
321 bool finalize_marking_completed_; 307 bool finalize_marking_completed_;
322 308
323 int incremental_marking_finalization_rounds_; 309 int incremental_marking_finalization_rounds_;
324 310
325 GCRequestType request_type_; 311 GCRequestType request_type_;
326 312
327 IncrementalMarkingJob incremental_marking_job_; 313 IncrementalMarkingJob incremental_marking_job_;
328 314
329 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); 315 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking);
330 }; 316 };
331 } // namespace internal 317 } // namespace internal
332 } // namespace v8 318 } // namespace v8
333 319
334 #endif // V8_HEAP_INCREMENTAL_MARKING_H_ 320 #endif // V8_HEAP_INCREMENTAL_MARKING_H_
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/incremental-marking.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698