diff --git a/src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp b/src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp index d635781f90f..df2cd18042f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp @@ -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() { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp index d00a99ee728..05eb0c299a5 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp @@ -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; diff --git a/test/hotspot/jtreg/gc/shenandoah/generational/TestOldGrowthTriggers.java b/test/hotspot/jtreg/gc/shenandoah/generational/TestOldGrowthTriggers.java index 840ceffc4fe..b5d191e33ba 100644 --- a/test/hotspot/jtreg/gc/shenandoah/generational/TestOldGrowthTriggers.java +++ b/test/hotspot/jtreg/gc/shenandoah/generational/TestOldGrowthTriggers.java @@ -57,17 +57,17 @@ public static void makeOldAllocations() { 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; }