8338444: Shenandoah: Remove ShenandoahHumongousThreshold tunable

Reviewed-by: rkennke, wkemper, ysr
This commit is contained in:
Aleksey Shipilev 2024-08-15 16:45:43 +00:00
parent 7d1bbff076
commit ef54af3988
10 changed files with 12 additions and 242 deletions

View File

@ -283,7 +283,7 @@ void ShenandoahAsserts::assert_in_correct_region(void* interior_loc, oop obj, co
}
size_t alloc_size = obj->size();
if (alloc_size > ShenandoahHeapRegion::humongous_threshold_words()) {
if (ShenandoahHeapRegion::requires_humongous(alloc_size)) {
size_t idx = r->index();
size_t num_regions = ShenandoahHeapRegion::required_regions(alloc_size * HeapWordSize);
for (size_t i = idx; i < idx + num_regions; i++) {

View File

@ -57,7 +57,7 @@ void ShenandoahController::handle_alloc_failure(ShenandoahAllocRequest& req, boo
ShenandoahHeap* heap = ShenandoahHeap::heap();
assert(current()->is_Java_thread(), "expect Java thread here");
bool is_humongous = req.size() > ShenandoahHeapRegion::humongous_threshold_words();
bool is_humongous = ShenandoahHeapRegion::requires_humongous(req.size());
if (try_set_alloc_failure_gc(is_humongous)) {
// Only report the first allocation failure
@ -80,7 +80,7 @@ void ShenandoahController::handle_alloc_failure(ShenandoahAllocRequest& req, boo
void ShenandoahController::handle_alloc_failure_evac(size_t words) {
ShenandoahHeap* heap = ShenandoahHeap::heap();
bool is_humongous = (words > ShenandoahHeapRegion::region_size_words());
bool is_humongous = ShenandoahHeapRegion::requires_humongous(words);
if (try_set_alloc_failure_gc(is_humongous)) {
// Only report the first allocation failure

View File

@ -1308,7 +1308,7 @@ void ShenandoahFreeSet::log_status() {
HeapWord* ShenandoahFreeSet::allocate(ShenandoahAllocRequest& req, bool& in_new_region) {
shenandoah_assert_heaplocked();
if (req.size() > ShenandoahHeapRegion::humongous_threshold_words()) {
if (ShenandoahHeapRegion::requires_humongous(req.size())) {
switch (req.type()) {
case ShenandoahAllocRequest::_alloc_shared:
case ShenandoahAllocRequest::_alloc_shared_gc:
@ -1317,8 +1317,7 @@ HeapWord* ShenandoahFreeSet::allocate(ShenandoahAllocRequest& req, bool& in_new_
case ShenandoahAllocRequest::_alloc_gclab:
case ShenandoahAllocRequest::_alloc_tlab:
in_new_region = false;
assert(false, "Trying to allocate TLAB larger than the humongous threshold: " SIZE_FORMAT " > " SIZE_FORMAT,
req.size(), ShenandoahHeapRegion::humongous_threshold_words());
assert(false, "Trying to allocate TLAB in humongous region: " SIZE_FORMAT, req.size());
return nullptr;
default:
ShouldNotReachHere();

View File

@ -277,14 +277,14 @@ private:
// While holding the heap lock, allocate memory for a single object or LAB which is to be entirely contained
// within a single HeapRegion as characterized by req.
//
// Precondition: req.size() <= ShenandoahHeapRegion::humongous_threshold_words().
// Precondition: !ShenandoahHeapRegion::requires_humongous(req.size())
HeapWord* allocate_single(ShenandoahAllocRequest& req, bool& in_new_region);
// While holding the heap lock, allocate memory for a humongous object which spans one or more regions that
// were previously empty. Regions that represent humongous objects are entirely dedicated to the humongous
// object. No other objects are packed into these regions.
//
// Precondition: req.size() > ShenandoahHeapRegion::humongous_threshold_words().
// Precondition: ShenandoahHeapRegion::requires_humongous(req.size())
HeapWord* allocate_contiguous(ShenandoahAllocRequest& req);
// Change region r from the Mutator partition to the GC's Collector partition. This requires that the region is entirely empty.

View File

@ -51,8 +51,6 @@ size_t ShenandoahHeapRegion::RegionSizeBytesShift = 0;
size_t ShenandoahHeapRegion::RegionSizeWordsShift = 0;
size_t ShenandoahHeapRegion::RegionSizeBytesMask = 0;
size_t ShenandoahHeapRegion::RegionSizeWordsMask = 0;
size_t ShenandoahHeapRegion::HumongousThresholdBytes = 0;
size_t ShenandoahHeapRegion::HumongousThresholdWords = 0;
size_t ShenandoahHeapRegion::MaxTLABSizeBytes = 0;
size_t ShenandoahHeapRegion::MaxTLABSizeWords = 0;
@ -598,18 +596,8 @@ 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");
guarantee(HumongousThresholdWords == 0, "we should only set it once");
HumongousThresholdWords = RegionSizeWords * ShenandoahHumongousThreshold / 100;
HumongousThresholdWords = align_down(HumongousThresholdWords, MinObjAlignment);
assert (HumongousThresholdWords <= RegionSizeWords, "sanity");
guarantee(HumongousThresholdBytes == 0, "we should only set it once");
HumongousThresholdBytes = HumongousThresholdWords * HeapWordSize;
assert (HumongousThresholdBytes <= RegionSizeBytes, "sanity");
guarantee(MaxTLABSizeWords == 0, "we should only set it once");
MaxTLABSizeWords = MIN2(RegionSizeWords, HumongousThresholdWords);
MaxTLABSizeWords = align_down(MaxTLABSizeWords, MinObjAlignment);
MaxTLABSizeWords = align_down(RegionSizeWords, MinObjAlignment);
guarantee(MaxTLABSizeBytes == 0, "we should only set it once");
MaxTLABSizeBytes = MaxTLABSizeWords * HeapWordSize;

View File

@ -217,8 +217,6 @@ private:
static size_t RegionSizeWordsShift;
static size_t RegionSizeBytesMask;
static size_t RegionSizeWordsMask;
static size_t HumongousThresholdBytes;
static size_t HumongousThresholdWords;
static size_t MaxTLABSizeBytes;
static size_t MaxTLABSizeWords;
@ -261,6 +259,10 @@ public:
return (bytes + ShenandoahHeapRegion::region_size_bytes() - 1) >> ShenandoahHeapRegion::region_size_bytes_shift();
}
inline static bool requires_humongous(size_t words) {
return words > ShenandoahHeapRegion::RegionSizeWords;
}
inline static size_t region_count() {
return ShenandoahHeapRegion::RegionCount;
}
@ -313,14 +315,6 @@ public:
return (jint)ShenandoahHeapRegion::RegionSizeWordsShift;
}
inline static size_t humongous_threshold_bytes() {
return ShenandoahHeapRegion::HumongousThresholdBytes;
}
inline static size_t humongous_threshold_words() {
return ShenandoahHeapRegion::HumongousThresholdWords;
}
inline static size_t max_tlab_size_bytes() {
return ShenandoahHeapRegion::MaxTLABSizeBytes;
}

View File

@ -43,7 +43,6 @@ void ShenandoahInitLogger::print_heap() {
log_info(gc, init)("Heap Region Count: " SIZE_FORMAT, ShenandoahHeapRegion::region_count());
log_info(gc, init)("Heap Region Size: " EXACTFMT, EXACTFMTARGS(ShenandoahHeapRegion::region_size_bytes()));
log_info(gc, init)("TLAB Size Max: " EXACTFMT, EXACTFMTARGS(ShenandoahHeapRegion::max_tlab_size_bytes()));
log_info(gc, init)("Humongous Object Threshold: " EXACTFMT, EXACTFMTARGS(ShenandoahHeapRegion::humongous_threshold_bytes()));
}
void ShenandoahInitLogger::print_gc_specific() {

View File

@ -49,13 +49,6 @@
"With automatic region sizing, the regions would be at most " \
"this large.") \
\
product(intx, ShenandoahHumongousThreshold, 100, EXPERIMENTAL, \
"Humongous objects are allocated in separate regions. " \
"This setting defines how large the object should be to be " \
"deemed humongous. Value is in percents of heap region size. " \
"This also caps the maximum TLAB size.") \
range(1, 100) \
\
product(ccstr, ShenandoahGCMode, "satb", \
"GC mode to use. Among other things, this defines which " \
"barriers are in in use. Possible values are:" \

View File

@ -1,131 +0,0 @@
/*
* Copyright (c) 2017, 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 id=default
* @key randomness
* @requires vm.gc.Shenandoah
* @library /test/lib
*
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:+ShenandoahVerify
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=50
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=90
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=99
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=100
* TestHumongousThreshold
*
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:-UseTLAB -XX:+ShenandoahVerify
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:-UseTLAB -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=50
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:-UseTLAB -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=90
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:-UseTLAB -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=99
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:-UseTLAB -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=100
* TestHumongousThreshold
*
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:ShenandoahHumongousThreshold=90 -XX:ShenandoahGCHeuristics=aggressive
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:-UseTLAB -XX:ShenandoahHumongousThreshold=90 -XX:ShenandoahGCHeuristics=aggressive
* TestHumongousThreshold
*/
/*
* @test id=16b
* @key randomness
* @requires vm.gc.Shenandoah
* @requires vm.bits == "64"
* @library /test/lib
*
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:ObjectAlignmentInBytes=16 -XX:+ShenandoahVerify
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:ObjectAlignmentInBytes=16 -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=50
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:ObjectAlignmentInBytes=16 -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=90
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:ObjectAlignmentInBytes=16 -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=99
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:ObjectAlignmentInBytes=16 -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=100
* TestHumongousThreshold
*
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:-UseTLAB -XX:ObjectAlignmentInBytes=16 -XX:+ShenandoahVerify
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:-UseTLAB -XX:ObjectAlignmentInBytes=16 -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=50
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:-UseTLAB -XX:ObjectAlignmentInBytes=16 -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=90
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:-UseTLAB -XX:ObjectAlignmentInBytes=16 -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=99
* TestHumongousThreshold
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx1g
* -XX:-UseTLAB -XX:ObjectAlignmentInBytes=16 -XX:+ShenandoahVerify -XX:ShenandoahHumongousThreshold=100
* TestHumongousThreshold
*/
import java.util.Random;
import jdk.test.lib.Utils;
public class TestHumongousThreshold {
static final long TARGET_MB = Long.getLong("target", 20_000); // 20 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)];
}
}
}

View File

@ -1,72 +0,0 @@
/*
* Copyright (c) 2017, 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
* @summary Test that Shenandoah humongous threshold args are checked
* @requires vm.gc.Shenandoah
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @run driver TestHumongousThresholdArgs
*/
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
public class TestHumongousThresholdArgs {
public static void main(String[] args) throws Exception {
{
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-Xmx128m",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseShenandoahGC",
"-version");
output.shouldHaveExitValue(0);
}
int[] valid = new int[] {1, 10, 50, 90, 100};
int[] invalid = new int[] {-100, -1, 0, 101, 1000};
for (int v : valid) {
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-Xmx128m",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseShenandoahGC",
"-XX:ShenandoahHumongousThreshold=" + v,
"-version");
output.shouldHaveExitValue(0);
}
for (int v : invalid) {
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-Xmx128m",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseShenandoahGC",
"-XX:ShenandoahHumongousThreshold=" + v,
"-version");
output.shouldHaveExitValue(1);
}
}
}