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

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

Issue 583593006: Force scavenge in idle notification if we estimate that it will take long. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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/gc-idle-time-handler-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 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 {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 size_t GCIdleTimeHandler::EstimateMarkCompactTime( 64 size_t GCIdleTimeHandler::EstimateMarkCompactTime(
65 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms) { 65 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms) {
66 if (mark_compact_speed_in_bytes_per_ms == 0) { 66 if (mark_compact_speed_in_bytes_per_ms == 0) {
67 mark_compact_speed_in_bytes_per_ms = kInitialConservativeMarkCompactSpeed; 67 mark_compact_speed_in_bytes_per_ms = kInitialConservativeMarkCompactSpeed;
68 } 68 }
69 size_t result = size_of_objects / mark_compact_speed_in_bytes_per_ms; 69 size_t result = size_of_objects / mark_compact_speed_in_bytes_per_ms;
70 return Min(result, kMaxMarkCompactTimeInMs); 70 return Min(result, kMaxMarkCompactTimeInMs);
71 } 71 }
72 72
73 73
74 size_t GCIdleTimeHandler::EstimateScavengeTime( 74 bool GCIdleTimeHandler::DoScavenge(
75 size_t new_space_size, size_t scavenge_speed_in_bytes_per_ms) { 75 size_t idle_time_in_ms, size_t new_space_size, size_t used_new_space_size,
76 size_t scavenge_speed_in_bytes_per_ms,
77 size_t new_space_allocation_throughput_in_bytes_per_ms) {
78 size_t new_space_allocation_limit =
79 kMaxFrameRenderingIdleTime * scavenge_speed_in_bytes_per_ms;
80
81 // If the limit is larger than the new space size, then scavenging used to be
82 // really fast. We can take advantage of the whole new space.
83 if (new_space_allocation_limit > new_space_size) {
84 new_space_allocation_limit = new_space_size;
85 }
86
87 // We have to trigger scavenge before we reach the end of new space.
88 new_space_allocation_limit -=
89 new_space_allocation_throughput_in_bytes_per_ms *
90 kMaxFrameRenderingIdleTime;
91
76 if (scavenge_speed_in_bytes_per_ms == 0) { 92 if (scavenge_speed_in_bytes_per_ms == 0) {
77 scavenge_speed_in_bytes_per_ms = kInitialConservativeScavengeSpeed; 93 scavenge_speed_in_bytes_per_ms = kInitialConservativeScavengeSpeed;
78 } 94 }
79 return new_space_size / scavenge_speed_in_bytes_per_ms;
80 }
81 95
82 96 if (new_space_allocation_limit <= used_new_space_size) {
83 bool GCIdleTimeHandler::ScavangeMayHappenSoon( 97 if (used_new_space_size / scavenge_speed_in_bytes_per_ms <=
84 size_t available_new_space_memory, 98 idle_time_in_ms) {
85 size_t new_space_allocation_throughput_in_bytes_per_ms) { 99 return true;
86 if (available_new_space_memory <= 100 }
87 new_space_allocation_throughput_in_bytes_per_ms *
88 kMaxFrameRenderingIdleTime) {
89 return true;
90 } 101 }
91 return false; 102 return false;
92 } 103 }
93 104
94 105
95 // The following logic is implemented by the controller: 106 // The following logic is implemented by the controller:
96 // (1) If the new space is almost full and we can effort a Scavenge, then a 107 // (1) If the new space is almost full and we can effort a Scavenge or if the
ulan 2014/09/26 08:12:22 nit: "we can _afford_ a Scavenge"?
Hannes Payer (out of office) 2014/10/02 07:22:09 Done.
97 // Scavenge is performed. 108 // next Scavenge will very likely take long, then a Scavenge is performed.
98 // (2) If there is currently no MarkCompact idle round going on, we start a 109 // (2) If there is currently no MarkCompact idle round going on, we start a
99 // new idle round if enough garbage was created or we received a context 110 // new idle round if enough garbage was created or we received a context
100 // disposal event. Otherwise we do not perform garbage collection to keep 111 // disposal event. Otherwise we do not perform garbage collection to keep
101 // system utilization low. 112 // system utilization low.
102 // (3) If incremental marking is done, we perform a full garbage collection 113 // (3) If incremental marking is done, we perform a full garbage collection
103 // if context was disposed or if we are allowed to still do full garbage 114 // if context was disposed or if we are allowed to still do full garbage
104 // collections during this idle round or if we are not allowed to start 115 // collections during this idle round or if we are not allowed to start
105 // incremental marking. Otherwise we do not perform garbage collection to 116 // incremental marking. Otherwise we do not perform garbage collection to
106 // keep system utilization low. 117 // keep system utilization low.
107 // (4) If sweeping is in progress and we received a large enough idle time 118 // (4) If sweeping is in progress and we received a large enough idle time
108 // request, we finalize sweeping here. 119 // request, we finalize sweeping here.
109 // (5) If incremental marking is in progress, we perform a marking step. Note, 120 // (5) If incremental marking is in progress, we perform a marking step. Note,
110 // that this currently may trigger a full garbage collection. 121 // that this currently may trigger a full garbage collection.
111 GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms, 122 GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms,
112 HeapState heap_state) { 123 HeapState heap_state) {
113 if (ScavangeMayHappenSoon( 124 if (DoScavenge(idle_time_in_ms, heap_state.new_space_capacity,
114 heap_state.available_new_space_memory, 125 heap_state.used_new_space_size,
115 heap_state.new_space_allocation_throughput_in_bytes_per_ms) && 126 heap_state.scavenge_speed_in_bytes_per_ms,
116 idle_time_in_ms >= 127 heap_state.new_space_allocation_throughput_in_bytes_per_ms)) {
117 EstimateScavengeTime(heap_state.new_space_capacity,
118 heap_state.scavenge_speed_in_bytes_per_ms)) {
119 return GCIdleTimeAction::Scavenge(); 128 return GCIdleTimeAction::Scavenge();
120 } 129 }
130
121 if (IsMarkCompactIdleRoundFinished()) { 131 if (IsMarkCompactIdleRoundFinished()) {
122 if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) { 132 if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) {
123 StartIdleRound(); 133 StartIdleRound();
124 } else { 134 } else {
125 return GCIdleTimeAction::Done(); 135 return GCIdleTimeAction::Done();
126 } 136 }
127 } 137 }
128 138
129 if (idle_time_in_ms == 0) { 139 if (idle_time_in_ms == 0) {
130 return GCIdleTimeAction::Nothing(); 140 return GCIdleTimeAction::Nothing();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 if (heap_state.incremental_marking_stopped && 174 if (heap_state.incremental_marking_stopped &&
165 !heap_state.can_start_incremental_marking) { 175 !heap_state.can_start_incremental_marking) {
166 return GCIdleTimeAction::Nothing(); 176 return GCIdleTimeAction::Nothing();
167 } 177 }
168 size_t step_size = EstimateMarkingStepSize( 178 size_t step_size = EstimateMarkingStepSize(
169 idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms); 179 idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms);
170 return GCIdleTimeAction::IncrementalMarking(step_size); 180 return GCIdleTimeAction::IncrementalMarking(step_size);
171 } 181 }
172 } 182 }
173 } 183 }
OLDNEW
« no previous file with comments | « src/heap/gc-idle-time-handler.h ('k') | src/heap/gc-idle-time-handler-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698