36 FLAG_SET_DEFAULT(name, false); \
37 } \
38 } while (0)
39
40 #define SHENANDOAH_ERGO_ENABLE_FLAG(name) \
41 do { \
42 if (FLAG_IS_DEFAULT(name) && !(name)) { \
43 log_info(gc)("Heuristics ergonomically sets -XX:+" #name); \
44 FLAG_SET_DEFAULT(name, true); \
45 } \
46 } while (0)
47
48 #define SHENANDOAH_ERGO_OVERRIDE_DEFAULT(name, value) \
49 do { \
50 if (FLAG_IS_DEFAULT(name)) { \
51 log_info(gc)("Heuristics ergonomically sets -XX:" #name "=" #value); \
52 FLAG_SET_DEFAULT(name, value); \
53 } \
54 } while (0)
55
56
57 class ShenandoahCollectionSet;
58 class ShenandoahHeapRegion;
59
60 class ShenandoahHeuristics : public CHeapObj<mtGC> {
61 protected:
62 typedef struct {
63 ShenandoahHeapRegion* _region;
64 size_t _garbage;
65 uint64_t _seqnum_last_alloc;
66 } RegionData;
67
68 typedef struct {
69 ShenandoahHeapRegion* _region;
70 size_t _connections;
71 } RegionConnections;
72
73 bool _update_refs_early;
74 bool _update_refs_adaptive;
75
76 RegionData* _region_data;
77 size_t _region_data_size;
78
79 RegionConnections* _region_connects;
80 size_t _region_connects_size;
81
82 uint _degenerated_cycles_in_a_row;
83 uint _successful_cycles_in_a_row;
84
85 size_t _bytes_in_cset;
86
87 double _last_cycle_end;
88
89 static int compare_by_garbage(RegionData a, RegionData b);
90 static int compare_by_alloc_seq_ascending(RegionData a, RegionData b);
91 static int compare_by_alloc_seq_descending(RegionData a, RegionData b);
92 static int compare_by_connects(RegionConnections a, RegionConnections b);
93
94 RegionData* get_region_data_cache(size_t num);
95
96 RegionConnections* get_region_connects_cache(size_t num);
97
98 virtual void choose_collection_set_from_regiondata(ShenandoahCollectionSet* set,
99 RegionData* data, size_t data_size,
100 size_t free) = 0;
101
102 public:
103
104 ShenandoahHeuristics();
105 virtual ~ShenandoahHeuristics();
106
107 void record_gc_start();
108
109 void record_gc_end();
110
111 virtual void record_cycle_start();
112
113 virtual void record_cycle_end();
114
115 virtual void record_phase_time(ShenandoahPhaseTimings::Phase phase, double secs);
116
117 virtual void print_thresholds();
118
119 virtual bool should_start_normal_gc() const = 0;
120
121 virtual bool should_start_update_refs();
122
123 virtual bool update_refs() const;
124
125 virtual bool should_degenerate_cycle();
126
127 virtual void record_success_concurrent();
128
129 virtual void record_success_degenerated();
130
131 virtual void record_success_full();
132
133 virtual void record_allocation_failure_gc();
134
135 virtual void record_explicit_gc();
136
137 virtual void record_peak_occupancy();
138
139 virtual void start_choose_collection_set() {
140 }
141 virtual void end_choose_collection_set() {
142 }
143
144 virtual void choose_collection_set(ShenandoahCollectionSet* collection_set);
145
146 virtual bool should_process_references();
147
148 virtual bool should_unload_classes();
149
150 virtual const char* name() = 0;
151 virtual bool is_diagnostic() = 0;
152 virtual bool is_experimental() = 0;
153 virtual void initialize();
154
155 };
156
157 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHHEURISTICS_HPP
|
36 FLAG_SET_DEFAULT(name, false); \
37 } \
38 } while (0)
39
40 #define SHENANDOAH_ERGO_ENABLE_FLAG(name) \
41 do { \
42 if (FLAG_IS_DEFAULT(name) && !(name)) { \
43 log_info(gc)("Heuristics ergonomically sets -XX:+" #name); \
44 FLAG_SET_DEFAULT(name, true); \
45 } \
46 } while (0)
47
48 #define SHENANDOAH_ERGO_OVERRIDE_DEFAULT(name, value) \
49 do { \
50 if (FLAG_IS_DEFAULT(name)) { \
51 log_info(gc)("Heuristics ergonomically sets -XX:" #name "=" #value); \
52 FLAG_SET_DEFAULT(name, value); \
53 } \
54 } while (0)
55
56 class ShenandoahCollectionSet;
57 class ShenandoahHeapRegion;
58
59 class ShenandoahHeuristics : public CHeapObj<mtGC> {
60 static const intx Concurrent_Adjust = 1; // recover from penalties
61 static const intx Degenerated_Penalty = 10; // how much to penalize average GC duration history on Degenerated GC
62 static const intx Full_Penalty = 20; // how much to penalize average GC duration history on Full GC
63
64 protected:
65 typedef struct {
66 ShenandoahHeapRegion* _region;
67 size_t _garbage;
68 uint64_t _seqnum_last_alloc;
69 } RegionData;
70
71 bool _update_refs_early;
72 bool _update_refs_adaptive;
73
74 RegionData* _region_data;
75 size_t _region_data_size;
76
77 uint _degenerated_cycles_in_a_row;
78 uint _successful_cycles_in_a_row;
79
80 size_t _bytes_in_cset;
81
82 double _cycle_start;
83 double _last_cycle_end;
84
85 size_t _gc_times_learned;
86 size_t _gc_time_penalties;
87 TruncatedSeq* _gc_time_history;
88
89 static int compare_by_garbage(RegionData a, RegionData b);
90 static int compare_by_alloc_seq_ascending(RegionData a, RegionData b);
91 static int compare_by_alloc_seq_descending(RegionData a, RegionData b);
92
93 RegionData* get_region_data_cache(size_t num);
94
95 virtual void choose_collection_set_from_regiondata(ShenandoahCollectionSet* set,
96 RegionData* data, size_t data_size,
97 size_t free) = 0;
98
99 public:
100
101 ShenandoahHeuristics();
102 virtual ~ShenandoahHeuristics();
103
104 void record_gc_start();
105
106 void record_gc_end();
107
108 virtual void record_cycle_start();
109
110 virtual void record_cycle_end();
111
112 virtual void record_phase_time(ShenandoahPhaseTimings::Phase phase, double secs);
113
114 virtual bool should_start_normal_gc() const;
115
116 virtual bool should_start_update_refs();
117
118 virtual bool should_degenerate_cycle();
119
120 virtual void record_success_concurrent();
121
122 virtual void record_success_degenerated();
123
124 virtual void record_success_full();
125
126 virtual void record_allocation_failure_gc();
127
128 virtual void record_explicit_gc();
129
130 virtual void start_choose_collection_set() {
131 }
132 virtual void end_choose_collection_set() {
133 }
134
135 virtual void choose_collection_set(ShenandoahCollectionSet* collection_set);
136
137 virtual bool should_process_references();
138
139 virtual bool should_unload_classes();
140
141 virtual const char* name() = 0;
142 virtual bool is_diagnostic() = 0;
143 virtual bool is_experimental() = 0;
144 virtual void initialize();
145
146 };
147
148 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHHEURISTICS_HPP
|