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 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 enum GCIdleTimeActionType { | 13 enum GCIdleTimeActionType { |
14 DONE, | 14 DONE, |
15 DO_NOTHING, | 15 DO_NOTHING, |
16 DO_INCREMENTAL_STEP, | 16 DO_INCREMENTAL_STEP, |
17 DO_SCAVENGE, | |
18 DO_FULL_GC, | 17 DO_FULL_GC, |
19 }; | 18 }; |
20 | 19 |
21 | 20 |
22 class GCIdleTimeAction { | 21 class GCIdleTimeAction { |
23 public: | 22 public: |
24 static GCIdleTimeAction Done() { | 23 static GCIdleTimeAction Done() { |
25 GCIdleTimeAction result; | 24 GCIdleTimeAction result; |
26 result.type = DONE; | 25 result.type = DONE; |
27 result.additional_work = false; | 26 result.additional_work = false; |
28 return result; | 27 return result; |
29 } | 28 } |
30 | 29 |
31 static GCIdleTimeAction Nothing() { | 30 static GCIdleTimeAction Nothing() { |
32 GCIdleTimeAction result; | 31 GCIdleTimeAction result; |
33 result.type = DO_NOTHING; | 32 result.type = DO_NOTHING; |
34 result.additional_work = false; | 33 result.additional_work = false; |
35 return result; | 34 return result; |
36 } | 35 } |
37 | 36 |
38 static GCIdleTimeAction IncrementalStep() { | 37 static GCIdleTimeAction IncrementalStep() { |
39 GCIdleTimeAction result; | 38 GCIdleTimeAction result; |
40 result.type = DO_INCREMENTAL_STEP; | 39 result.type = DO_INCREMENTAL_STEP; |
41 result.additional_work = false; | 40 result.additional_work = false; |
42 return result; | 41 return result; |
43 } | 42 } |
44 | 43 |
45 static GCIdleTimeAction Scavenge() { | |
46 GCIdleTimeAction result; | |
47 result.type = DO_SCAVENGE; | |
48 result.additional_work = false; | |
49 return result; | |
50 } | |
51 | |
52 static GCIdleTimeAction FullGC() { | 44 static GCIdleTimeAction FullGC() { |
53 GCIdleTimeAction result; | 45 GCIdleTimeAction result; |
54 result.type = DO_FULL_GC; | 46 result.type = DO_FULL_GC; |
55 result.additional_work = false; | 47 result.additional_work = false; |
56 return result; | 48 return result; |
57 } | 49 } |
58 | 50 |
59 void Print(); | 51 void Print(); |
60 | 52 |
61 GCIdleTimeActionType type; | 53 GCIdleTimeActionType type; |
62 bool additional_work; | 54 bool additional_work; |
63 }; | 55 }; |
64 | 56 |
65 | 57 |
66 class GCIdleTimeHeapState { | 58 class GCIdleTimeHeapState { |
67 public: | 59 public: |
68 void Print(); | 60 void Print(); |
69 | 61 |
70 int contexts_disposed; | 62 int contexts_disposed; |
71 double contexts_disposal_rate; | 63 double contexts_disposal_rate; |
72 size_t size_of_objects; | 64 size_t size_of_objects; |
73 bool incremental_marking_stopped; | 65 bool incremental_marking_stopped; |
74 bool sweeping_in_progress; | 66 bool sweeping_in_progress; |
75 bool sweeping_completed; | 67 bool sweeping_completed; |
76 bool has_low_allocation_rate; | 68 bool has_low_allocation_rate; |
77 size_t mark_compact_speed_in_bytes_per_ms; | 69 size_t mark_compact_speed_in_bytes_per_ms; |
78 size_t incremental_marking_speed_in_bytes_per_ms; | 70 size_t incremental_marking_speed_in_bytes_per_ms; |
79 size_t final_incremental_mark_compact_speed_in_bytes_per_ms; | 71 size_t final_incremental_mark_compact_speed_in_bytes_per_ms; |
80 size_t scavenge_speed_in_bytes_per_ms; | |
81 size_t used_new_space_size; | |
82 size_t new_space_capacity; | |
83 size_t new_space_allocation_throughput_in_bytes_per_ms; | |
84 }; | 72 }; |
85 | 73 |
86 | 74 |
87 // The idle time handler makes decisions about which garbage collection | 75 // The idle time handler makes decisions about which garbage collection |
88 // operations are executing during IdleNotification. | 76 // operations are executing during IdleNotification. |
89 class GCIdleTimeHandler { | 77 class GCIdleTimeHandler { |
90 public: | 78 public: |
91 // If we haven't recorded any incremental marking events yet, we carefully | 79 // If we haven't recorded any incremental marking events yet, we carefully |
92 // mark with a conservative lower bound for the marking speed. | 80 // mark with a conservative lower bound for the marking speed. |
93 static const size_t kInitialConservativeMarkingSpeed = 100 * KB; | 81 static const size_t kInitialConservativeMarkingSpeed = 100 * KB; |
(...skipping 23 matching lines...) Expand all Loading... |
117 | 105 |
118 // This is the maximum scheduled idle time. Note that it can be more than | 106 // This is the maximum scheduled idle time. Note that it can be more than |
119 // 16.66 ms when there is currently no rendering going on. | 107 // 16.66 ms when there is currently no rendering going on. |
120 static const size_t kMaxScheduledIdleTime = 50; | 108 static const size_t kMaxScheduledIdleTime = 50; |
121 | 109 |
122 // The maximum idle time when frames are rendered is 16.66ms. | 110 // The maximum idle time when frames are rendered is 16.66ms. |
123 static const size_t kMaxFrameRenderingIdleTime = 17; | 111 static const size_t kMaxFrameRenderingIdleTime = 17; |
124 | 112 |
125 static const int kMinBackgroundIdleTime = 900; | 113 static const int kMinBackgroundIdleTime = 900; |
126 | 114 |
127 // We conservatively assume that in the next kTimeUntilNextIdleEvent ms | |
128 // no idle notification happens. | |
129 static const size_t kTimeUntilNextIdleEvent = 100; | |
130 | |
131 // An allocation throughput below kLowAllocationThroughput bytes/ms is | 115 // An allocation throughput below kLowAllocationThroughput bytes/ms is |
132 // considered low | 116 // considered low |
133 static const size_t kLowAllocationThroughput = 1000; | 117 static const size_t kLowAllocationThroughput = 1000; |
134 | 118 |
135 // If we haven't recorded any scavenger events yet, we use a conservative | |
136 // lower bound for the scavenger speed. | |
137 static const size_t kInitialConservativeScavengeSpeed = 100 * KB; | |
138 | |
139 // The minimum size of allocated new space objects to trigger a scavenge. | |
140 static const size_t kMinimumNewSpaceSizeToPerformScavenge = MB / 2; | |
141 | |
142 // If contexts are disposed at a higher rate a full gc is triggered. | 119 // If contexts are disposed at a higher rate a full gc is triggered. |
143 static const double kHighContextDisposalRate; | 120 static const double kHighContextDisposalRate; |
144 | 121 |
145 // Incremental marking step time. | 122 // Incremental marking step time. |
146 static const size_t kIncrementalMarkingStepTimeInMs = 1; | 123 static const size_t kIncrementalMarkingStepTimeInMs = 1; |
147 | 124 |
148 static const size_t kMinTimeForOverApproximatingWeakClosureInMs; | 125 static const size_t kMinTimeForOverApproximatingWeakClosureInMs; |
149 | 126 |
150 // Number of times we will return a Nothing action in the current mode | 127 // Number of times we will return a Nothing action in the current mode |
151 // despite having idle time available before we returning a Done action to | 128 // despite having idle time available before we returning a Done action to |
(...skipping 22 matching lines...) Expand all Loading... |
174 | 151 |
175 static bool ShouldDoContextDisposalMarkCompact(int context_disposed, | 152 static bool ShouldDoContextDisposalMarkCompact(int context_disposed, |
176 double contexts_disposal_rate); | 153 double contexts_disposal_rate); |
177 | 154 |
178 static bool ShouldDoFinalIncrementalMarkCompact( | 155 static bool ShouldDoFinalIncrementalMarkCompact( |
179 size_t idle_time_in_ms, size_t size_of_objects, | 156 size_t idle_time_in_ms, size_t size_of_objects, |
180 size_t final_incremental_mark_compact_speed_in_bytes_per_ms); | 157 size_t final_incremental_mark_compact_speed_in_bytes_per_ms); |
181 | 158 |
182 static bool ShouldDoOverApproximateWeakClosure(size_t idle_time_in_ms); | 159 static bool ShouldDoOverApproximateWeakClosure(size_t idle_time_in_ms); |
183 | 160 |
184 static bool ShouldDoScavenge( | |
185 size_t idle_time_in_ms, size_t new_space_size, size_t used_new_space_size, | |
186 size_t scavenger_speed_in_bytes_per_ms, | |
187 size_t new_space_allocation_throughput_in_bytes_per_ms); | |
188 | |
189 private: | 161 private: |
190 GCIdleTimeAction NothingOrDone(double idle_time_in_ms); | 162 GCIdleTimeAction NothingOrDone(double idle_time_in_ms); |
191 | 163 |
192 // Idle notifications with no progress. | 164 // Idle notifications with no progress. |
193 int idle_times_which_made_no_progress_; | 165 int idle_times_which_made_no_progress_; |
194 | 166 |
195 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); | 167 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); |
196 }; | 168 }; |
197 | 169 |
198 } // namespace internal | 170 } // namespace internal |
199 } // namespace v8 | 171 } // namespace v8 |
200 | 172 |
201 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ | 173 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ |
OLD | NEW |