131 size_t pred_promotion_size = (size_t)(pred_marking_time * pred_promotion_rate);
132
133 size_t predicted_needed_bytes_during_marking =
134 pred_promotion_size +
135 // In reality we would need the maximum size of the young gen during
136 // marking. This is a conservative estimate.
137 _last_unrestrained_young_size;
138
139 size_t internal_threshold = actual_target_threshold();
140 size_t predicted_initiating_threshold = predicted_needed_bytes_during_marking < internal_threshold ?
141 internal_threshold - predicted_needed_bytes_during_marking :
142 0;
143 return predicted_initiating_threshold;
144 } else {
145 // Use the initial value.
146 return (size_t)(_initial_ihop_percent * _target_occupancy / 100.0);
147 }
148 }
149
150 double G1AdaptiveIHOPControl::last_mutator_period_old_allocation_rate() const {
151 // The upper limit of the freed region count is the number of regions allocated
152 // since the last gc. When more humongous regions survived the current gc than
153 // survived the previous one, deduct the increment.
154 assert(_last_allocation_time_s > 0, "This should not be called when the last GC is full");
155 size_t freed_humongous_bytes = _old_gen_alloc_tracker->_last_period_humongous_bytes;
156 size_t humongous_bytes_after_penultimate_gc = _old_gen_alloc_tracker->_humongous_bytes_after_penultimate_gc;
157 size_t humongous_bytes_after_last_gc = _old_gen_alloc_tracker->_humongous_bytes_after_last_gc;
158 size_t last_period_old_bytes = _old_gen_alloc_tracker->last_period_old_bytes();
159
160 if (freed_humongous_bytes > 0 && humongous_bytes_after_penultimate_gc < humongous_bytes_after_last_gc) {
161 freed_humongous_bytes -= humongous_bytes_after_last_gc - humongous_bytes_after_penultimate_gc;
162 }
163 assert(last_period_old_bytes >= freed_humongous_bytes, "Allocation rate cannot be negative");
164 return (last_period_old_bytes - freed_humongous_bytes) / _last_allocation_time_s;
165 }
166
167 void G1AdaptiveIHOPControl::update_allocation_info(double allocation_time_s,
168 size_t additional_buffer_size) {
169 G1IHOPControl::update_allocation_info(allocation_time_s, additional_buffer_size);
170 _allocation_rate_s.add(last_mutator_period_old_allocation_rate());
171
172 _last_unrestrained_young_size = additional_buffer_size;
173 }
174
175 void G1AdaptiveIHOPControl::update_marking_length(double marking_length_s) {
176 assert(marking_length_s >= 0.0, "Marking length must be larger than zero but is %.3f", marking_length_s);
177 _marking_times_s.add(marking_length_s);
178 }
179
180 void G1AdaptiveIHOPControl::print() {
181 G1IHOPControl::print();
182 size_t actual_target = actual_target_threshold();
183 log_debug(gc, ihop)("Adaptive IHOP information (value update), threshold: " SIZE_FORMAT "B (%1.2f), internal target occupancy: " SIZE_FORMAT "B, "
184 "occupancy: " SIZE_FORMAT "B, additional buffer size: " SIZE_FORMAT "B, predicted old gen allocation rate: %1.2fB/s, "
|
131 size_t pred_promotion_size = (size_t)(pred_marking_time * pred_promotion_rate);
132
133 size_t predicted_needed_bytes_during_marking =
134 pred_promotion_size +
135 // In reality we would need the maximum size of the young gen during
136 // marking. This is a conservative estimate.
137 _last_unrestrained_young_size;
138
139 size_t internal_threshold = actual_target_threshold();
140 size_t predicted_initiating_threshold = predicted_needed_bytes_during_marking < internal_threshold ?
141 internal_threshold - predicted_needed_bytes_during_marking :
142 0;
143 return predicted_initiating_threshold;
144 } else {
145 // Use the initial value.
146 return (size_t)(_initial_ihop_percent * _target_occupancy / 100.0);
147 }
148 }
149
150 double G1AdaptiveIHOPControl::last_mutator_period_old_allocation_rate() const {
151 assert(_last_allocation_time_s > 0, "This should not be called when the last GC is full");
152
153 return _old_gen_alloc_tracker->last_period_net_survived_old_bytes() / _last_allocation_time_s;
154 }
155
156 void G1AdaptiveIHOPControl::update_allocation_info(double allocation_time_s,
157 size_t additional_buffer_size) {
158 G1IHOPControl::update_allocation_info(allocation_time_s, additional_buffer_size);
159 _allocation_rate_s.add(last_mutator_period_old_allocation_rate());
160
161 _last_unrestrained_young_size = additional_buffer_size;
162 }
163
164 void G1AdaptiveIHOPControl::update_marking_length(double marking_length_s) {
165 assert(marking_length_s >= 0.0, "Marking length must be larger than zero but is %.3f", marking_length_s);
166 _marking_times_s.add(marking_length_s);
167 }
168
169 void G1AdaptiveIHOPControl::print() {
170 G1IHOPControl::print();
171 size_t actual_target = actual_target_threshold();
172 log_debug(gc, ihop)("Adaptive IHOP information (value update), threshold: " SIZE_FORMAT "B (%1.2f), internal target occupancy: " SIZE_FORMAT "B, "
173 "occupancy: " SIZE_FORMAT "B, additional buffer size: " SIZE_FORMAT "B, predicted old gen allocation rate: %1.2fB/s, "
|