| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 // If we haven't recorded any mark-compact events yet, we use | 84 // If we haven't recorded any mark-compact events yet, we use |
| 85 // conservative lower bound for the mark-compact speed. | 85 // conservative lower bound for the mark-compact speed. |
| 86 static const size_t kInitialConservativeMarkCompactSpeed = 2 * MB; | 86 static const size_t kInitialConservativeMarkCompactSpeed = 2 * MB; |
| 87 | 87 |
| 88 // If we haven't recorded any final incremental mark-compact events yet, we | 88 // If we haven't recorded any final incremental mark-compact events yet, we |
| 89 // use conservative lower bound for the mark-compact speed. | 89 // use conservative lower bound for the mark-compact speed. |
| 90 static const size_t kInitialConservativeFinalIncrementalMarkCompactSpeed = | 90 static const size_t kInitialConservativeFinalIncrementalMarkCompactSpeed = |
| 91 2 * MB; | 91 2 * MB; |
| 92 | 92 |
| 93 // Maximum mark-compact time returned by EstimateMarkCompactTime. | |
| 94 static const size_t kMaxMarkCompactTimeInMs; | |
| 95 | |
| 96 // Maximum final incremental mark-compact time returned by | 93 // Maximum final incremental mark-compact time returned by |
| 97 // EstimateFinalIncrementalMarkCompactTime. | 94 // EstimateFinalIncrementalMarkCompactTime. |
| 98 static const size_t kMaxFinalIncrementalMarkCompactTimeInMs; | 95 static const size_t kMaxFinalIncrementalMarkCompactTimeInMs; |
| 99 | 96 |
| 100 // This is the maximum scheduled idle time. Note that it can be more than | 97 // This is the maximum scheduled idle time. Note that it can be more than |
| 101 // 16.66 ms when there is currently no rendering going on. | 98 // 16.66 ms when there is currently no rendering going on. |
| 102 static const size_t kMaxScheduledIdleTime = 50; | 99 static const size_t kMaxScheduledIdleTime = 50; |
| 103 | 100 |
| 104 // The maximum idle time when frames are rendered is 16.66ms. | 101 // The maximum idle time when frames are rendered is 16.66ms. |
| 105 static const size_t kMaxFrameRenderingIdleTime = 17; | 102 static const size_t kMaxFrameRenderingIdleTime = 17; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 123 // ensure we don't keep scheduling idle tasks and making no progress. | 120 // ensure we don't keep scheduling idle tasks and making no progress. |
| 124 static const int kMaxNoProgressIdleTimes = 10; | 121 static const int kMaxNoProgressIdleTimes = 10; |
| 125 | 122 |
| 126 GCIdleTimeHandler() : idle_times_which_made_no_progress_(0) {} | 123 GCIdleTimeHandler() : idle_times_which_made_no_progress_(0) {} |
| 127 | 124 |
| 128 GCIdleTimeAction Compute(double idle_time_in_ms, | 125 GCIdleTimeAction Compute(double idle_time_in_ms, |
| 129 GCIdleTimeHeapState heap_state); | 126 GCIdleTimeHeapState heap_state); |
| 130 | 127 |
| 131 void ResetNoProgressCounter() { idle_times_which_made_no_progress_ = 0; } | 128 void ResetNoProgressCounter() { idle_times_which_made_no_progress_ = 0; } |
| 132 | 129 |
| 133 static size_t EstimateMarkingStepSize(size_t idle_time_in_ms, | 130 static size_t EstimateMarkingStepSize(double idle_time_in_ms, |
| 134 size_t marking_speed_in_bytes_per_ms); | 131 double marking_speed_in_bytes_per_ms); |
| 135 | 132 |
| 136 static size_t EstimateMarkCompactTime( | 133 static double EstimateFinalIncrementalMarkCompactTime( |
| 137 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms); | 134 size_t size_of_objects, double mark_compact_speed_in_bytes_per_ms); |
| 138 | |
| 139 static size_t EstimateFinalIncrementalMarkCompactTime( | |
| 140 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms); | |
| 141 | |
| 142 static bool ShouldDoMarkCompact(size_t idle_time_in_ms, | |
| 143 size_t size_of_objects, | |
| 144 size_t mark_compact_speed_in_bytes_per_ms); | |
| 145 | 135 |
| 146 static bool ShouldDoContextDisposalMarkCompact(int context_disposed, | 136 static bool ShouldDoContextDisposalMarkCompact(int context_disposed, |
| 147 double contexts_disposal_rate); | 137 double contexts_disposal_rate); |
| 148 | 138 |
| 149 static bool ShouldDoFinalIncrementalMarkCompact( | 139 static bool ShouldDoFinalIncrementalMarkCompact( |
| 150 size_t idle_time_in_ms, size_t size_of_objects, | 140 double idle_time_in_ms, size_t size_of_objects, |
| 151 size_t final_incremental_mark_compact_speed_in_bytes_per_ms); | 141 double final_incremental_mark_compact_speed_in_bytes_per_ms); |
| 152 | 142 |
| 153 static bool ShouldDoOverApproximateWeakClosure(size_t idle_time_in_ms); | 143 static bool ShouldDoOverApproximateWeakClosure(double idle_time_in_ms); |
| 154 | 144 |
| 155 private: | 145 private: |
| 156 GCIdleTimeAction NothingOrDone(double idle_time_in_ms); | 146 GCIdleTimeAction NothingOrDone(double idle_time_in_ms); |
| 157 | 147 |
| 158 // Idle notifications with no progress. | 148 // Idle notifications with no progress. |
| 159 int idle_times_which_made_no_progress_; | 149 int idle_times_which_made_no_progress_; |
| 160 | 150 |
| 161 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); | 151 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); |
| 162 }; | 152 }; |
| 163 | 153 |
| 164 } // namespace internal | 154 } // namespace internal |
| 165 } // namespace v8 | 155 } // namespace v8 |
| 166 | 156 |
| 167 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ | 157 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ |
| OLD | NEW |