30 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
31 #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp"
32 #include "logging/log.hpp"
33 #include "logging/logTag.hpp"
34
35 ShenandoahCompactHeuristics::ShenandoahCompactHeuristics(ShenandoahSpaceInfo* space_info) :
36 ShenandoahHeuristics(space_info) {
37 SHENANDOAH_ERGO_ENABLE_FLAG(ExplicitGCInvokesConcurrent);
38 SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent);
39 SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahUncommit);
40 SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahAlwaysClearSoftRefs);
41 SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahAllocationThreshold, 10);
42 SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahImmediateThreshold, 100);
43 SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahUncommitDelay, 1000);
44 SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGuaranteedGCInterval, 30000);
45 SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGarbageThreshold, 10);
46 }
47
48 bool ShenandoahCompactHeuristics::should_start_gc() {
49 size_t max_capacity = _space_info->max_capacity();
50 size_t capacity = _space_info->soft_max_capacity();
51 size_t available = _space_info->available();
52
53 // Make sure the code below treats available without the soft tail.
54 size_t soft_tail = max_capacity - capacity;
55 available = (available > soft_tail) ? (available - soft_tail) : 0;
56
57 size_t threshold_bytes_allocated = capacity / 100 * ShenandoahAllocationThreshold;
58 size_t min_threshold = capacity / 100 * ShenandoahMinFreeThreshold;
59
60 if (available < min_threshold) {
61 log_trigger("Free (%zu%s) is below minimum threshold (%zu%s)",
62 byte_size_in_proper_unit(available), proper_unit_for_byte_size(available),
63 byte_size_in_proper_unit(min_threshold), proper_unit_for_byte_size(min_threshold));
64 accept_trigger();
65 return true;
66 }
67
68 size_t bytes_allocated = _space_info->bytes_allocated_since_gc_start();
69 if (bytes_allocated > threshold_bytes_allocated) {
70 log_trigger("Allocated since last cycle (%zu%s) is larger than allocation threshold (%zu%s)",
|
30 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
31 #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp"
32 #include "logging/log.hpp"
33 #include "logging/logTag.hpp"
34
35 ShenandoahCompactHeuristics::ShenandoahCompactHeuristics(ShenandoahSpaceInfo* space_info) :
36 ShenandoahHeuristics(space_info) {
37 SHENANDOAH_ERGO_ENABLE_FLAG(ExplicitGCInvokesConcurrent);
38 SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent);
39 SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahUncommit);
40 SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahAlwaysClearSoftRefs);
41 SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahAllocationThreshold, 10);
42 SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahImmediateThreshold, 100);
43 SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahUncommitDelay, 1000);
44 SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGuaranteedGCInterval, 30000);
45 SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGarbageThreshold, 10);
46 }
47
48 bool ShenandoahCompactHeuristics::should_start_gc() {
49 size_t max_capacity = _space_info->max_capacity();
50 size_t capacity = ShenandoahHeap::heap()->soft_max_capacity();
51 size_t available = _space_info->available();
52
53 // Make sure the code below treats available without the soft tail.
54 size_t soft_tail = max_capacity - capacity;
55 available = (available > soft_tail) ? (available - soft_tail) : 0;
56
57 size_t threshold_bytes_allocated = capacity / 100 * ShenandoahAllocationThreshold;
58 size_t min_threshold = capacity / 100 * ShenandoahMinFreeThreshold;
59
60 if (available < min_threshold) {
61 log_trigger("Free (%zu%s) is below minimum threshold (%zu%s)",
62 byte_size_in_proper_unit(available), proper_unit_for_byte_size(available),
63 byte_size_in_proper_unit(min_threshold), proper_unit_for_byte_size(min_threshold));
64 accept_trigger();
65 return true;
66 }
67
68 size_t bytes_allocated = _space_info->bytes_allocated_since_gc_start();
69 if (bytes_allocated > threshold_bytes_allocated) {
70 log_trigger("Allocated since last cycle (%zu%s) is larger than allocation threshold (%zu%s)",
|