Skip to content

Commit d634dde

Browse files
author
Thomas Schatzl
committed
8295354: Remove G1 incremental non-copy time calculation
Reviewed-by: ayang, iwalulya
1 parent 8836b92 commit d634dde

File tree

7 files changed

+40
-167
lines changed

7 files changed

+40
-167
lines changed

Diff for: src/hotspot/share/gc/g1/g1Analytics.cpp

+1-8
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ G1Analytics::G1Analytics(const G1Predictions* predictor) :
8383
_cost_per_byte_copied_ms_seq(TruncatedSeqLength),
8484
_pending_cards_seq(TruncatedSeqLength),
8585
_rs_length_seq(TruncatedSeqLength),
86-
_rs_length_diff_seq(TruncatedSeqLength),
8786
_constant_other_time_ms_seq(TruncatedSeqLength),
8887
_young_other_cost_per_region_ms_seq(TruncatedSeqLength),
8988
_non_young_other_cost_per_region_ms_seq(TruncatedSeqLength),
@@ -105,7 +104,6 @@ G1Analytics::G1Analytics(const G1Predictions* predictor) :
105104
_card_scan_to_merge_ratio_seq.set_initial(young_card_scan_to_merge_ratio_defaults[index]);
106105
_cost_per_card_scan_ms_seq.set_initial(young_only_cost_per_card_scan_ms_defaults[index]);
107106
_rs_length_seq.set_initial(0);
108-
_rs_length_diff_seq.set_initial(0.0);
109107
_cost_per_byte_copied_ms_seq.set_initial(cost_per_byte_ms_defaults[index]);
110108

111109
_constant_other_time_ms_seq.add(constant_other_time_ms_defaults[index]);
@@ -192,10 +190,6 @@ void G1Analytics::report_card_scan_to_merge_ratio(double merge_to_scan_ratio, bo
192190
_card_scan_to_merge_ratio_seq.add(merge_to_scan_ratio, for_young_only_phase);
193191
}
194192

195-
void G1Analytics::report_rs_length_diff(double rs_length_diff, bool for_young_only_phase) {
196-
_rs_length_diff_seq.add(rs_length_diff, for_young_only_phase);
197-
}
198-
199193
void G1Analytics::report_cost_per_byte_ms(double cost_per_byte_ms, bool for_young_only_phase) {
200194
_cost_per_byte_copied_ms_seq.add(cost_per_byte_ms, for_young_only_phase);
201195
}
@@ -277,8 +271,7 @@ double G1Analytics::predict_cleanup_time_ms() const {
277271
}
278272

279273
size_t G1Analytics::predict_rs_length(bool for_young_only_phase) const {
280-
return predict_size(&_rs_length_seq, for_young_only_phase) +
281-
predict_size(&_rs_length_diff_seq, for_young_only_phase);
274+
return predict_size(&_rs_length_seq, for_young_only_phase);
282275
}
283276

284277
size_t G1Analytics::predict_pending_cards(bool for_young_only_phase) const {

Diff for: src/hotspot/share/gc/g1/g1Analytics.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class G1Analytics: public CHeapObj<mtGC> {
6262

6363
G1PhaseDependentSeq _pending_cards_seq;
6464
G1PhaseDependentSeq _rs_length_seq;
65-
G1PhaseDependentSeq _rs_length_diff_seq;
6665

6766
TruncatedSeq _constant_other_time_ms_seq;
6867
TruncatedSeq _young_other_cost_per_region_ms_seq;

Diff for: src/hotspot/share/gc/g1/g1CollectionSet.cpp

+8-86
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424

2525
#include "precompiled.hpp"
26+
#include "gc/g1/g1Analytics.hpp"
2627
#include "gc/g1/g1CollectedHeap.inline.hpp"
2728
#include "gc/g1/g1CollectionSet.hpp"
2829
#include "gc/g1/g1CollectionSetCandidates.hpp"
@@ -47,10 +48,6 @@ G1GCPhaseTimes* G1CollectionSet::phase_times() {
4748
return _policy->phase_times();
4849
}
4950

50-
double G1CollectionSet::predict_region_non_copy_time_ms(HeapRegion* hr) const {
51-
return _policy->predict_region_non_copy_time_ms(hr, collector_state()->in_young_only_phase());
52-
}
53-
5451
G1CollectionSet::G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy) :
5552
_g1h(g1h),
5653
_policy(policy),
@@ -63,20 +60,13 @@ G1CollectionSet::G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy) :
6360
_collection_set_max_length(0),
6461
_num_optional_regions(0),
6562
_bytes_used_before(0),
66-
_recorded_rs_length(0),
6763
_inc_build_state(Inactive),
6864
_inc_part_start(0),
69-
_inc_collection_set_stats(NULL),
70-
_inc_bytes_used_before(0),
71-
_inc_recorded_rs_length(0),
72-
_inc_recorded_rs_length_diff(0),
73-
_inc_predicted_non_copy_time_ms(0.0),
74-
_inc_predicted_non_copy_time_ms_diff(0.0) {
65+
_inc_bytes_used_before(0) {
7566
}
7667

7768
G1CollectionSet::~G1CollectionSet() {
7869
FREE_C_HEAP_ARRAY(uint, _collection_set_regions);
79-
FREE_C_HEAP_ARRAY(IncCollectionSetRegionStat, _inc_collection_set_stats);
8070
free_optional_regions();
8171
clear_candidates();
8272
}
@@ -99,7 +89,6 @@ void G1CollectionSet::initialize(uint max_region_length) {
9989
guarantee(_collection_set_regions == NULL, "Must only initialize once.");
10090
_collection_set_max_length = max_region_length;
10191
_collection_set_regions = NEW_C_HEAP_ARRAY(uint, max_region_length, mtGC);
102-
_inc_collection_set_stats = NEW_C_HEAP_ARRAY(IncCollectionSetRegionStat, max_region_length, mtGC);
10392
}
10493

10594
void G1CollectionSet::free_optional_regions() {
@@ -115,10 +104,6 @@ bool G1CollectionSet::has_candidates() {
115104
return _candidates != NULL && !_candidates->is_empty();
116105
}
117106

118-
void G1CollectionSet::set_recorded_rs_length(size_t rs_length) {
119-
_recorded_rs_length = rs_length;
120-
}
121-
122107
// Add the heap region at the head of the non-incremental collection set
123108
void G1CollectionSet::add_old_region(HeapRegion* hr) {
124109
assert_at_safepoint_on_vm_thread();
@@ -134,7 +119,6 @@ void G1CollectionSet::add_old_region(HeapRegion* hr) {
134119
_collection_set_regions[_collection_set_cur_length++] = hr->hrm_index();
135120

136121
_bytes_used_before += hr->used();
137-
_recorded_rs_length += hr->rem_set()->occupied();
138122
_old_region_length++;
139123

140124
_g1h->old_set_remove(hr);
@@ -152,38 +136,15 @@ void G1CollectionSet::add_optional_region(HeapRegion* hr) {
152136
void G1CollectionSet::start_incremental_building() {
153137
assert(_collection_set_cur_length == 0, "Collection set must be empty before starting a new collection set.");
154138
assert(_inc_build_state == Inactive, "Precondition");
155-
#ifdef ASSERT
156-
for (uint i = 0; i < _collection_set_max_length; i++) {
157-
_inc_collection_set_stats[i].reset();
158-
}
159-
#endif
160139

161140
_inc_bytes_used_before = 0;
162141

163-
_inc_recorded_rs_length = 0;
164-
_inc_recorded_rs_length_diff = 0;
165-
_inc_predicted_non_copy_time_ms = 0.0;
166-
_inc_predicted_non_copy_time_ms_diff = 0.0;
167-
168142
update_incremental_marker();
169143
}
170144

171145
void G1CollectionSet::finalize_incremental_building() {
172146
assert(_inc_build_state == Active, "Precondition");
173147
assert(SafepointSynchronize::is_at_safepoint(), "should be at a safepoint");
174-
175-
// The two "main" fields, _inc_recorded_rs_length and
176-
// _inc_predicted_non_copy_time_ms, are updated by the thread
177-
// that adds a new region to the CSet. Further updates by the
178-
// concurrent refinement thread that samples the young RSet lengths
179-
// are accumulated in the *_diff fields. Here we add the diffs to
180-
// the "main" fields.
181-
182-
_inc_recorded_rs_length += _inc_recorded_rs_length_diff;
183-
_inc_predicted_non_copy_time_ms += _inc_predicted_non_copy_time_ms_diff;
184-
185-
_inc_recorded_rs_length_diff = 0;
186-
_inc_predicted_non_copy_time_ms_diff = 0.0;
187148
}
188149

189150
void G1CollectionSet::clear() {
@@ -239,31 +200,6 @@ void G1CollectionSet::iterate_part_from(HeapRegionClosure* cl,
239200
worker_id);
240201
}
241202

242-
void G1CollectionSet::update_young_region_prediction(HeapRegion* hr,
243-
size_t new_rs_length) {
244-
// Update the CSet information that is dependent on the new RS length
245-
assert(hr->is_young(), "Precondition");
246-
assert(!SafepointSynchronize::is_at_safepoint(), "should not be at a safepoint");
247-
248-
IncCollectionSetRegionStat* stat = &_inc_collection_set_stats[hr->hrm_index()];
249-
250-
size_t old_rs_length = stat->_rs_length;
251-
assert(old_rs_length <= new_rs_length,
252-
"Remembered set decreased (changed from " SIZE_FORMAT " to " SIZE_FORMAT " region %u type %s)",
253-
old_rs_length, new_rs_length, hr->hrm_index(), hr->get_short_type_str());
254-
size_t rs_length_diff = new_rs_length - old_rs_length;
255-
stat->_rs_length = new_rs_length;
256-
_inc_recorded_rs_length_diff += rs_length_diff;
257-
258-
double old_non_copy_time = stat->_non_copy_time_ms;
259-
assert(old_non_copy_time >= 0.0, "Non copy time for region %u not initialized yet, is %.3f", hr->hrm_index(), old_non_copy_time);
260-
double new_non_copy_time = predict_region_non_copy_time_ms(hr);
261-
double non_copy_time_ms_diff = new_non_copy_time - old_non_copy_time;
262-
263-
stat->_non_copy_time_ms = new_non_copy_time;
264-
_inc_predicted_non_copy_time_ms_diff += non_copy_time_ms_diff;
265-
}
266-
267203
void G1CollectionSet::add_young_region_common(HeapRegion* hr) {
268204
assert(hr->is_young(), "invariant");
269205
assert(_inc_build_state == Active, "Precondition");
@@ -285,20 +221,6 @@ void G1CollectionSet::add_young_region_common(HeapRegion* hr) {
285221
// Ignore calls to this due to retirement during full gc.
286222

287223
if (!_g1h->collector_state()->in_full_gc()) {
288-
size_t rs_length = hr->rem_set()->occupied();
289-
double non_copy_time = predict_region_non_copy_time_ms(hr);
290-
291-
// Cache the values we have added to the aggregated information
292-
// in the heap region in case we have to remove this region from
293-
// the incremental collection set, or it is updated by the
294-
// rset sampling code
295-
296-
IncCollectionSetRegionStat* stat = &_inc_collection_set_stats[hr->hrm_index()];
297-
stat->_rs_length = rs_length;
298-
stat->_non_copy_time_ms = non_copy_time;
299-
300-
_inc_recorded_rs_length += rs_length;
301-
_inc_predicted_non_copy_time_ms += non_copy_time;
302224
_inc_bytes_used_before += hr->used();
303225
}
304226

@@ -400,7 +322,8 @@ double G1CollectionSet::finalize_young_part(double target_pause_time_ms, G1Survi
400322
guarantee(target_pause_time_ms > 0.0,
401323
"target_pause_time_ms = %1.6lf should be positive", target_pause_time_ms);
402324

403-
size_t pending_cards = _policy->pending_cards_at_gc_start() + _g1h->hot_card_cache()->num_entries();
325+
size_t pending_cards = _policy->pending_cards_at_gc_start() +
326+
_g1h->hot_card_cache()->num_entries();
404327

405328
log_trace(gc, ergo, cset)("Start choosing CSet. Pending cards: " SIZE_FORMAT " target pause time: %1.2fms",
406329
pending_cards, target_pause_time_ms);
@@ -417,12 +340,11 @@ double G1CollectionSet::finalize_young_part(double target_pause_time_ms, G1Survi
417340

418341
_bytes_used_before = _inc_bytes_used_before;
419342

420-
// The number of recorded young regions is the incremental
421-
// collection set's current size
422-
set_recorded_rs_length(_inc_recorded_rs_length);
423-
424343
double predicted_base_time_ms = _policy->predict_base_time_ms(pending_cards);
425-
double predicted_eden_time = _inc_predicted_non_copy_time_ms + _policy->predict_eden_copy_time_ms(eden_region_length);
344+
// Base time already includes the whole remembered set related time, so do not add that here
345+
// again.
346+
double predicted_eden_time = _policy->predict_young_region_other_time_ms(eden_region_length) +
347+
_policy->predict_eden_copy_time_ms(eden_region_length);
426348
double remaining_time_ms = MAX2(target_pause_time_ms - (predicted_base_time_ms + predicted_eden_time), 0.0);
427349

428350
log_trace(gc, ergo, cset)("Added young regions to CSet. Eden: %u regions, Survivors: %u regions, "

Diff for: src/hotspot/share/gc/g1/g1CollectionSet.hpp

-54
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,6 @@ class G1CollectionSet {
161161
// pause, and updated as more regions are added to the collection set.
162162
size_t _bytes_used_before;
163163

164-
// The number of cards in the remembered set in the collection set. Set from
165-
// the incrementally built collection set at the start of an evacuation
166-
// pause, and updated as more regions are added to the collection set.
167-
size_t _recorded_rs_length;
168-
169164
enum CSetBuildType {
170165
Active, // We are actively building the collection set
171166
Inactive // We are not actively building the collection set
@@ -174,22 +169,6 @@ class G1CollectionSet {
174169
CSetBuildType _inc_build_state;
175170
size_t _inc_part_start;
176171

177-
// Information about eden regions in the incremental collection set.
178-
struct IncCollectionSetRegionStat {
179-
// The predicted non-copy time that was added to the total incremental value
180-
// for the collection set.
181-
double _non_copy_time_ms;
182-
// The remembered set length that was added to the total incremental value
183-
// for the collection set.
184-
size_t _rs_length;
185-
186-
#ifdef ASSERT
187-
// Resets members to "uninitialized" values.
188-
void reset() { _rs_length = ~(size_t)0; _non_copy_time_ms = -1.0; }
189-
#endif
190-
};
191-
192-
IncCollectionSetRegionStat* _inc_collection_set_stats;
193172
// The associated information that is maintained while the incremental
194173
// collection set is being built with *young* regions. Used to populate
195174
// the recorded info for the evacuation pause.
@@ -199,38 +178,11 @@ class G1CollectionSet {
199178
// an evacuation pause.
200179
size_t _inc_bytes_used_before;
201180

202-
// The RSet lengths recorded for regions in the CSet. It is updated
203-
// by the thread that adds a new region to the CSet. We assume that
204-
// only one thread can be allocating a new CSet region (currently,
205-
// it does so after taking the Heap_lock) hence no need to
206-
// synchronize updates to this field.
207-
size_t _inc_recorded_rs_length;
208-
209-
// A concurrent refinement thread periodically samples the young
210-
// region RSets and needs to update _inc_recorded_rs_length as
211-
// the RSets grow. Instead of having to synchronize updates to that
212-
// field we accumulate them in this field and add it to
213-
// _inc_recorded_rs_length_diff at the start of a GC.
214-
size_t _inc_recorded_rs_length_diff;
215-
216-
// The predicted elapsed time it will take to collect the regions in
217-
// the CSet. This is updated by the thread that adds a new region to
218-
// the CSet. See the comment for _inc_recorded_rs_length about
219-
// MT-safety assumptions.
220-
double _inc_predicted_non_copy_time_ms;
221-
222-
// See the comment for _inc_recorded_rs_length_diff.
223-
double _inc_predicted_non_copy_time_ms_diff;
224-
225-
void set_recorded_rs_length(size_t rs_length);
226-
227181
G1CollectorState* collector_state() const;
228182
G1GCPhaseTimes* phase_times();
229183

230184
void verify_young_cset_indices() const NOT_DEBUG_RETURN;
231185

232-
double predict_region_non_copy_time_ms(HeapRegion* hr) const;
233-
234186
// Update the incremental collection set information when adding a region.
235187
void add_young_region_common(HeapRegion* hr);
236188

@@ -322,8 +274,6 @@ class G1CollectionSet {
322274

323275
void iterate_optional(HeapRegionClosure* cl) const;
324276

325-
size_t recorded_rs_length() { return _recorded_rs_length; }
326-
327277
size_t bytes_used_before() const {
328278
return _bytes_used_before;
329279
}
@@ -341,10 +291,6 @@ class G1CollectionSet {
341291
// pause.
342292
void abandon_optional_collection_set(G1ParScanThreadStateSet* pss);
343293

344-
// Update information about hr in the aggregated information for
345-
// the incrementally built collection set.
346-
void update_young_region_prediction(HeapRegion* hr, size_t new_rs_length);
347-
348294
// Add eden region to the collection set.
349295
void add_eden_region(HeapRegion* hr);
350296

Diff for: src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@ class G1ConcurrentRefine::RemSetSamplingClosure : public HeapRegionClosure {
288288
bool do_heap_region(HeapRegion* r) override {
289289
size_t rs_length = r->rem_set()->occupied();
290290
_sampled_rs_length += rs_length;
291-
// Update the collection set policy information for this region.
292-
_cset->update_young_region_prediction(r, rs_length);
293291
return false;
294292
}
295293

0 commit comments

Comments
 (0)