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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // Number of scavenges that will trigger start of new idle round. | 106 // Number of scavenges that will trigger start of new idle round. |
107 static const int kIdleScavengeThreshold; | 107 static const int kIdleScavengeThreshold; |
108 | 108 |
109 // Heap size threshold below which we prefer mark-compact over incremental | 109 // Heap size threshold below which we prefer mark-compact over incremental |
110 // step. | 110 // step. |
111 static const size_t kSmallHeapSize = 2 * kPointerSize * MB; | 111 static const size_t kSmallHeapSize = 2 * kPointerSize * MB; |
112 | 112 |
113 // That is the maximum idle time we will have during frame rendering. | 113 // That is the maximum idle time we will have during frame rendering. |
114 static const size_t kMaxFrameRenderingIdleTime = 16; | 114 static const size_t kMaxFrameRenderingIdleTime = 16; |
115 | 115 |
| 116 // We consider idle notification with larger or equal invocations as large |
| 117 // idle notifications. |
| 118 static const size_t kLargeIdleTime = 10; |
| 119 |
| 120 // Scavenges with a larger estimated execution time may be forced early by the |
| 121 // idle notification. |
| 122 static const size_t kForceScavengeThreshold = 10; |
| 123 |
116 // If less than that much memory is left in the new space, we consider it | 124 // If less than that much memory is left in the new space, we consider it |
117 // as almost full and force a new space collection earlier in the idle time. | 125 // as almost full and force a new space collection earlier in the idle time. |
118 static const size_t kNewSpaceAlmostFullTreshold = 100 * KB; | 126 static const size_t kNewSpaceAlmostFullTreshold = 100 * KB; |
119 | 127 |
120 // If we haven't recorded any scavenger events yet, we use a conservative | |
121 // lower bound for the scavenger speed. | |
122 static const size_t kInitialConservativeScavengeSpeed = 100 * KB; | |
123 | |
124 struct HeapState { | 128 struct HeapState { |
125 int contexts_disposed; | 129 int contexts_disposed; |
126 size_t size_of_objects; | 130 size_t size_of_objects; |
127 bool incremental_marking_stopped; | 131 bool incremental_marking_stopped; |
128 bool can_start_incremental_marking; | 132 bool can_start_incremental_marking; |
129 bool sweeping_in_progress; | 133 bool sweeping_in_progress; |
130 size_t mark_compact_speed_in_bytes_per_ms; | 134 size_t mark_compact_speed_in_bytes_per_ms; |
131 size_t incremental_marking_speed_in_bytes_per_ms; | 135 size_t incremental_marking_speed_in_bytes_per_ms; |
132 size_t scavenge_speed_in_bytes_per_ms; | 136 size_t scavenge_speed_in_bytes_per_ms; |
133 size_t available_new_space_memory; | 137 size_t available_new_space_memory; |
(...skipping 25 matching lines...) Expand all Loading... |
159 static size_t EstimateMarkCompactTime( | 163 static size_t EstimateMarkCompactTime( |
160 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms); | 164 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms); |
161 | 165 |
162 static size_t EstimateScavengeTime(size_t new_space_size, | 166 static size_t EstimateScavengeTime(size_t new_space_size, |
163 size_t scavenger_speed_in_bytes_per_ms); | 167 size_t scavenger_speed_in_bytes_per_ms); |
164 | 168 |
165 static bool ScavangeMayHappenSoon( | 169 static bool ScavangeMayHappenSoon( |
166 size_t available_new_space_memory, | 170 size_t available_new_space_memory, |
167 size_t new_space_allocation_throughput_in_bytes_per_ms); | 171 size_t new_space_allocation_throughput_in_bytes_per_ms); |
168 | 172 |
| 173 static bool DoEarlyScavenge(size_t idle_time_in_ms, size_t new_space_size, |
| 174 size_t available_new_space_memory, |
| 175 size_t scavenger_speed_in_bytes_per_ms); |
| 176 |
| 177 static bool DoScavenge( |
| 178 size_t idle_time_in_ms, size_t new_space_size, |
| 179 size_t available_new_space_memory, size_t scavenger_speed_in_bytes_per_ms, |
| 180 size_t new_space_allocation_throughput_in_bytes_per_ms); |
| 181 |
169 private: | 182 private: |
170 void StartIdleRound() { mark_compacts_since_idle_round_started_ = 0; } | 183 void StartIdleRound() { mark_compacts_since_idle_round_started_ = 0; } |
171 bool IsMarkCompactIdleRoundFinished() { | 184 bool IsMarkCompactIdleRoundFinished() { |
172 return mark_compacts_since_idle_round_started_ == | 185 return mark_compacts_since_idle_round_started_ == |
173 kMaxMarkCompactsInIdleRound; | 186 kMaxMarkCompactsInIdleRound; |
174 } | 187 } |
175 bool EnoughGarbageSinceLastIdleRound() { | 188 bool EnoughGarbageSinceLastIdleRound() { |
176 return scavenges_since_last_idle_round_ >= kIdleScavengeThreshold; | 189 return scavenges_since_last_idle_round_ >= kIdleScavengeThreshold; |
177 } | 190 } |
178 | 191 |
179 int mark_compacts_since_idle_round_started_; | 192 int mark_compacts_since_idle_round_started_; |
180 int scavenges_since_last_idle_round_; | 193 int scavenges_since_last_idle_round_; |
181 | 194 |
182 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); | 195 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); |
183 }; | 196 }; |
184 | 197 |
185 } // namespace internal | 198 } // namespace internal |
186 } // namespace v8 | 199 } // namespace v8 |
187 | 200 |
188 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ | 201 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ |
OLD | NEW |