24 #include "precompiled.hpp"
25
26 #include "gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp"
27 #include "gc/shenandoah/shenandoahCollectionSet.hpp"
28 #include "gc/shenandoah/shenandoahFreeSet.hpp"
29 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
30 #include "logging/log.hpp"
31 #include "logging/logTag.hpp"
32 #include "utilities/quickSort.hpp"
33
34 ShenandoahAdaptiveHeuristics::ShenandoahAdaptiveHeuristics() :
35 ShenandoahHeuristics(),
36 _cycle_gap_history(new TruncatedSeq(5)),
37 _conc_mark_duration_history(new TruncatedSeq(5)),
38 _conc_uprefs_duration_history(new TruncatedSeq(5)) {
39
40 SHENANDOAH_ERGO_ENABLE_FLAG(ExplicitGCInvokesConcurrent);
41 SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent);
42
43 // Final configuration checks
44 SHENANDOAH_CHECK_FLAG_SET(ShenandoahSATBBarrier);
45 SHENANDOAH_CHECK_FLAG_SET(ShenandoahReadBarrier);
46 SHENANDOAH_CHECK_FLAG_SET(ShenandoahWriteBarrier);
47 SHENANDOAH_CHECK_FLAG_SET(ShenandoahStoreValReadBarrier);
48 SHENANDOAH_CHECK_FLAG_SET(ShenandoahKeepAliveBarrier);
49 SHENANDOAH_CHECK_FLAG_SET(ShenandoahCASBarrier);
50 SHENANDOAH_CHECK_FLAG_SET(ShenandoahAcmpBarrier);
51 SHENANDOAH_CHECK_FLAG_SET(ShenandoahCloneBarrier);
52 }
53
54 ShenandoahAdaptiveHeuristics::~ShenandoahAdaptiveHeuristics() {}
55
56 void ShenandoahAdaptiveHeuristics::choose_collection_set_from_regiondata(ShenandoahCollectionSet* cset,
57 RegionData* data, size_t size,
58 size_t actual_free) {
59 size_t garbage_threshold = ShenandoahHeapRegion::region_size_bytes() * ShenandoahGarbageThreshold / 100;
60
61 // The logic for cset selection in adaptive is as follows:
62 //
63 // 1. We cannot get cset larger than available free space. Otherwise we guarantee OOME
64 // during evacuation, and thus guarantee full GC. In practice, we also want to let
65 // application to allocate something. This is why we limit CSet to some fraction of
66 // available space. In non-overloaded heap, max_cset would contain all plausible candidates
67 // over garbage threshold.
68 //
69 // 2. We should not get cset too low so that free threshold would not be met right
70 // after the cycle. Otherwise we get back-to-back cycles for no reason if heap is
|
24 #include "precompiled.hpp"
25
26 #include "gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp"
27 #include "gc/shenandoah/shenandoahCollectionSet.hpp"
28 #include "gc/shenandoah/shenandoahFreeSet.hpp"
29 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
30 #include "logging/log.hpp"
31 #include "logging/logTag.hpp"
32 #include "utilities/quickSort.hpp"
33
34 ShenandoahAdaptiveHeuristics::ShenandoahAdaptiveHeuristics() :
35 ShenandoahHeuristics(),
36 _cycle_gap_history(new TruncatedSeq(5)),
37 _conc_mark_duration_history(new TruncatedSeq(5)),
38 _conc_uprefs_duration_history(new TruncatedSeq(5)) {
39
40 SHENANDOAH_ERGO_ENABLE_FLAG(ExplicitGCInvokesConcurrent);
41 SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent);
42
43 // Final configuration checks
44 SHENANDOAH_CHECK_FLAG_SET(ShenandoahLoadRefBarrier);
45 SHENANDOAH_CHECK_FLAG_SET(ShenandoahSATBBarrier);
46 SHENANDOAH_CHECK_FLAG_SET(ShenandoahKeepAliveBarrier);
47 SHENANDOAH_CHECK_FLAG_SET(ShenandoahCASBarrier);
48 SHENANDOAH_CHECK_FLAG_SET(ShenandoahCloneBarrier);
49 }
50
51 ShenandoahAdaptiveHeuristics::~ShenandoahAdaptiveHeuristics() {}
52
53 void ShenandoahAdaptiveHeuristics::choose_collection_set_from_regiondata(ShenandoahCollectionSet* cset,
54 RegionData* data, size_t size,
55 size_t actual_free) {
56 size_t garbage_threshold = ShenandoahHeapRegion::region_size_bytes() * ShenandoahGarbageThreshold / 100;
57
58 // The logic for cset selection in adaptive is as follows:
59 //
60 // 1. We cannot get cset larger than available free space. Otherwise we guarantee OOME
61 // during evacuation, and thus guarantee full GC. In practice, we also want to let
62 // application to allocate something. This is why we limit CSet to some fraction of
63 // available space. In non-overloaded heap, max_cset would contain all plausible candidates
64 // over garbage threshold.
65 //
66 // 2. We should not get cset too low so that free threshold would not be met right
67 // after the cycle. Otherwise we get back-to-back cycles for no reason if heap is
|