OLD | NEW |
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 static const size_t kMaximumMarkingStepSize = 700 * MB; | 85 static const size_t kMaximumMarkingStepSize = 700 * MB; |
86 | 86 |
87 // We have to make sure that we finish the IdleNotification before | 87 // We have to make sure that we finish the IdleNotification before |
88 // idle_time_in_ms. Hence, we conservatively prune our workload estimate. | 88 // idle_time_in_ms. Hence, we conservatively prune our workload estimate. |
89 static const double kConservativeTimeRatio; | 89 static const double kConservativeTimeRatio; |
90 | 90 |
91 // If we haven't recorded any mark-compact events yet, we use | 91 // If we haven't recorded any mark-compact events yet, we use |
92 // conservative lower bound for the mark-compact speed. | 92 // conservative lower bound for the mark-compact speed. |
93 static const size_t kInitialConservativeMarkCompactSpeed = 2 * MB; | 93 static const size_t kInitialConservativeMarkCompactSpeed = 2 * MB; |
94 | 94 |
95 // If we haven't recorded any final incremental mark-compact events yet, we | |
96 // use conservative lower bound for the mark-compact speed. | |
97 static const size_t kInitialConservativeFinalIncrementalMarkCompactSpeed = | |
98 2 * MB; | |
99 | |
100 // Maximum mark-compact time returned by EstimateMarkCompactTime. | 95 // Maximum mark-compact time returned by EstimateMarkCompactTime. |
101 static const size_t kMaxMarkCompactTimeInMs; | 96 static const size_t kMaxMarkCompactTimeInMs; |
102 | 97 |
103 // Maximum final incremental mark-compact time returned by | |
104 // EstimateFinalIncrementalMarkCompactTime. | |
105 static const size_t kMaxFinalIncrementalMarkCompactTimeInMs; | |
106 | |
107 // Minimum time to finalize sweeping phase. The main thread may wait for | 98 // Minimum time to finalize sweeping phase. The main thread may wait for |
108 // sweeper threads. | 99 // sweeper threads. |
109 static const size_t kMinTimeForFinalizeSweeping; | 100 static const size_t kMinTimeForFinalizeSweeping; |
110 | 101 |
111 // Number of idle mark-compact events, after which idle handler will finish | 102 // Number of idle mark-compact events, after which idle handler will finish |
112 // idle round. | 103 // idle round. |
113 static const int kMaxMarkCompactsInIdleRound; | 104 static const int kMaxMarkCompactsInIdleRound; |
114 | 105 |
115 // Number of scavenges that will trigger start of new idle round. | 106 // Number of scavenges that will trigger start of new idle round. |
116 static const int kIdleScavengeThreshold; | 107 static const int kIdleScavengeThreshold; |
(...skipping 13 matching lines...) Expand all Loading... |
130 void Print(); | 121 void Print(); |
131 | 122 |
132 int contexts_disposed; | 123 int contexts_disposed; |
133 double contexts_disposal_rate; | 124 double contexts_disposal_rate; |
134 size_t size_of_objects; | 125 size_t size_of_objects; |
135 bool incremental_marking_stopped; | 126 bool incremental_marking_stopped; |
136 bool can_start_incremental_marking; | 127 bool can_start_incremental_marking; |
137 bool sweeping_in_progress; | 128 bool sweeping_in_progress; |
138 size_t mark_compact_speed_in_bytes_per_ms; | 129 size_t mark_compact_speed_in_bytes_per_ms; |
139 size_t incremental_marking_speed_in_bytes_per_ms; | 130 size_t incremental_marking_speed_in_bytes_per_ms; |
140 size_t final_incremental_mark_compact_speed_in_bytes_per_ms; | |
141 size_t scavenge_speed_in_bytes_per_ms; | 131 size_t scavenge_speed_in_bytes_per_ms; |
142 size_t used_new_space_size; | 132 size_t used_new_space_size; |
143 size_t new_space_capacity; | 133 size_t new_space_capacity; |
144 size_t new_space_allocation_throughput_in_bytes_per_ms; | 134 size_t new_space_allocation_throughput_in_bytes_per_ms; |
145 }; | 135 }; |
146 | 136 |
147 GCIdleTimeHandler() | 137 GCIdleTimeHandler() |
148 : mark_compacts_since_idle_round_started_(0), | 138 : mark_compacts_since_idle_round_started_(0), |
149 scavenges_since_last_idle_round_(0) {} | 139 scavenges_since_last_idle_round_(0) {} |
150 | 140 |
(...skipping 10 matching lines...) Expand all Loading... |
161 } | 151 } |
162 | 152 |
163 void NotifyScavenge() { ++scavenges_since_last_idle_round_; } | 153 void NotifyScavenge() { ++scavenges_since_last_idle_round_; } |
164 | 154 |
165 static size_t EstimateMarkingStepSize(size_t idle_time_in_ms, | 155 static size_t EstimateMarkingStepSize(size_t idle_time_in_ms, |
166 size_t marking_speed_in_bytes_per_ms); | 156 size_t marking_speed_in_bytes_per_ms); |
167 | 157 |
168 static size_t EstimateMarkCompactTime( | 158 static size_t EstimateMarkCompactTime( |
169 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms); | 159 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms); |
170 | 160 |
171 static size_t EstimateFinalIncrementalMarkCompactTime( | |
172 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms); | |
173 | |
174 static bool ShouldDoMarkCompact(size_t idle_time_in_ms, | 161 static bool ShouldDoMarkCompact(size_t idle_time_in_ms, |
175 size_t size_of_objects, | 162 size_t size_of_objects, |
176 size_t mark_compact_speed_in_bytes_per_ms); | 163 size_t mark_compact_speed_in_bytes_per_ms); |
177 | 164 |
178 static bool ShouldDoContextDisposalMarkCompact(bool context_disposed, | 165 static bool ShouldDoContextDisposalMarkCompact(bool context_disposed, |
179 double contexts_disposal_rate); | 166 double contexts_disposal_rate); |
180 | 167 |
181 static bool ShouldDoFinalIncrementalMarkCompact( | |
182 size_t idle_time_in_ms, size_t size_of_objects, | |
183 size_t final_incremental_mark_compact_speed_in_bytes_per_ms); | |
184 | |
185 static bool ShouldDoScavenge( | 168 static bool ShouldDoScavenge( |
186 size_t idle_time_in_ms, size_t new_space_size, size_t used_new_space_size, | 169 size_t idle_time_in_ms, size_t new_space_size, size_t used_new_space_size, |
187 size_t scavenger_speed_in_bytes_per_ms, | 170 size_t scavenger_speed_in_bytes_per_ms, |
188 size_t new_space_allocation_throughput_in_bytes_per_ms); | 171 size_t new_space_allocation_throughput_in_bytes_per_ms); |
189 | 172 |
190 private: | 173 private: |
191 void StartIdleRound() { mark_compacts_since_idle_round_started_ = 0; } | 174 void StartIdleRound() { mark_compacts_since_idle_round_started_ = 0; } |
192 bool IsMarkCompactIdleRoundFinished() { | 175 bool IsMarkCompactIdleRoundFinished() { |
193 return mark_compacts_since_idle_round_started_ == | 176 return mark_compacts_since_idle_round_started_ == |
194 kMaxMarkCompactsInIdleRound; | 177 kMaxMarkCompactsInIdleRound; |
195 } | 178 } |
196 bool EnoughGarbageSinceLastIdleRound() { | 179 bool EnoughGarbageSinceLastIdleRound() { |
197 return scavenges_since_last_idle_round_ >= kIdleScavengeThreshold; | 180 return scavenges_since_last_idle_round_ >= kIdleScavengeThreshold; |
198 } | 181 } |
199 | 182 |
200 int mark_compacts_since_idle_round_started_; | 183 int mark_compacts_since_idle_round_started_; |
201 int scavenges_since_last_idle_round_; | 184 int scavenges_since_last_idle_round_; |
202 | 185 |
203 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); | 186 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); |
204 }; | 187 }; |
205 | 188 |
206 } // namespace internal | 189 } // namespace internal |
207 } // namespace v8 | 190 } // namespace v8 |
208 | 191 |
209 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ | 192 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ |
OLD | NEW |