8359947: GenShen: use smaller TLABs by default

Reviewed-by: phh, xpeng
This commit is contained in:
Kelvin Nilsen 2025-06-26 14:36:33 +00:00
parent 7576064a10
commit a0c3efa6a8
3 changed files with 13 additions and 6 deletions

View File

@ -184,9 +184,10 @@ void ShenandoahArguments::initialize() {
// Current default is good for generational collectors that run frequent young GCs.
// With Shenandoah, GC cycles are much less frequent, so we need we need sizing policy
// to converge faster over smaller number of resizing decisions.
if (FLAG_IS_DEFAULT(TLABAllocationWeight)) {
if (strcmp(ShenandoahGCMode, "generational") && FLAG_IS_DEFAULT(TLABAllocationWeight)) {
FLAG_SET_DEFAULT(TLABAllocationWeight, 90);
}
// In generational mode, let TLABAllocationWeight keeps its default value of 35.
if (GCCardSizeInBytes < ShenandoahMinCardSizeInBytes) {
vm_exit_during_initialization(
@ -217,6 +218,10 @@ void ShenandoahArguments::initialize_alignments() {
}
SpaceAlignment = align;
HeapAlignment = align;
if (FLAG_IS_DEFAULT(TLABSize)) {
TLABSize = MAX2(ShenandoahHeapRegion::region_size_bytes() / 256, (size_t) 32 * 1024);
}
}
CollectedHeap* ShenandoahArguments::create_heap() {

View File

@ -790,8 +790,10 @@ size_t ShenandoahHeapRegion::setup_sizes(size_t max_heap_size) {
RegionCount = align_up(max_heap_size, RegionSizeBytes) / RegionSizeBytes;
guarantee(RegionCount >= MIN_NUM_REGIONS, "Should have at least minimum regions");
// Limit TLAB size for better startup behavior and more equitable distribution of memory between contending mutator threads.
guarantee(MaxTLABSizeWords == 0, "we should only set it once");
MaxTLABSizeWords = align_down(RegionSizeWords, MinObjAlignment);
MaxTLABSizeWords = align_down(MIN2(RegionSizeWords, MAX2(RegionSizeWords / 32, (size_t) (256 * 1024) / HeapWordSize)),
MinObjAlignment);
guarantee(MaxTLABSizeBytes == 0, "we should only set it once");
MaxTLABSizeBytes = MaxTLABSizeWords * HeapWordSize;

View File

@ -57,17 +57,17 @@ public class TestOldGrowthTriggers {
for (int i = 0; i < ArraySize; i++) {
int replaceIndex = r.nextInt(ArraySize);
int deriveIndex = r.nextInt(ArraySize);
switch (i & 0x3) {
case 0:
switch (i & 0x7) {
case 0,1,2:
// creates new old BigInteger, releases old BigInteger,
// may create ephemeral data while computing gcd
array[replaceIndex] = array[replaceIndex].gcd(array[deriveIndex]);
break;
case 1:
case 3,4:
// creates new old BigInteger, releases old BigInteger
array[replaceIndex] = array[replaceIndex].multiply(array[deriveIndex]);
break;
case 2,3:
case 5,6,7:
// do nothing, let all objects in the array age to increase pressure on old generation
break;
}