122 // ShenandoahGarbageThreshold is the soft threshold which would be ignored until min_garbage is hit. |
122 // ShenandoahGarbageThreshold is the soft threshold which would be ignored until min_garbage is hit. |
123 // |
123 // |
124 // The significant complication is that liveness data was collected at the previous cycle, and only |
124 // The significant complication is that liveness data was collected at the previous cycle, and only |
125 // for those regions that were allocated before previous cycle started. |
125 // for those regions that were allocated before previous cycle started. |
126 |
126 |
127 size_t capacity = heap->capacity(); |
127 size_t capacity = heap->max_capacity(); |
128 size_t actual_free = heap->free_set()->available(); |
128 size_t actual_free = heap->free_set()->available(); |
129 size_t free_target = ShenandoahMinFreeThreshold * capacity / 100; |
129 size_t free_target = ShenandoahMinFreeThreshold * capacity / 100; |
130 size_t min_garbage = free_target > actual_free ? (free_target - actual_free) : 0; |
130 size_t min_garbage = free_target > actual_free ? (free_target - actual_free) : 0; |
131 size_t max_cset = (size_t)(1.0 * ShenandoahEvacReserve * capacity / 100 / ShenandoahEvacWaste); |
131 size_t max_cset = (size_t)(1.0 * ShenandoahEvacReserve * capacity / 100 / ShenandoahEvacWaste); |
132 |
132 |
211 |
211 |
212 bool ShenandoahTraversalHeuristics::should_start_traversal_gc() { |
212 bool ShenandoahTraversalHeuristics::should_start_traversal_gc() { |
213 ShenandoahHeap* heap = ShenandoahHeap::heap(); |
213 ShenandoahHeap* heap = ShenandoahHeap::heap(); |
214 assert(!heap->has_forwarded_objects(), "no forwarded objects here"); |
214 assert(!heap->has_forwarded_objects(), "no forwarded objects here"); |
215 |
215 |
216 size_t capacity = heap->capacity(); |
216 size_t capacity = heap->max_capacity(); |
217 size_t available = heap->free_set()->available(); |
217 size_t available = heap->free_set()->available(); |
218 |
218 |
219 // Check if we are falling below the worst limit, time to trigger the GC, regardless of |
219 // Check if we are falling below the worst limit, time to trigger the GC, regardless of |
220 // anything else. |
220 // anything else. |
221 size_t min_threshold = ShenandoahMinFreeThreshold * heap->capacity() / 100; |
221 size_t min_threshold = ShenandoahMinFreeThreshold * heap->max_capacity() / 100; |
222 if (available < min_threshold) { |
222 if (available < min_threshold) { |
223 log_info(gc)("Trigger: Free (" SIZE_FORMAT "M) is below minimum threshold (" SIZE_FORMAT "M)", |
223 log_info(gc)("Trigger: Free (" SIZE_FORMAT "M) is below minimum threshold (" SIZE_FORMAT "M)", |
224 available / M, min_threshold / M); |
224 available / M, min_threshold / M); |
225 return true; |
225 return true; |
226 } |
226 } |
227 |
227 |
228 // Check if are need to learn a bit about the application |
228 // Check if are need to learn a bit about the application |
229 const size_t max_learn = ShenandoahLearningSteps; |
229 const size_t max_learn = ShenandoahLearningSteps; |
230 if (_gc_times_learned < max_learn) { |
230 if (_gc_times_learned < max_learn) { |
231 size_t init_threshold = ShenandoahInitFreeThreshold * heap->capacity() / 100; |
231 size_t init_threshold = ShenandoahInitFreeThreshold * heap->max_capacity() / 100; |
232 if (available < init_threshold) { |
232 if (available < init_threshold) { |
233 log_info(gc)("Trigger: Learning " SIZE_FORMAT " of " SIZE_FORMAT ". Free (" SIZE_FORMAT "M) is below initial threshold (" SIZE_FORMAT "M)", |
233 log_info(gc)("Trigger: Learning " SIZE_FORMAT " of " SIZE_FORMAT ". Free (" SIZE_FORMAT "M) is below initial threshold (" SIZE_FORMAT "M)", |
234 _gc_times_learned + 1, max_learn, available / M, init_threshold / M); |
234 _gc_times_learned + 1, max_learn, available / M, init_threshold / M); |
235 return true; |
235 return true; |
236 } |
236 } |