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

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

Issue 500483002: Revert "Add finalize sweeping event to GCIdleTimeHandler." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/heap/gc-idle-time-handler.h ('k') | src/heap/heap.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 #include "src/heap/gc-idle-time-handler.h" 5 #include "src/heap/gc-idle-time-handler.h"
6 #include "src/heap/gc-tracer.h" 6 #include "src/heap/gc-tracer.h"
7 #include "src/utils.h" 7 #include "src/utils.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
11 11
12 const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9; 12 const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9;
13 const size_t GCIdleTimeHandler::kMaxMarkCompactTimeInMs = 1000000;
13 14
14 15
15 size_t GCIdleTimeHandler::EstimateMarkingStepSize( 16 size_t GCIdleTimeHandler::EstimateMarkingStepSize(
16 size_t idle_time_in_ms, size_t marking_speed_in_bytes_per_ms) { 17 size_t idle_time_in_ms, size_t marking_speed_in_bytes_per_ms) {
17 DCHECK(idle_time_in_ms > 0); 18 DCHECK(idle_time_in_ms > 0);
18 19
19 if (marking_speed_in_bytes_per_ms == 0) { 20 if (marking_speed_in_bytes_per_ms == 0) {
20 marking_speed_in_bytes_per_ms = kInitialConservativeMarkingSpeed; 21 marking_speed_in_bytes_per_ms = kInitialConservativeMarkingSpeed;
21 } 22 }
22 23
23 size_t marking_step_size = marking_speed_in_bytes_per_ms * idle_time_in_ms; 24 size_t marking_step_size = marking_speed_in_bytes_per_ms * idle_time_in_ms;
24 if (marking_step_size / marking_speed_in_bytes_per_ms != idle_time_in_ms) { 25 if (marking_step_size / marking_speed_in_bytes_per_ms != idle_time_in_ms) {
25 // In the case of an overflow we return maximum marking step size. 26 // In the case of an overflow we return maximum marking step size.
26 return kMaximumMarkingStepSize; 27 return kMaximumMarkingStepSize;
27 } 28 }
28 29
29 if (marking_step_size > kMaximumMarkingStepSize) 30 if (marking_step_size > kMaximumMarkingStepSize)
30 return kMaximumMarkingStepSize; 31 return kMaximumMarkingStepSize;
31 32
32 return static_cast<size_t>(marking_step_size * kConservativeTimeRatio); 33 return static_cast<size_t>(marking_step_size *
34 GCIdleTimeHandler::kConservativeTimeRatio);
33 } 35 }
34 36
35 37
36 size_t GCIdleTimeHandler::EstimateMarkCompactTime( 38 size_t GCIdleTimeHandler::EstimateMarkCompactTime(
37 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms) { 39 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms) {
38 if (mark_compact_speed_in_bytes_per_ms == 0) { 40 if (mark_compact_speed_in_bytes_per_ms == 0) {
39 mark_compact_speed_in_bytes_per_ms = kInitialConservativeMarkCompactSpeed; 41 mark_compact_speed_in_bytes_per_ms = kInitialConservativeMarkCompactSpeed;
40 } 42 }
41 size_t result = size_of_objects / mark_compact_speed_in_bytes_per_ms; 43 size_t result = size_of_objects / mark_compact_speed_in_bytes_per_ms;
42 return Min(result, kMaxMarkCompactTimeInMs); 44 return Min(result, kMaxMarkCompactTimeInMs);
43 } 45 }
44 46
45 47
46 GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms, 48 GCIdleTimeAction GCIdleTimeHandler::Compute(int idle_time_in_ms,
47 HeapState heap_state, 49 HeapState heap_state,
48 GCTracer* gc_tracer) { 50 GCTracer* gc_tracer) {
49 if (IsIdleRoundFinished()) { 51 if (IsIdleRoundFinished()) {
50 if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) { 52 if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) {
51 StartIdleRound(); 53 StartIdleRound();
52 } else { 54 } else {
53 return GCIdleTimeAction::Nothing(); 55 return GCIdleTimeAction::Nothing();
54 } 56 }
55 } 57 }
56 if (heap_state.incremental_marking_stopped) { 58 if (heap_state.incremental_marking_stopped) {
57 size_t speed = 59 size_t speed =
58 static_cast<size_t>(gc_tracer->MarkCompactSpeedInBytesPerMillisecond()); 60 static_cast<size_t>(gc_tracer->MarkCompactSpeedInBytesPerMillisecond());
59 if (idle_time_in_ms >= 61 if (idle_time_in_ms >= static_cast<int>(EstimateMarkCompactTime(
60 EstimateMarkCompactTime(heap_state.size_of_objects, speed)) { 62 heap_state.size_of_objects, speed))) {
61 // If there are no more than two GCs left in this idle round and we are 63 // If there are no more than two GCs left in this idle round and we are
62 // allowed to do a full GC, then make those GCs full in order to compact 64 // allowed to do a full GC, then make those GCs full in order to compact
63 // the code space. 65 // the code space.
64 // TODO(ulan): Once we enable code compaction for incremental marking, we 66 // TODO(ulan): Once we enable code compaction for incremental marking, we
65 // can get rid of this special case and always start incremental marking. 67 // can get rid of this special case and always start incremental marking.
66 int remaining_mark_sweeps = 68 int remaining_mark_sweeps =
67 kMaxMarkCompactsInIdleRound - mark_compacts_since_idle_round_started_; 69 kMaxMarkCompactsInIdleRound - mark_compacts_since_idle_round_started_;
68 if (heap_state.contexts_disposed > 0 || remaining_mark_sweeps <= 2 || 70 if (heap_state.contexts_disposed > 0 || remaining_mark_sweeps <= 2 ||
69 !heap_state.can_start_incremental_marking) { 71 !heap_state.can_start_incremental_marking) {
70 return GCIdleTimeAction::FullGC(); 72 return GCIdleTimeAction::FullGC();
71 } 73 }
72 } 74 }
73 if (!heap_state.can_start_incremental_marking) { 75 if (!heap_state.can_start_incremental_marking) {
74 return GCIdleTimeAction::Nothing(); 76 return GCIdleTimeAction::Nothing();
75 } 77 }
76 } 78 }
77 // TODO(hpayer): Estimate finalize sweeping time.
78 if (heap_state.sweeping_in_progress &&
79 idle_time_in_ms >= kMinTimeForFinalizeSweeping) {
80 return GCIdleTimeAction::FinalizeSweeping();
81 }
82
83 intptr_t speed = gc_tracer->IncrementalMarkingSpeedInBytesPerMillisecond(); 79 intptr_t speed = gc_tracer->IncrementalMarkingSpeedInBytesPerMillisecond();
84 size_t step_size = 80 size_t step_size =
85 static_cast<size_t>(EstimateMarkingStepSize(idle_time_in_ms, speed)); 81 static_cast<size_t>(EstimateMarkingStepSize(idle_time_in_ms, speed));
86 return GCIdleTimeAction::IncrementalMarking(step_size); 82 return GCIdleTimeAction::IncrementalMarking(step_size);
87 } 83 }
88 } 84 }
89 } 85 }
OLDNEW
« no previous file with comments | « src/heap/gc-idle-time-handler.h ('k') | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698