| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 GCIdleTimeAction result; | 42 GCIdleTimeAction result; |
| 43 result.type = DO_FULL_GC; | 43 result.type = DO_FULL_GC; |
| 44 result.parameter = 0; | 44 result.parameter = 0; |
| 45 return result; | 45 return result; |
| 46 } | 46 } |
| 47 | 47 |
| 48 GCIdleTimeActionType type; | 48 GCIdleTimeActionType type; |
| 49 intptr_t parameter; | 49 intptr_t parameter; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 | |
| 53 class GCTracer; | 52 class GCTracer; |
| 54 | 53 |
| 55 // The idle time handler makes decisions about which garbage collection | 54 // The idle time handler makes decisions about which garbage collection |
| 56 // operations are executing during IdleNotification. | 55 // operations are executing during IdleNotification. |
| 57 class GCIdleTimeHandler { | 56 class GCIdleTimeHandler { |
| 58 public: | 57 public: |
| 59 // If we haven't recorded any incremental marking events yet, we carefully | 58 // If we haven't recorded any incremental marking events yet, we carefully |
| 60 // mark with a conservative lower bound for the marking speed. | 59 // mark with a conservative lower bound for the marking speed. |
| 61 static const size_t kInitialConservativeMarkingSpeed = 100 * KB; | 60 static const size_t kInitialConservativeMarkingSpeed = 100 * KB; |
| 62 | 61 |
| 63 // Maximum marking step size returned by EstimateMarkingStepSize. | 62 // Maximum marking step size returned by EstimateMarkingStepSize. |
| 64 static const size_t kMaximumMarkingStepSize = 700 * MB; | 63 static const size_t kMaximumMarkingStepSize = 700 * MB; |
| 65 | 64 |
| 66 // We have to make sure that we finish the IdleNotification before | 65 // We have to make sure that we finish the IdleNotification before |
| 67 // idle_time_in_ms. Hence, we conservatively prune our workload estimate. | 66 // idle_time_in_ms. Hence, we conservatively prune our workload estimate. |
| 68 static const double kConservativeTimeRatio; | 67 static const double kConservativeTimeRatio; |
| 69 | 68 |
| 70 // If we haven't recorded any mark-compact events yet, we use | 69 // If we haven't recorded any mark-compact events yet, we use |
| 71 // conservative lower bound for the mark-compact speed. | 70 // conservative lower bound for the mark-compact speed. |
| 72 static const size_t kInitialConservativeMarkCompactSpeed = 2 * MB; | 71 static const size_t kInitialConservativeMarkCompactSpeed = 2 * MB; |
| 73 | 72 |
| 74 // Maximum mark-compact time returned by EstimateMarkCompactTime. | 73 // Maximum mark-compact time returned by EstimateMarkCompactTime. |
| 75 static const size_t kMaxMarkCompactTimeInMs; | 74 static const size_t kMaxMarkCompactTimeInMs; |
| 76 | 75 |
| 77 struct HeapState { | |
| 78 int contexts_disposed; | |
| 79 size_t size_of_objects; | |
| 80 bool incremental_marking_stopped; | |
| 81 bool can_start_incremental_marking; | |
| 82 }; | |
| 83 | |
| 84 GCIdleTimeHandler() | 76 GCIdleTimeHandler() |
| 85 : mark_compacts_since_idle_round_started_(0), | 77 : mark_compacts_since_idle_round_started_(0), |
| 86 scavenges_since_last_idle_round_(0) {} | 78 scavenges_since_last_idle_round_(0) {} |
| 87 | 79 |
| 88 GCIdleTimeAction Compute(int idle_time_in_ms, HeapState heap_state, | 80 GCIdleTimeAction Compute(int idle_time_in_ms, int contexts_disposed, |
| 81 size_t size_of_objects, |
| 82 bool incremental_marking_stopped, |
| 89 GCTracer* gc_tracer); | 83 GCTracer* gc_tracer); |
| 90 | 84 |
| 91 void NotifyIdleMarkCompact() { | 85 void NotifyIdleMarkCompact() { |
| 92 if (mark_compacts_since_idle_round_started_ < kMaxMarkCompactsInIdleRound) { | 86 if (mark_compacts_since_idle_round_started_ < kMaxMarkCompactsInIdleRound) { |
| 93 ++mark_compacts_since_idle_round_started_; | 87 ++mark_compacts_since_idle_round_started_; |
| 94 if (mark_compacts_since_idle_round_started_ == | 88 if (mark_compacts_since_idle_round_started_ == |
| 95 kMaxMarkCompactsInIdleRound) { | 89 kMaxMarkCompactsInIdleRound) { |
| 96 scavenges_since_last_idle_round_ = 0; | 90 scavenges_since_last_idle_round_ = 0; |
| 97 } | 91 } |
| 98 } | 92 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 121 int mark_compacts_since_idle_round_started_; | 115 int mark_compacts_since_idle_round_started_; |
| 122 int scavenges_since_last_idle_round_; | 116 int scavenges_since_last_idle_round_; |
| 123 | 117 |
| 124 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); | 118 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); |
| 125 }; | 119 }; |
| 126 | 120 |
| 127 } // namespace internal | 121 } // namespace internal |
| 128 } // namespace v8 | 122 } // namespace v8 |
| 129 | 123 |
| 130 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ | 124 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ |
| OLD | NEW |