Skip to content

Commit 17d633a

Browse files
committed
8373720: GenShen: Count live-at-old mark using Snapshot at Beginning
Reviewed-by: ysr
1 parent 232b41b commit 17d633a

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,13 @@ void ShenandoahOldHeuristics::prepare_for_old_collections() {
335335

336336
size_t garbage = region->garbage();
337337
size_t live_bytes = region->get_live_data_bytes();
338-
live_data += live_bytes;
338+
if (!region->was_promoted_in_place()) {
339+
// As currently implemented, region->get_live_data_bytes() represents bytes concurrently marked.
340+
// Expansion of the region by promotion during concurrent marking is above TAMS, and is not included
341+
// as live-data at [start of] old marking.
342+
live_data += live_bytes;
343+
}
344+
// else, regions that were promoted in place had 0 old live data at mark start
339345

340346
if (region->is_regular() || region->is_regular_pinned()) {
341347
// Only place regular or pinned regions with live data into the candidate set.
@@ -374,7 +380,6 @@ void ShenandoahOldHeuristics::prepare_for_old_collections() {
374380
}
375381
}
376382

377-
// TODO: subtract from live_data bytes promoted during concurrent GC.
378383
_old_generation->set_live_bytes_at_last_mark(live_data);
379384

380385
// Unlike young, we are more interested in efficiently packing OLD-gen than in reclaiming garbage first. We sort by live-data.

src/hotspot/share/gc/shenandoah/shenandoahGenerationalEvacuationTask.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ void ShenandoahGenerationalEvacuationTask::promote_in_place(ShenandoahHeapRegion
223223
// We do not need to scan above TAMS because restored top equals tams
224224
assert(obj_addr == tams, "Expect loop to terminate when obj_addr equals tams");
225225

226-
227226
{
228227
ShenandoahHeapLocker locker(_heap->lock());
229228

@@ -251,6 +250,7 @@ void ShenandoahGenerationalEvacuationTask::promote_in_place(ShenandoahHeapRegion
251250
// Transfer this region from young to old, increasing promoted_reserve if available space exceeds plab_min_size()
252251
_heap->free_set()->add_promoted_in_place_region_to_old_collector(region);
253252
region->set_affiliation(OLD_GENERATION);
253+
region->set_promoted_in_place();
254254
}
255255
}
256256

@@ -289,6 +289,7 @@ void ShenandoahGenerationalEvacuationTask::promote_humongous(ShenandoahHeapRegio
289289
r->index(), p2i(r->bottom()), p2i(r->top()));
290290
// We mark the entire humongous object's range as dirty after loop terminates, so no need to dirty the range here
291291
r->set_affiliation(OLD_GENERATION);
292+
r->set_promoted_in_place();
292293
}
293294

294295
ShenandoahFreeSet* freeset = _heap->free_set();

src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ class ShenandoahHeapRegion {
262262
HeapWord* volatile _update_watermark;
263263

264264
uint _age;
265+
bool _promoted_in_place;
265266
CENSUS_NOISE(uint _youth;) // tracks epochs of retrograde ageing (rejuvenation)
266267

267268
ShenandoahSharedFlag _recycling; // Used to indicate that the region is being recycled; see try_recycle*().
@@ -354,6 +355,15 @@ class ShenandoahHeapRegion {
354355

355356
inline void save_top_before_promote();
356357
inline HeapWord* get_top_before_promote() const { return _top_before_promoted; }
358+
359+
inline void set_promoted_in_place() {
360+
_promoted_in_place = true;
361+
}
362+
363+
// Returns true iff this region was promoted in place subsequent to the most recent start of concurrent old marking.
364+
inline bool was_promoted_in_place() {
365+
return _promoted_in_place;
366+
}
357367
inline void restore_top_before_promote();
358368
inline size_t garbage_before_padded_for_promote() const;
359369

@@ -379,7 +389,13 @@ class ShenandoahHeapRegion {
379389
inline void increase_live_data_gc_words(size_t s);
380390

381391
inline bool has_live() const;
392+
393+
// Represents the number of live bytes identified by most recent marking effort. Does not include the bytes
394+
// above TAMS.
382395
inline size_t get_live_data_bytes() const;
396+
397+
// Represents the number of live words identified by most recent marking effort. Does not include the words
398+
// above TAMS.
383399
inline size_t get_live_data_words() const;
384400

385401
inline size_t garbage() const;

src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ inline void ShenandoahHeapRegion::internal_increase_live_data(size_t s) {
152152

153153
inline void ShenandoahHeapRegion::clear_live_data() {
154154
AtomicAccess::store(&_live_data, (size_t)0);
155+
_promoted_in_place = false;
155156
}
156157

157158
inline size_t ShenandoahHeapRegion::get_live_data_words() const {

0 commit comments

Comments
 (0)