Skip to content

Commit ba6aa29

Browse files
author
William Kemper
committedJun 17, 2024
8333825: GenShen: Revert/Remove ShenandoahMaxEvacLABRatio
Backport-of: 6071b4a9a170b2d91522971a3c9b32bbf44eee3b
1 parent 0fde759 commit ba6aa29

File tree

3 files changed

+17
-46
lines changed

3 files changed

+17
-46
lines changed
 

‎src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp

+16-19
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ size_t ShenandoahGenerationalHeap::calculate_min_plab() {
8989

9090
size_t ShenandoahGenerationalHeap::calculate_max_plab() {
9191
size_t MaxTLABSizeWords = ShenandoahHeapRegion::max_tlab_size_words();
92-
return ((ShenandoahMaxEvacLABRatio > 0)?
93-
align_down(MIN2(MaxTLABSizeWords, PLAB::min_size() * ShenandoahMaxEvacLABRatio), CardTable::card_size_in_words()):
94-
align_down(MaxTLABSizeWords, CardTable::card_size_in_words()));
92+
return align_down(MaxTLABSizeWords, CardTable::card_size_in_words());
9593
}
9694

9795
// Returns size in bytes
@@ -395,51 +393,50 @@ HeapWord* ShenandoahGenerationalHeap::allocate_from_plab_slow(Thread* thread, si
395393

396394
assert(mode()->is_generational(), "PLABs only relevant to generational GC");
397395
const size_t plab_min_size = this->plab_min_size();
396+
// PLABs are aligned to card boundaries to avoid synchronization with concurrent
397+
// allocations in other PLABs.
398398
const size_t min_size = (size > plab_min_size)? align_up(size, CardTable::card_size_in_words()): plab_min_size;
399399

400-
// Figure out size of new PLAB, looking back at heuristics. Expand aggressively. PLABs must align on size
401-
// of card table in order to avoid the need for synchronization when registering newly allocated objects within
402-
// the card table.
400+
// Figure out size of new PLAB, using value determined at last refill.
403401
size_t cur_size = ShenandoahThreadLocalData::plab_size(thread);
404402
if (cur_size == 0) {
405403
cur_size = plab_min_size;
406404
}
407405

408-
// Limit growth of PLABs to the smaller of ShenandoahMaxEvacLABRatio * the minimum size and ShenandoahHumongousThreshold.
409-
// This minimum value is represented by generational_heap->plab_max_size(). Enforcing this limit enables more equitable
410-
// distribution of available evacuation budget between the many threads that are coordinating in the evacuation effort.
406+
// Expand aggressively, doubling at each refill in this epoch, ceiling at plab_max_size()
411407
size_t future_size = MIN2(cur_size * 2, plab_max_size());
412-
assert(is_aligned(future_size, CardTable::card_size_in_words()), "Align by design, future_size: " SIZE_FORMAT
413-
", alignment: " SIZE_FORMAT ", cur_size: " SIZE_FORMAT ", max: " SIZE_FORMAT,
408+
// Doubling, starting at a card-multiple, should give us a card-multiple. (Ceiling and floor
409+
// are card multiples.)
410+
assert(is_aligned(future_size, CardTable::card_size_in_words()), "Card multiple by construction, future_size: " SIZE_FORMAT
411+
", card_size: " SIZE_FORMAT ", cur_size: " SIZE_FORMAT ", max: " SIZE_FORMAT,
414412
future_size, (size_t) CardTable::card_size_in_words(), cur_size, plab_max_size());
415413

416414
// Record new heuristic value even if we take any shortcut. This captures
417415
// the case when moderately-sized objects always take a shortcut. At some point,
418416
// heuristics should catch up with them. Note that the requested cur_size may
419417
// not be honored, but we remember that this is the preferred size.
418+
log_debug(gc, free)("Set new PLAB size: " SIZE_FORMAT, future_size);
420419
ShenandoahThreadLocalData::set_plab_size(thread, future_size);
421420
if (cur_size < size) {
422421
// The PLAB to be allocated is still not large enough to hold the object. Fall back to shared allocation.
423422
// This avoids retiring perfectly good PLABs in order to represent a single large object allocation.
423+
log_debug(gc, free)("Current PLAB size (" SIZE_FORMAT ") is too small for " SIZE_FORMAT, cur_size, size);
424424
return nullptr;
425425
}
426426

427427
// Retire current PLAB, and allocate a new one.
428428
PLAB* plab = ShenandoahThreadLocalData::plab(thread);
429429
if (plab->words_remaining() < plab_min_size) {
430-
// Retire current PLAB, and allocate a new one.
431-
// CAUTION: retire_plab may register the remnant filler object with the remembered set scanner without a lock. This
432-
// is safe iff it is assured that each PLAB is a whole-number multiple of card-mark memory size and each PLAB is
433-
// aligned with the start of a card's memory range.
430+
// Retire current PLAB. This takes care of any PLAB book-keeping.
431+
// retire_plab() registers the remnant filler object with the remembered set scanner without a lock.
432+
// Since PLABs are card-aligned, concurrent registrations in other PLABs don't interfere.
434433
retire_plab(plab, thread);
435434

436435
size_t actual_size = 0;
437-
// allocate_new_plab resets plab_evacuated and plab_promoted and disables promotions if old-gen available is
438-
// less than the remaining evacuation need. It also adjusts plab_preallocated and expend_promoted if appropriate.
439436
HeapWord* plab_buf = allocate_new_plab(min_size, cur_size, &actual_size);
440437
if (plab_buf == nullptr) {
441438
if (min_size == plab_min_size) {
442-
// Disable plab promotions for this thread because we cannot even allocate a plab of minimal size. This allows us
439+
// Disable PLAB promotions for this thread because we cannot even allocate a minimal PLAB. This allows us
443440
// to fail faster on subsequent promotion attempts.
444441
ShenandoahThreadLocalData::disable_plab_promotions(thread);
445442
}
@@ -468,7 +465,7 @@ HeapWord* ShenandoahGenerationalHeap::allocate_from_plab_slow(Thread* thread, si
468465
}
469466
return plab->allocate(size);
470467
} else {
471-
// If there's still at least min_size() words available within the current plab, don't retire it. Let's gnaw
468+
// If there's still at least min_size() words available within the current plab, don't retire it. Let's nibble
472469
// away on this plab as long as we can. Meanwhile, return nullptr to force this particular allocation request
473470
// to be satisfied with a shared allocation. By packing more promotions into the previously allocated PLAB, we
474471
// reduce the likelihood of evacuation failures, and we reduce the need for downsizing our PLABs.

‎src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -919,19 +919,13 @@ HeapWord* ShenandoahHeap::allocate_from_gclab_slow(Thread* thread, size_t size)
919919
// Figure out size of new GCLAB, looking back at heuristics. Expand aggressively.
920920
size_t new_size = ShenandoahThreadLocalData::gclab_size(thread) * 2;
921921

922-
// Limit growth of GCLABs to ShenandoahMaxEvacLABRatio * the minimum size. This enables more equitable distribution of
923-
// available evacuation buidget between the many threads that are coordinating in the evacuation effort.
924-
if (ShenandoahMaxEvacLABRatio > 0) {
925-
log_debug(gc, free)("Allocate new gclab: " SIZE_FORMAT ", " SIZE_FORMAT, new_size, PLAB::min_size() * ShenandoahMaxEvacLABRatio);
926-
new_size = MIN2(new_size, PLAB::min_size() * ShenandoahMaxEvacLABRatio);
927-
}
928-
929922
new_size = MIN2(new_size, PLAB::max_size());
930923
new_size = MAX2(new_size, PLAB::min_size());
931924

932925
// Record new heuristic value even if we take any shortcut. This captures
933926
// the case when moderately-sized objects always take a shortcut. At some point,
934927
// heuristics should catch up with them.
928+
log_debug(gc, free)("Set new GCLAB size: " SIZE_FORMAT, new_size);
935929
ShenandoahThreadLocalData::set_gclab_size(thread, new_size);
936930

937931
if (new_size < size) {

‎src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp

-20
Original file line numberDiff line numberDiff line change
@@ -384,26 +384,6 @@
384384
"failures, which will trigger stop-the-world Full GC passes.") \
385385
range(1.0,100.0) \
386386
\
387-
product(uintx, ShenandoahMaxEvacLABRatio, 0, EXPERIMENTAL, \
388-
"Potentially, each running thread maintains a PLAB for " \
389-
"evacuating objects into old-gen memory and a GCLAB for " \
390-
"evacuating objects into young-gen memory. Each time a thread " \
391-
"exhausts its PLAB or GCLAB, a new local buffer is allocated. " \
392-
"By default, the new buffer is twice the size of the previous " \
393-
"buffer. The sizes are reset to the minimum at the start of " \
394-
"each GC pass. This parameter limits the growth of evacuation " \
395-
"buffer sizes to its value multiplied by the minimum buffer " \
396-
"size. A higher value allows evacuation allocations to be more " \
397-
"efficient because less synchronization is required by " \
398-
"individual threads. However, a larger value increases the " \
399-
"likelihood of evacuation failures, leading to long " \
400-
"stop-the-world pauses. This is because a large value " \
401-
"allows individual threads to consume large percentages of " \
402-
"the total evacuation budget without necessarily effectively " \
403-
"filling their local evacuation buffers with evacuated " \
404-
"objects. A value of zero means no maximum size is enforced.") \
405-
range(0, 1024) \
406-
\
407387
product(bool, ShenandoahEvacReserveOverflow, true, EXPERIMENTAL, \
408388
"Allow evacuations to overflow the reserved space. Enabling it " \
409389
"will make evacuations more resilient when evacuation " \

0 commit comments

Comments
 (0)
Please sign in to comment.