8321120: Shenandoah: Remove ShenandoahElasticTLAB flag

Reviewed-by: kdnilsen, ysr
This commit is contained in:
Aleksey Shipilev 2023-12-04 08:20:09 +00:00
parent 9b8eaa2fc3
commit 93b9235f19
5 changed files with 5 additions and 92 deletions

@ -154,7 +154,7 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah
HeapWord* result = nullptr;
size_t size = req.size();
if (ShenandoahElasticTLAB && req.is_lab_alloc()) {
if (req.is_lab_alloc()) {
size_t free = align_down(r->free() >> LogHeapWordSize, MinObjAlignment);
if (size > free) {
size = free;

@ -1186,13 +1186,9 @@ void ShenandoahHeap::gclabs_retire(bool resize) {
// Returns size in bytes
size_t ShenandoahHeap::unsafe_max_tlab_alloc(Thread *thread) const {
if (ShenandoahElasticTLAB) {
// With Elastic TLABs, return the max allowed size, and let the allocation path
// figure out the safe size for current allocation.
return ShenandoahHeapRegion::max_tlab_size_bytes();
} else {
return MIN2(_free_set->unsafe_peek_free(), ShenandoahHeapRegion::max_tlab_size_bytes());
}
// Return the max allowed size, and let the allocation path
// figure out the safe size for current allocation.
return ShenandoahHeapRegion::max_tlab_size_bytes();
}
size_t ShenandoahHeap::max_tlab_size() const {

@ -607,26 +607,8 @@ size_t ShenandoahHeapRegion::setup_sizes(size_t max_heap_size) {
HumongousThresholdBytes = HumongousThresholdWords * HeapWordSize;
assert (HumongousThresholdBytes <= RegionSizeBytes, "sanity");
// The rationale for trimming the TLAB sizes has to do with the raciness in
// TLAB allocation machinery. It may happen that TLAB sizing policy polls Shenandoah
// about next free size, gets the answer for region #N, goes away for a while, then
// tries to allocate in region #N, and fail because some other thread have claimed part
// of the region #N, and then the freeset allocation code has to retire the region #N,
// before moving the allocation to region #N+1.
//
// The worst case realizes when "answer" is "region size", which means it could
// prematurely retire an entire region. Having smaller TLABs does not fix that
// completely, but reduces the probability of too wasteful region retirement.
// With current divisor, we will waste no more than 1/8 of region size in the worst
// case. This also has a secondary effect on collection set selection: even under
// the race, the regions would be at least 7/8 used, which allows relying on
// "used" - "live" for cset selection. Otherwise, we can get the fragmented region
// below the garbage threshold that would never be considered for collection.
//
// The whole thing is mitigated if Elastic TLABs are enabled.
//
guarantee(MaxTLABSizeWords == 0, "we should only set it once");
MaxTLABSizeWords = MIN2(ShenandoahElasticTLAB ? RegionSizeWords : (RegionSizeWords / 8), HumongousThresholdWords);
MaxTLABSizeWords = MIN2(RegionSizeWords, HumongousThresholdWords);
MaxTLABSizeWords = align_down(MaxTLABSizeWords, MinObjAlignment);
guarantee(MaxTLABSizeBytes == 0, "we should only set it once");

@ -215,9 +215,6 @@
" 3 = previous level, plus all reachable objects; " \
" 4 = previous level, plus all marked objects") \
\
product(bool, ShenandoahElasticTLAB, true, DIAGNOSTIC, \
"Use Elastic TLABs with Shenandoah") \
\
product(uintx, ShenandoahEvacReserve, 5, EXPERIMENTAL, \
"How much of heap to reserve for evacuations. Larger values make "\
"GC evacuate more live objects on every cycle, while leaving " \

@ -1,62 +0,0 @@
/*
* Copyright (c) 2018, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/*
* @test
* @key randomness
* @summary Test that Shenandoah is able to work with elastic TLABs
* @requires vm.gc.Shenandoah
* @library /test/lib
*
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g -XX:-UseTLAB -XX:-ShenandoahElasticTLAB -XX:+ShenandoahVerify TestElasticTLAB
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g -XX:-UseTLAB -XX:-ShenandoahElasticTLAB TestElasticTLAB
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g -XX:-UseTLAB -XX:+ShenandoahElasticTLAB -XX:+ShenandoahVerify TestElasticTLAB
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g -XX:-UseTLAB -XX:+ShenandoahElasticTLAB TestElasticTLAB
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g -XX:+UseTLAB -XX:-ShenandoahElasticTLAB -XX:+ShenandoahVerify TestElasticTLAB
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g -XX:+UseTLAB -XX:-ShenandoahElasticTLAB TestElasticTLAB
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g -XX:+UseTLAB -XX:+ShenandoahElasticTLAB -XX:+ShenandoahVerify TestElasticTLAB
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g -XX:+UseTLAB -XX:+ShenandoahElasticTLAB TestElasticTLAB
*/
import java.util.Random;
import jdk.test.lib.Utils;
public class TestElasticTLAB {
static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation
static volatile Object sink;
public static void main(String[] args) throws Exception {
final int min = 0;
final int max = 384 * 1024;
long count = TARGET_MB * 1024 * 1024 / (16 + 4 * (min + (max - min) / 2));
Random r = Utils.getRandomInstance();
for (long c = 0; c < count; c++) {
sink = new int[min + r.nextInt(max - min)];
}
}
}