8255298: Remove SurvivorAlignmentInBytes functionality
Reviewed-by: shade, ayang, kbarrett
This commit is contained in:
parent
4031cb4190
commit
38574d5169
src/hotspot/share
gc
g1
parallel
serial
shared
runtime
test/hotspot/jtreg
@ -281,22 +281,9 @@ HeapWord* G1Allocator::old_attempt_allocation(size_t min_word_size,
|
||||
return result;
|
||||
}
|
||||
|
||||
uint G1PLABAllocator::calc_survivor_alignment_bytes() {
|
||||
assert(SurvivorAlignmentInBytes >= ObjectAlignmentInBytes, "sanity");
|
||||
if (SurvivorAlignmentInBytes == ObjectAlignmentInBytes) {
|
||||
// No need to align objects in the survivors differently, return 0
|
||||
// which means "survivor alignment is not used".
|
||||
return 0;
|
||||
} else {
|
||||
assert(SurvivorAlignmentInBytes > 0, "sanity");
|
||||
return SurvivorAlignmentInBytes;
|
||||
}
|
||||
}
|
||||
|
||||
G1PLABAllocator::G1PLABAllocator(G1Allocator* allocator) :
|
||||
_g1h(G1CollectedHeap::heap()),
|
||||
_allocator(allocator),
|
||||
_survivor_alignment_bytes(calc_survivor_alignment_bytes()) {
|
||||
_allocator(allocator) {
|
||||
for (region_type_t state = 0; state < G1HeapRegionAttr::Num; state++) {
|
||||
_direct_allocated[state] = 0;
|
||||
uint length = alloc_buffers_length(state);
|
||||
|
@ -149,13 +149,6 @@ private:
|
||||
|
||||
PLAB** _alloc_buffers[G1HeapRegionAttr::Num];
|
||||
|
||||
// The survivor alignment in effect in bytes.
|
||||
// == 0 : don't align survivors
|
||||
// != 0 : align survivors to that alignment
|
||||
// These values were chosen to favor the non-alignment case since some
|
||||
// architectures have a special compare against zero instructions.
|
||||
const uint _survivor_alignment_bytes;
|
||||
|
||||
// Number of words allocated directly (not counting PLAB allocation).
|
||||
size_t _direct_allocated[G1HeapRegionAttr::Num];
|
||||
|
||||
@ -168,10 +161,6 @@ private:
|
||||
// active NUMA nodes.
|
||||
inline uint alloc_buffers_length(region_type_t dest) const;
|
||||
|
||||
// Calculate the survivor space object alignment in bytes. Returns that or 0 if
|
||||
// there are no restrictions on survivor alignment.
|
||||
static uint calc_survivor_alignment_bytes();
|
||||
|
||||
bool may_throw_away_buffer(size_t const allocation_word_sz, size_t const buffer_size) const;
|
||||
public:
|
||||
G1PLABAllocator(G1Allocator* allocator);
|
||||
|
@ -105,11 +105,7 @@ inline HeapWord* G1PLABAllocator::plab_allocate(G1HeapRegionAttr dest,
|
||||
size_t word_sz,
|
||||
uint node_index) {
|
||||
PLAB* buffer = alloc_buffer(dest, node_index);
|
||||
if (_survivor_alignment_bytes == 0 || !dest.is_young()) {
|
||||
return buffer->allocate(word_sz);
|
||||
} else {
|
||||
return buffer->allocate_aligned(word_sz, _survivor_alignment_bytes);
|
||||
}
|
||||
return buffer->allocate(word_sz);
|
||||
}
|
||||
|
||||
inline HeapWord* G1PLABAllocator::allocate(G1HeapRegionAttr dest,
|
||||
|
@ -32,20 +32,14 @@
|
||||
HeapWord* PSYoungPromotionLAB::allocate(size_t size) {
|
||||
// Can't assert this, when young fills, we keep the LAB around, but flushed.
|
||||
// assert(_state != flushed, "Sanity");
|
||||
HeapWord* obj = CollectedHeap::align_allocation_or_fail(top(), end(), SurvivorAlignmentInBytes);
|
||||
if (obj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HeapWord* obj = top();
|
||||
HeapWord* new_top = obj + size;
|
||||
// The 'new_top>obj' check is needed to detect overflow of obj+size.
|
||||
if (new_top > obj && new_top <= end()) {
|
||||
set_top(new_top);
|
||||
assert(is_aligned(obj, SurvivorAlignmentInBytes) && is_object_aligned(new_top),
|
||||
"checking alignment");
|
||||
assert(is_object_aligned(new_top), "checking alignment");
|
||||
return obj;
|
||||
} else {
|
||||
set_top(obj);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -711,7 +711,7 @@ oop DefNewGeneration::copy_to_survivor_space(oop old) {
|
||||
|
||||
// Try allocating obj in to-space (unless too old)
|
||||
if (old->age() < tenuring_threshold()) {
|
||||
obj = (oop) to()->allocate_aligned(s);
|
||||
obj = (oop) to()->allocate(s);
|
||||
}
|
||||
|
||||
// Otherwise try allocating obj tenured
|
||||
|
@ -310,12 +310,6 @@ class CollectedHeap : public CHeapObj<mtInternal> {
|
||||
virtual size_t min_dummy_object_size() const;
|
||||
size_t tlab_alloc_reserve() const;
|
||||
|
||||
// Return the address "addr" aligned by "alignment_in_bytes" if such
|
||||
// an address is below "end". Return NULL otherwise.
|
||||
inline static HeapWord* align_allocation_or_fail(HeapWord* addr,
|
||||
HeapWord* end,
|
||||
unsigned short alignment_in_bytes);
|
||||
|
||||
// Some heaps may offer a contiguous region for shared non-blocking
|
||||
// allocation, via inlined code (by exporting the address of the top and
|
||||
// end fields defining the extent of the contiguous allocation region.)
|
||||
|
@ -30,43 +30,6 @@
|
||||
#include "oops/oop.inline.hpp"
|
||||
#include "utilities/align.hpp"
|
||||
|
||||
inline HeapWord* CollectedHeap::align_allocation_or_fail(HeapWord* addr,
|
||||
HeapWord* end,
|
||||
unsigned short alignment_in_bytes) {
|
||||
if (alignment_in_bytes <= ObjectAlignmentInBytes) {
|
||||
return addr;
|
||||
}
|
||||
|
||||
assert(is_aligned(addr, HeapWordSize),
|
||||
"Address " PTR_FORMAT " is not properly aligned.", p2i(addr));
|
||||
assert(is_aligned(alignment_in_bytes, HeapWordSize),
|
||||
"Alignment size %u is incorrect.", alignment_in_bytes);
|
||||
|
||||
HeapWord* new_addr = align_up(addr, alignment_in_bytes);
|
||||
size_t padding = pointer_delta(new_addr, addr);
|
||||
|
||||
if (padding == 0) {
|
||||
return addr;
|
||||
}
|
||||
|
||||
if (padding < CollectedHeap::min_fill_size()) {
|
||||
padding += alignment_in_bytes / HeapWordSize;
|
||||
assert(padding >= CollectedHeap::min_fill_size(),
|
||||
"alignment_in_bytes %u is expect to be larger "
|
||||
"than the minimum object size", alignment_in_bytes);
|
||||
new_addr = addr + padding;
|
||||
}
|
||||
|
||||
assert(new_addr > addr, "Unexpected arithmetic overflow "
|
||||
PTR_FORMAT " not greater than " PTR_FORMAT, p2i(new_addr), p2i(addr));
|
||||
if(new_addr < end) {
|
||||
CollectedHeap::fill_with_object(addr, padding);
|
||||
return new_addr;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
inline oop CollectedHeap::obj_allocate(Klass* klass, int size, TRAPS) {
|
||||
ObjAllocator allocator(klass, size, THREAD);
|
||||
return allocator.allocate();
|
||||
|
@ -438,22 +438,3 @@ JVMFlag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
|
||||
}
|
||||
}
|
||||
|
||||
JVMFlag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) {
|
||||
if (value != 0) {
|
||||
if (!is_power_of_2(value)) {
|
||||
JVMFlag::printError(verbose,
|
||||
"SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
|
||||
"power of 2\n",
|
||||
value);
|
||||
return JVMFlag::VIOLATES_CONSTRAINT;
|
||||
}
|
||||
if (value < ObjectAlignmentInBytes) {
|
||||
JVMFlag::printError(verbose,
|
||||
"SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
|
||||
"greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n",
|
||||
value, ObjectAlignmentInBytes);
|
||||
return JVMFlag::VIOLATES_CONSTRAINT;
|
||||
}
|
||||
}
|
||||
return JVMFlag::SUCCESS;
|
||||
}
|
||||
|
@ -67,8 +67,7 @@
|
||||
f(uintx, TLABWasteIncrementConstraintFunc) \
|
||||
f(uintx, SurvivorRatioConstraintFunc) \
|
||||
f(size_t, MetaspaceSizeConstraintFunc) \
|
||||
f(size_t, MaxMetaspaceSizeConstraintFunc) \
|
||||
f(intx, SurvivorAlignmentInBytesConstraintFunc)
|
||||
f(size_t, MaxMetaspaceSizeConstraintFunc)
|
||||
|
||||
SHARED_GC_CONSTRAINTS(DECLARE_CONSTRAINT)
|
||||
|
||||
|
@ -30,18 +30,6 @@
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
|
||||
inline HeapWord* PLAB::allocate_aligned(size_t word_sz, unsigned short alignment_in_bytes) {
|
||||
HeapWord* res = CollectedHeap::align_allocation_or_fail(_top, _end, alignment_in_bytes);
|
||||
if (res == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Set _top so that allocate(), which expects _top to be correctly set,
|
||||
// can be used below.
|
||||
_top = res;
|
||||
return allocate(word_sz);
|
||||
}
|
||||
|
||||
void PLABStats::add_allocated(size_t v) {
|
||||
Atomic::add(&_allocated, v);
|
||||
}
|
||||
|
@ -567,27 +567,6 @@ inline HeapWord* ContiguousSpace::par_allocate_impl(size_t size) {
|
||||
} while (true);
|
||||
}
|
||||
|
||||
HeapWord* ContiguousSpace::allocate_aligned(size_t size) {
|
||||
assert(Heap_lock->owned_by_self() || (SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread()), "not locked");
|
||||
HeapWord* end_value = end();
|
||||
|
||||
HeapWord* obj = CollectedHeap::align_allocation_or_fail(top(), end_value, SurvivorAlignmentInBytes);
|
||||
if (obj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pointer_delta(end_value, obj) >= size) {
|
||||
HeapWord* new_top = obj + size;
|
||||
set_top(new_top);
|
||||
assert(::is_aligned(obj, SurvivorAlignmentInBytes) && is_aligned(new_top),
|
||||
"checking alignment");
|
||||
return obj;
|
||||
} else {
|
||||
set_top(obj);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Requires locking.
|
||||
HeapWord* ContiguousSpace::allocate(size_t size) {
|
||||
return allocate_impl(size);
|
||||
|
@ -560,7 +560,6 @@ class ContiguousSpace: public CompactibleSpace {
|
||||
// Allocation (return NULL if full)
|
||||
virtual HeapWord* allocate(size_t word_size);
|
||||
virtual HeapWord* par_allocate(size_t word_size);
|
||||
HeapWord* allocate_aligned(size_t word_size);
|
||||
|
||||
// Iteration
|
||||
void oop_iterate(OopIterateClosure* cl);
|
||||
|
@ -1659,10 +1659,6 @@ void set_object_alignment() {
|
||||
|
||||
// Oop encoding heap max
|
||||
OopEncodingHeapMax = (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes;
|
||||
|
||||
if (SurvivorAlignmentInBytes == 0) {
|
||||
SurvivorAlignmentInBytes = ObjectAlignmentInBytes;
|
||||
}
|
||||
}
|
||||
|
||||
size_t Arguments::max_heap_for_compressed_oops() {
|
||||
|
@ -2393,11 +2393,6 @@ const intx ObjectAlignmentInBytes = 8;
|
||||
product(bool, WhiteBoxAPI, false, DIAGNOSTIC, \
|
||||
"Enable internal testing APIs") \
|
||||
\
|
||||
product(intx, SurvivorAlignmentInBytes, 0, EXPERIMENTAL, \
|
||||
"Default survivor space alignment in bytes") \
|
||||
range(8, 256) \
|
||||
constraint(SurvivorAlignmentInBytesConstraintFunc,AfterErgo) \
|
||||
\
|
||||
product(ccstr, DumpLoadedClassList, NULL, \
|
||||
"Dump the names all loaded classes, that could be stored into " \
|
||||
"the CDS archive, in the specified file") \
|
||||
|
@ -202,7 +202,6 @@ tier1_gc_2 = \
|
||||
-gc/g1/ \
|
||||
-gc/logging/TestUnifiedLoggingSwitchStress.java \
|
||||
-gc/stress \
|
||||
-gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java \
|
||||
-gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java \
|
||||
-gc/shenandoah \
|
||||
-gc/nvdimm
|
||||
|
@ -1,142 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. 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.
|
||||
*/
|
||||
|
||||
package gc.arguments;
|
||||
|
||||
import jdk.test.lib.Platform;
|
||||
import jdk.test.lib.process.ExitCode;
|
||||
import jdk.test.lib.cli.CommandLineOptionTest;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8031323
|
||||
* @summary Verify SurvivorAlignmentInBytes option processing.
|
||||
* @library /test/lib
|
||||
* @requires vm.opt.SurvivorAlignmentInBytes == null
|
||||
* & vm.opt.ObjectAlignmentInBytes == null
|
||||
* & vm.opt.UnlockExperimentalVMOptions == null
|
||||
* & (vm.opt.IgnoreUnrecognizedVMOptions == null
|
||||
* | vm.opt.IgnoreUnrecognizedVMOptions == "false")
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
* @run driver gc.arguments.TestSurvivorAlignmentInBytesOption
|
||||
*/
|
||||
public class TestSurvivorAlignmentInBytesOption {
|
||||
public static void main(String args[]) throws Throwable {
|
||||
String optionName = "SurvivorAlignmentInBytes";
|
||||
String unlockExperimentalVMOpts = "UnlockExperimentalVMOptions";
|
||||
String optionIsExperimental
|
||||
= CommandLineOptionTest.getExperimentalOptionErrorMessage(
|
||||
optionName);
|
||||
String valueIsTooSmall= ".*SurvivorAlignmentInBytes.*must be greater"
|
||||
+ " than or equal to ObjectAlignmentInBytes.*";
|
||||
String mustBePowerOf2 = ".*SurvivorAlignmentInBytes.*must be "
|
||||
+ "power of 2.*";
|
||||
|
||||
// Verify that without -XX:+UnlockExperimentalVMOptions usage of
|
||||
// SurvivorAlignmentInBytes option will cause JVM startup failure
|
||||
// with the warning message saying that that option is experimental.
|
||||
String shouldFailMessage = String.format("JVM option '%s' is "
|
||||
+ "experimental.%nJVM startup should fail without "
|
||||
+ "-XX:+UnlockExperimentalVMOptions option", optionName);
|
||||
CommandLineOptionTest.verifyJVMStartup(
|
||||
new String[]{optionIsExperimental}, null,
|
||||
shouldFailMessage, shouldFailMessage,
|
||||
ExitCode.FAIL, false,
|
||||
"-XX:-UnlockExperimentalVMOptions",
|
||||
CommandLineOptionTest.prepareBooleanFlag(
|
||||
unlockExperimentalVMOpts, false),
|
||||
CommandLineOptionTest.prepareNumericFlag(optionName, 64));
|
||||
|
||||
// Verify that with -XX:+UnlockExperimentalVMOptions passed to JVM
|
||||
// usage of SurvivorAlignmentInBytes option won't cause JVM startup
|
||||
// failure.
|
||||
String shouldPassMessage = String.format("JVM option '%s' is "
|
||||
+ "experimental.%nJVM startup should pass with "
|
||||
+ "-XX:+UnlockExperimentalVMOptions option", optionName);
|
||||
String noWarningMessage = "There should be no warnings when use "
|
||||
+ "with -XX:+UnlockExperimentalVMOptions option";
|
||||
CommandLineOptionTest.verifyJVMStartup(
|
||||
null, new String[]{optionIsExperimental},
|
||||
shouldPassMessage, noWarningMessage,
|
||||
ExitCode.OK, false,
|
||||
CommandLineOptionTest.prepareBooleanFlag(
|
||||
unlockExperimentalVMOpts, true),
|
||||
CommandLineOptionTest.prepareNumericFlag(optionName, 64));
|
||||
|
||||
// Verify that if specified SurvivorAlignmentInBytes is lower than
|
||||
// ObjectAlignmentInBytes, then the JVM startup will fail with
|
||||
// appropriate error message.
|
||||
if (Platform.is64bit()) {
|
||||
shouldFailMessage = String.format("JVM startup should fail with "
|
||||
+ "'%s' option value lower than ObjectAlignmentInBytes", optionName);
|
||||
CommandLineOptionTest.verifyJVMStartup(
|
||||
new String[]{valueIsTooSmall}, null,
|
||||
shouldFailMessage, shouldFailMessage,
|
||||
ExitCode.FAIL, false,
|
||||
CommandLineOptionTest.prepareBooleanFlag(
|
||||
unlockExperimentalVMOpts, true),
|
||||
CommandLineOptionTest.prepareNumericFlag(optionName, 8),
|
||||
CommandLineOptionTest.prepareNumericFlag("ObjectAlignmentInBytes", 16));
|
||||
}
|
||||
|
||||
// Verify that if specified SurvivorAlignmentInBytes value is not
|
||||
// a power of 2 then the JVM startup will fail with appropriate error
|
||||
// message.
|
||||
shouldFailMessage = String.format("JVM startup should fail with "
|
||||
+ "'%s' option value is not a power of 2", optionName);
|
||||
CommandLineOptionTest.verifyJVMStartup(
|
||||
new String[]{mustBePowerOf2}, null,
|
||||
shouldFailMessage, shouldFailMessage,
|
||||
ExitCode.FAIL, false,
|
||||
CommandLineOptionTest.prepareBooleanFlag(
|
||||
unlockExperimentalVMOpts, true),
|
||||
CommandLineOptionTest.prepareNumericFlag(optionName, 127));
|
||||
|
||||
// Verify that if SurvivorAlignmentInBytes has correct value, then
|
||||
// the JVM will be started without errors.
|
||||
shouldPassMessage = String.format("JVM startup should pass with "
|
||||
+ "correct '%s' option value", optionName);
|
||||
noWarningMessage = String.format("There should be no warnings when use "
|
||||
+ "correct '%s' option value", optionName);
|
||||
CommandLineOptionTest.verifyJVMStartup(
|
||||
null, new String[]{".*SurvivorAlignmentInBytes.*"},
|
||||
shouldPassMessage, noWarningMessage,
|
||||
ExitCode.OK, false,
|
||||
CommandLineOptionTest.prepareBooleanFlag(
|
||||
unlockExperimentalVMOpts, true),
|
||||
CommandLineOptionTest.prepareNumericFlag(optionName, 128));
|
||||
|
||||
// Verify that we can setup different SurvivorAlignmentInBytes values.
|
||||
for (int alignment = 32; alignment <= 128; alignment *= 2) {
|
||||
shouldPassMessage = String.format("JVM startup should pass with "
|
||||
+ "'%s' = %d", optionName, alignment);
|
||||
CommandLineOptionTest.verifyOptionValue(optionName,
|
||||
Integer.toString(alignment), shouldPassMessage,
|
||||
CommandLineOptionTest.prepareBooleanFlag(
|
||||
unlockExperimentalVMOpts, true),
|
||||
CommandLineOptionTest.prepareNumericFlag(
|
||||
optionName, alignment));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,176 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. 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.
|
||||
*/
|
||||
|
||||
package gc.survivorAlignment;
|
||||
|
||||
import java.lang.management.MemoryPoolMXBean;
|
||||
import java.util.Optional;
|
||||
|
||||
import sun.hotspot.WhiteBox;
|
||||
|
||||
/**
|
||||
* Helper class aimed to provide information about alignment of objects in
|
||||
* particular heap space, expected memory usage after objects' allocation so on.
|
||||
*/
|
||||
public class AlignmentHelper {
|
||||
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
|
||||
|
||||
private static final long OBJECT_ALIGNMENT_IN_BYTES_FOR_32_VM = 8L;
|
||||
|
||||
/**
|
||||
* Max relative allowed actual memory usage deviation from expected memory
|
||||
* usage.
|
||||
*/
|
||||
private static final float MAX_RELATIVE_DEVIATION = 0.05f; // 5%
|
||||
|
||||
public static final long OBJECT_ALIGNMENT_IN_BYTES = Optional.ofNullable(
|
||||
AlignmentHelper.WHITE_BOX.getIntxVMFlag("ObjectAlignmentInBytes"))
|
||||
.orElse(AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES_FOR_32_VM);
|
||||
|
||||
public static final long SURVIVOR_ALIGNMENT_IN_BYTES = Optional.ofNullable(
|
||||
AlignmentHelper.WHITE_BOX.getIntxVMFlag("SurvivorAlignmentInBytes"))
|
||||
.orElseThrow(() ->new AssertionError(
|
||||
"Unable to get SurvivorAlignmentInBytes value"));
|
||||
/**
|
||||
* Min amount of memory that will be occupied by an object.
|
||||
*/
|
||||
public static final long MIN_OBJECT_SIZE
|
||||
= AlignmentHelper.WHITE_BOX.getObjectSize(new Object());
|
||||
/**
|
||||
* Min amount of memory that will be occupied by an empty byte array.
|
||||
*/
|
||||
public static final long MIN_ARRAY_SIZE
|
||||
= AlignmentHelper.WHITE_BOX.getObjectSize(new byte[0]);
|
||||
|
||||
/**
|
||||
* Precision at which actual memory usage in a heap space represented by
|
||||
* this sizing helper could be measured.
|
||||
*/
|
||||
private final long memoryUsageMeasurementPrecision;
|
||||
/**
|
||||
* Min amount of memory that will be occupied by an object allocated in a
|
||||
* heap space represented by this sizing helper.
|
||||
*/
|
||||
private final long minObjectSizeInThisSpace;
|
||||
/**
|
||||
* Object's alignment in a heap space represented by this sizing helper.
|
||||
*/
|
||||
private final long objectAlignmentInThisRegion;
|
||||
/**
|
||||
* MemoryPoolMXBean associated with a heap space represented by this sizing
|
||||
* helper.
|
||||
*/
|
||||
private final MemoryPoolMXBean poolMXBean;
|
||||
|
||||
private static long alignUp(long value, long alignment) {
|
||||
return ((value - 1) / alignment + 1) * alignment;
|
||||
}
|
||||
|
||||
protected AlignmentHelper(long memoryUsageMeasurementPrecision,
|
||||
long objectAlignmentInThisRegion, long minObjectSizeInThisSpace,
|
||||
MemoryPoolMXBean poolMXBean) {
|
||||
this.memoryUsageMeasurementPrecision = memoryUsageMeasurementPrecision;
|
||||
this.minObjectSizeInThisSpace = minObjectSizeInThisSpace;
|
||||
this.objectAlignmentInThisRegion = objectAlignmentInThisRegion;
|
||||
this.poolMXBean = poolMXBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns how many objects have to be allocated to fill
|
||||
* {@code memoryToFill} bytes in this heap space using objects of size
|
||||
* {@code objectSize}.
|
||||
*/
|
||||
public int getObjectsCount(long memoryToFill, long objectSize) {
|
||||
return (int) (memoryToFill / getObjectSizeInThisSpace(objectSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns amount of memory that {@code objectsCount} of objects with size
|
||||
* {@code objectSize} will occupy this this space after allocation.
|
||||
*/
|
||||
public long getExpectedMemoryUsage(long objectSize, int objectsCount) {
|
||||
long correctedObjectSize = getObjectSizeInThisSpace(objectSize);
|
||||
return AlignmentHelper.alignUp(correctedObjectSize * objectsCount,
|
||||
memoryUsageMeasurementPrecision);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current memory usage in this heap space.
|
||||
*/
|
||||
public long getActualMemoryUsage() {
|
||||
return poolMXBean.getUsage().getUsed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns maximum memory usage deviation from {@code expectedMemoryUsage}
|
||||
* given the max allowed relative deviation equal to
|
||||
* {@code relativeDeviation}.
|
||||
*
|
||||
* Note that value returned by this method is aligned according to
|
||||
* memory measurement precision for this heap space.
|
||||
*/
|
||||
public long getAllowedMemoryUsageDeviation(long expectedMemoryUsage) {
|
||||
long unalignedDeviation = (long) (expectedMemoryUsage *
|
||||
AlignmentHelper.MAX_RELATIVE_DEVIATION);
|
||||
return AlignmentHelper.alignUp(unalignedDeviation,
|
||||
memoryUsageMeasurementPrecision);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns amount of memory that will be occupied by an object with size
|
||||
* {@code objectSize} in this heap space.
|
||||
*/
|
||||
public long getObjectSizeInThisSpace(long objectSize) {
|
||||
objectSize = Math.max(objectSize, minObjectSizeInThisSpace);
|
||||
|
||||
long alignedObjectSize = AlignmentHelper.alignUp(objectSize,
|
||||
objectAlignmentInThisRegion);
|
||||
long sizeDiff = alignedObjectSize - objectSize;
|
||||
|
||||
// If there is not enough space to fit padding object, then object will
|
||||
// be aligned to {@code 2 * objectAlignmentInThisRegion}.
|
||||
if (sizeDiff >= AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES
|
||||
&& sizeDiff < AlignmentHelper.MIN_OBJECT_SIZE) {
|
||||
alignedObjectSize += AlignmentHelper.MIN_OBJECT_SIZE;
|
||||
alignedObjectSize = AlignmentHelper.alignUp(alignedObjectSize,
|
||||
objectAlignmentInThisRegion);
|
||||
}
|
||||
|
||||
return alignedObjectSize;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(String.format("AlignmentHelper for memory pool '%s':%n",
|
||||
poolMXBean.getName()));
|
||||
builder.append(String.format("Memory usage measurement precision: %d%n",
|
||||
memoryUsageMeasurementPrecision));
|
||||
builder.append(String.format("Min object size in this space: %d%n",
|
||||
minObjectSizeInThisSpace));
|
||||
builder.append(String.format("Object alignment in this space: %d%n",
|
||||
objectAlignmentInThisRegion));
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
@ -1,395 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. 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.
|
||||
*/
|
||||
|
||||
package gc.survivorAlignment;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryPoolMXBean;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import jdk.test.lib.Asserts;
|
||||
import com.sun.management.ThreadMXBean;
|
||||
import sun.hotspot.WhiteBox;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
/**
|
||||
* Main class for tests on {@code SurvivorAlignmentInBytes} option.
|
||||
*
|
||||
* Typical usage is to obtain instance using fromArgs method, allocate objects
|
||||
* and verify that actual memory usage in tested heap space is close to
|
||||
* expected.
|
||||
*/
|
||||
public class SurvivorAlignmentTestMain {
|
||||
enum HeapSpace {
|
||||
EDEN,
|
||||
SURVIVOR,
|
||||
TENURED
|
||||
}
|
||||
|
||||
public static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
|
||||
|
||||
public static final long MAX_TENURING_THRESHOLD = Optional.ofNullable(
|
||||
SurvivorAlignmentTestMain.WHITE_BOX.getIntxVMFlag(
|
||||
"MaxTenuringThreshold")).orElse(15L);
|
||||
|
||||
/**
|
||||
* Regexp used to parse memory size params, like 2G, 34m or 15k.
|
||||
*/
|
||||
private static final Pattern SIZE_REGEX
|
||||
= Pattern.compile("(?<size>[0-9]+)(?<multiplier>[GMKgmk])?");
|
||||
|
||||
// Names of different heap spaces.
|
||||
private static final String DEF_NEW_EDEN = "Eden Space";
|
||||
private static final String DEF_NEW_SURVIVOR = "Survivor Space";
|
||||
private static final String PAR_NEW_EDEN = "Par Eden Space";
|
||||
private static final String PAR_NEW_SURVIVOR = "Par Survivor Space";
|
||||
private static final String PS_EDEN = "PS Eden Space";
|
||||
private static final String PS_SURVIVOR = "PS Survivor Space";
|
||||
private static final String G1_EDEN = "G1 Eden Space";
|
||||
private static final String G1_SURVIVOR = "G1 Survivor Space";
|
||||
private static final String SERIAL_TENURED = "Tenured Gen";
|
||||
private static final String PS_TENURED = "PS Old Gen";
|
||||
private static final String G1_TENURED = "G1 Old Gen";
|
||||
|
||||
private static final long G1_HEAP_REGION_SIZE = Optional.ofNullable(
|
||||
SurvivorAlignmentTestMain.WHITE_BOX.getUintxVMFlag(
|
||||
"G1HeapRegionSize")).orElse(-1L);
|
||||
|
||||
private static final AlignmentHelper EDEN_SPACE_HELPER;
|
||||
private static final AlignmentHelper SURVIVOR_SPACE_HELPER;
|
||||
private static final AlignmentHelper TENURED_SPACE_HELPER;
|
||||
/**
|
||||
* Amount of memory that should be filled during a test run.
|
||||
*/
|
||||
private final long memoryToFill;
|
||||
/**
|
||||
* The size of an objects that will be allocated during a test run.
|
||||
*/
|
||||
private final long objectSize;
|
||||
/**
|
||||
* Amount of memory that will be actually occupied by an object in eden
|
||||
* space.
|
||||
*/
|
||||
private final long actualObjectSize;
|
||||
/**
|
||||
* Storage for allocated objects.
|
||||
*/
|
||||
private final Object[] garbage;
|
||||
/**
|
||||
* Heap space whose memory usage is a subject of assertions during the test
|
||||
* run.
|
||||
*/
|
||||
private final HeapSpace testedSpace;
|
||||
|
||||
private long[] baselinedThreadMemoryUsage = null;
|
||||
private long[] threadIds = null;
|
||||
|
||||
/**
|
||||
* Initialize {@code EDEN_SPACE_HELPER}, {@code SURVIVOR_SPACE_HELPER} and
|
||||
* {@code TENURED_SPACE_HELPER} to represent heap spaces in use.
|
||||
*
|
||||
* Note that regardless to GC object's alignment in survivor space is
|
||||
* expected to be equal to {@code SurvivorAlignmentInBytes} value and
|
||||
* alignment in other spaces is expected to be equal to
|
||||
* {@code ObjectAlignmentInBytes} value.
|
||||
*
|
||||
* For G1 GC MXBeans could report memory usage only with region size
|
||||
* precision (if an object allocated in some G1 heap region, then all region
|
||||
* will claimed as used), so for G1's spaces precision is equal to
|
||||
* {@code G1HeapRegionSize} value.
|
||||
*/
|
||||
static {
|
||||
AlignmentHelper edenHelper = null;
|
||||
AlignmentHelper survivorHelper = null;
|
||||
AlignmentHelper tenuredHelper = null;
|
||||
for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) {
|
||||
switch (pool.getName()) {
|
||||
case SurvivorAlignmentTestMain.DEF_NEW_EDEN:
|
||||
case SurvivorAlignmentTestMain.PAR_NEW_EDEN:
|
||||
case SurvivorAlignmentTestMain.PS_EDEN:
|
||||
Asserts.assertNull(edenHelper,
|
||||
"Only one bean for eden space is expected.");
|
||||
edenHelper = new AlignmentHelper(
|
||||
AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
|
||||
AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
|
||||
AlignmentHelper.MIN_OBJECT_SIZE, pool);
|
||||
break;
|
||||
case SurvivorAlignmentTestMain.G1_EDEN:
|
||||
Asserts.assertNull(edenHelper,
|
||||
"Only one bean for eden space is expected.");
|
||||
edenHelper = new AlignmentHelper(
|
||||
SurvivorAlignmentTestMain.G1_HEAP_REGION_SIZE,
|
||||
AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
|
||||
AlignmentHelper.MIN_OBJECT_SIZE, pool);
|
||||
break;
|
||||
case SurvivorAlignmentTestMain.DEF_NEW_SURVIVOR:
|
||||
case SurvivorAlignmentTestMain.PAR_NEW_SURVIVOR:
|
||||
case SurvivorAlignmentTestMain.PS_SURVIVOR:
|
||||
Asserts.assertNull(survivorHelper,
|
||||
"Only one bean for survivor space is expected.");
|
||||
survivorHelper = new AlignmentHelper(
|
||||
AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
|
||||
AlignmentHelper.SURVIVOR_ALIGNMENT_IN_BYTES,
|
||||
AlignmentHelper.MIN_OBJECT_SIZE, pool);
|
||||
break;
|
||||
case SurvivorAlignmentTestMain.G1_SURVIVOR:
|
||||
Asserts.assertNull(survivorHelper,
|
||||
"Only one bean for survivor space is expected.");
|
||||
survivorHelper = new AlignmentHelper(
|
||||
SurvivorAlignmentTestMain.G1_HEAP_REGION_SIZE,
|
||||
AlignmentHelper.SURVIVOR_ALIGNMENT_IN_BYTES,
|
||||
AlignmentHelper.MIN_OBJECT_SIZE, pool);
|
||||
break;
|
||||
case SurvivorAlignmentTestMain.SERIAL_TENURED:
|
||||
case SurvivorAlignmentTestMain.PS_TENURED:
|
||||
case SurvivorAlignmentTestMain.G1_TENURED:
|
||||
Asserts.assertNull(tenuredHelper,
|
||||
"Only one bean for tenured space is expected.");
|
||||
tenuredHelper = new AlignmentHelper(
|
||||
AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
|
||||
AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
|
||||
AlignmentHelper.MIN_OBJECT_SIZE, pool);
|
||||
break;
|
||||
}
|
||||
}
|
||||
EDEN_SPACE_HELPER = Objects.requireNonNull(edenHelper,
|
||||
"AlignmentHelper for eden space should be initialized.");
|
||||
SURVIVOR_SPACE_HELPER = Objects.requireNonNull(survivorHelper,
|
||||
"AlignmentHelper for survivor space should be initialized.");
|
||||
TENURED_SPACE_HELPER = Objects.requireNonNull(tenuredHelper,
|
||||
"AlignmentHelper for tenured space should be initialized.");
|
||||
}
|
||||
/**
|
||||
* Returns an SurvivorAlignmentTestMain instance constructed using CLI
|
||||
* options.
|
||||
*
|
||||
* Following options are expected:
|
||||
* <ul>
|
||||
* <li>memoryToFill</li>
|
||||
* <li>objectSize</li>
|
||||
* </ul>
|
||||
*
|
||||
* Both argument may contain multiplier suffix k, m or g.
|
||||
*/
|
||||
public static SurvivorAlignmentTestMain fromArgs(String[] args) {
|
||||
Asserts.assertEQ(args.length, 3, "Expected three arguments: "
|
||||
+ "memory size, object size and tested heap space name.");
|
||||
|
||||
long memoryToFill = parseSize(args[0]);
|
||||
long objectSize = Math.max(parseSize(args[1]),
|
||||
AlignmentHelper.MIN_ARRAY_SIZE);
|
||||
HeapSpace testedSpace = HeapSpace.valueOf(args[2]);
|
||||
|
||||
return new SurvivorAlignmentTestMain(memoryToFill, objectSize,
|
||||
testedSpace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value parsed from a string with format
|
||||
* <integer><multiplier>.
|
||||
*/
|
||||
private static long parseSize(String sizeString) {
|
||||
Matcher matcher = SIZE_REGEX.matcher(sizeString);
|
||||
Asserts.assertTrue(matcher.matches(),
|
||||
"sizeString should have following format \"[0-9]+([MBK])?\"");
|
||||
long size = Long.valueOf(matcher.group("size"));
|
||||
|
||||
if (matcher.group("multiplier") != null) {
|
||||
long K = 1024L;
|
||||
// fall through multipliers
|
||||
switch (matcher.group("multiplier").toLowerCase()) {
|
||||
case "g":
|
||||
size *= K;
|
||||
case "m":
|
||||
size *= K;
|
||||
case "k":
|
||||
size *= K;
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
private SurvivorAlignmentTestMain(long memoryToFill, long objectSize,
|
||||
HeapSpace testedSpace) {
|
||||
this.objectSize = objectSize;
|
||||
this.memoryToFill = memoryToFill;
|
||||
this.testedSpace = testedSpace;
|
||||
|
||||
AlignmentHelper helper = SurvivorAlignmentTestMain.EDEN_SPACE_HELPER;
|
||||
|
||||
this.actualObjectSize = helper.getObjectSizeInThisSpace(
|
||||
this.objectSize);
|
||||
int arrayLength = helper.getObjectsCount(memoryToFill, this.objectSize);
|
||||
garbage = new Object[arrayLength];
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate byte arrays to fill {@code memoryToFill} memory.
|
||||
*/
|
||||
public void allocate() {
|
||||
int byteArrayLength = Math.max((int) (objectSize
|
||||
- Unsafe.ARRAY_BYTE_BASE_OFFSET), 0);
|
||||
|
||||
for (int i = 0; i < garbage.length; i++) {
|
||||
garbage[i] = new byte[byteArrayLength];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Release memory occupied after {@code allocate} call.
|
||||
*/
|
||||
public void release() {
|
||||
for (int i = 0; i < garbage.length; i++) {
|
||||
garbage[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns expected amount of memory occupied in a {@code heapSpace} by
|
||||
* objects referenced from {@code garbage} array.
|
||||
*/
|
||||
public long getExpectedMemoryUsage() {
|
||||
AlignmentHelper alignmentHelper = getAlignmentHelper(testedSpace);
|
||||
return alignmentHelper.getExpectedMemoryUsage(objectSize,
|
||||
garbage.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that memory usage in a {@code heapSpace} deviates from
|
||||
* {@code expectedUsage} for no more than {@code MAX_RELATIVE_DEVIATION}.
|
||||
*/
|
||||
public void verifyMemoryUsage(long expectedUsage) {
|
||||
AlignmentHelper alignmentHelper = getAlignmentHelper(testedSpace);
|
||||
|
||||
long actualMemoryUsage = alignmentHelper.getActualMemoryUsage();
|
||||
boolean otherThreadsAllocatedMemory = areOtherThreadsAllocatedMemory();
|
||||
|
||||
long memoryUsageDiff = Math.abs(actualMemoryUsage - expectedUsage);
|
||||
long maxAllowedUsageDiff
|
||||
= alignmentHelper.getAllowedMemoryUsageDeviation(expectedUsage);
|
||||
|
||||
System.out.println("Verifying memory usage in space: " + testedSpace);
|
||||
System.out.println("Allocated objects count: " + garbage.length);
|
||||
System.out.println("Desired object size: " + objectSize);
|
||||
System.out.println("Actual object size: " + actualObjectSize);
|
||||
System.out.println("Expected object size in space: "
|
||||
+ alignmentHelper.getObjectSizeInThisSpace(objectSize));
|
||||
System.out.println("Expected memory usage: " + expectedUsage);
|
||||
System.out.println("Actual memory usage: " + actualMemoryUsage);
|
||||
System.out.println("Memory usage diff: " + memoryUsageDiff);
|
||||
System.out.println("Max allowed usage diff: " + maxAllowedUsageDiff);
|
||||
|
||||
if (memoryUsageDiff > maxAllowedUsageDiff
|
||||
&& otherThreadsAllocatedMemory) {
|
||||
System.out.println("Memory usage diff is incorrect, but it seems "
|
||||
+ "like someone else allocated objects");
|
||||
return;
|
||||
}
|
||||
|
||||
Asserts.assertLTE(memoryUsageDiff, maxAllowedUsageDiff,
|
||||
"Actual memory usage should not deviate from expected for " +
|
||||
"more then " + maxAllowedUsageDiff);
|
||||
}
|
||||
|
||||
/**
|
||||
* Baselines amount of memory allocated by each thread.
|
||||
*/
|
||||
public void baselineMemoryAllocation() {
|
||||
ThreadMXBean bean = (ThreadMXBean) ManagementFactory.getThreadMXBean();
|
||||
threadIds = bean.getAllThreadIds();
|
||||
baselinedThreadMemoryUsage = bean.getThreadAllocatedBytes(threadIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if threads other then the current thread were allocating objects
|
||||
* after baselinedThreadMemoryUsage call.
|
||||
*
|
||||
* If baselinedThreadMemoryUsage was not called, then this method will return
|
||||
* {@code false}.
|
||||
*/
|
||||
public boolean areOtherThreadsAllocatedMemory() {
|
||||
if (baselinedThreadMemoryUsage == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ThreadMXBean bean = (ThreadMXBean) ManagementFactory.getThreadMXBean();
|
||||
long currentMemoryAllocation[]
|
||||
= bean.getThreadAllocatedBytes(threadIds);
|
||||
boolean otherThreadsAllocatedMemory = false;
|
||||
|
||||
System.out.println("Verifying amount of memory allocated by threads:");
|
||||
for (int i = 0; i < threadIds.length; i++) {
|
||||
System.out.format("Thread %d%nbaseline allocation: %d"
|
||||
+ "%ncurrent allocation:%d%n", threadIds[i],
|
||||
baselinedThreadMemoryUsage[i], currentMemoryAllocation[i]);
|
||||
System.out.println(bean.getThreadInfo(threadIds[i]));
|
||||
|
||||
long bytesAllocated = Math.abs(currentMemoryAllocation[i]
|
||||
- baselinedThreadMemoryUsage[i]);
|
||||
if (bytesAllocated > 0
|
||||
&& threadIds[i] != Thread.currentThread().getId()) {
|
||||
otherThreadsAllocatedMemory = true;
|
||||
}
|
||||
}
|
||||
|
||||
return otherThreadsAllocatedMemory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(String.format("SurvivorAlignmentTestMain info:%n"));
|
||||
builder.append(String.format("Desired object size: %d%n", objectSize));
|
||||
builder.append(String.format("Memory to fill: %d%n", memoryToFill));
|
||||
builder.append(String.format("Objects to be allocated: %d%n",
|
||||
garbage.length));
|
||||
|
||||
builder.append(String.format("Alignment helpers to be used: %n"));
|
||||
for (HeapSpace heapSpace: HeapSpace.values()) {
|
||||
builder.append(String.format("For space %s:%n%s%n", heapSpace,
|
||||
getAlignmentHelper(heapSpace)));
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code AlignmentHelper} for a space {@code heapSpace}.
|
||||
*/
|
||||
public static AlignmentHelper getAlignmentHelper(HeapSpace heapSpace) {
|
||||
switch (heapSpace) {
|
||||
case EDEN:
|
||||
return SurvivorAlignmentTestMain.EDEN_SPACE_HELPER;
|
||||
case SURVIVOR:
|
||||
return SurvivorAlignmentTestMain.SURVIVOR_SPACE_HELPER;
|
||||
case TENURED:
|
||||
return SurvivorAlignmentTestMain.TENURED_SPACE_HELPER;
|
||||
default:
|
||||
throw new Error("Unexpected heap space: " + heapSpace);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. 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.
|
||||
*/
|
||||
|
||||
package gc.survivorAlignment;
|
||||
|
||||
/**
|
||||
* @test gc.survivorAlignment.TestAllocationInEden
|
||||
* @bug 8031323
|
||||
* @summary Verify that object's alignment in eden space is not affected by
|
||||
* SurvivorAlignmentInBytes option.
|
||||
* @requires vm.gc != "Z" & vm.gc != "Shenandoah"
|
||||
* @library /test/lib
|
||||
* @library /
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
* @build sun.hotspot.WhiteBox
|
||||
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
|
||||
* -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=32 -XX:-UseTLAB -XX:-ResizePLAB
|
||||
* -XX:OldSize=128m -XX:MaxHeapSize=192m
|
||||
* -XX:-ExplicitGCInvokesConcurrent
|
||||
* gc.survivorAlignment.TestAllocationInEden 10m 9 EDEN
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
|
||||
* -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=32 -XX:-UseTLAB -XX:-ResizePLAB
|
||||
* -XX:OldSize=128m -XX:MaxHeapSize=192m
|
||||
* -XX:-ExplicitGCInvokesConcurrent
|
||||
* gc.survivorAlignment.TestAllocationInEden 10m 47 EDEN
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
|
||||
* -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=64 -XX:-UseTLAB -XX:-ResizePLAB
|
||||
* -XX:OldSize=128m -XX:MaxHeapSize=192m
|
||||
* -XX:-ExplicitGCInvokesConcurrent
|
||||
* gc.survivorAlignment.TestAllocationInEden 10m 9 EDEN
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
|
||||
* -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=64 -XX:-UseTLAB -XX:-ResizePLAB
|
||||
* -XX:OldSize=128m -XX:MaxHeapSize=192m
|
||||
* -XX:-ExplicitGCInvokesConcurrent
|
||||
* gc.survivorAlignment.TestAllocationInEden 10m 87 EDEN
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
|
||||
* -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=128 -XX:-UseTLAB -XX:-ResizePLAB
|
||||
* -XX:OldSize=128m -XX:MaxHeapSize=192m
|
||||
* -XX:-ExplicitGCInvokesConcurrent
|
||||
* gc.survivorAlignment.TestAllocationInEden 10m 9 EDEN
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
|
||||
* -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=128 -XX:-UseTLAB -XX:-ResizePLAB
|
||||
* -XX:OldSize=128m -XX:MaxHeapSize=192m
|
||||
* -XX:-ExplicitGCInvokesConcurrent
|
||||
* gc.survivorAlignment.TestAllocationInEden 10m 147 EDEN
|
||||
*/
|
||||
public class TestAllocationInEden {
|
||||
public static void main(String args[]) {
|
||||
SurvivorAlignmentTestMain test
|
||||
= SurvivorAlignmentTestMain.fromArgs(args);
|
||||
System.out.println(test);
|
||||
|
||||
long expectedMemoryUsage = test.getExpectedMemoryUsage();
|
||||
test.baselineMemoryAllocation();
|
||||
System.gc();
|
||||
|
||||
test.allocate();
|
||||
|
||||
test.verifyMemoryUsage(expectedMemoryUsage);
|
||||
}
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. 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.
|
||||
*/
|
||||
|
||||
package gc.survivorAlignment;
|
||||
|
||||
/**
|
||||
* @test gc.survivorAlignment.TestPromotionFromEdenToTenured
|
||||
* @bug 8031323
|
||||
* @summary Verify that objects promoted from eden space to tenured space during
|
||||
* full GC are not aligned to SurvivorAlignmentInBytes value.
|
||||
* @requires vm.gc != "Z" & vm.gc != "Shenandoah"
|
||||
* @library /test/lib
|
||||
* @library /
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
* @build sun.hotspot.WhiteBox
|
||||
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
|
||||
* -XX:OldSize=32m -XX:MaxHeapSize=96m -XX:SurvivorRatio=1
|
||||
* -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=32
|
||||
* gc.survivorAlignment.TestPromotionFromEdenToTenured 10m 9 TENURED
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
|
||||
* -XX:OldSize=32m -XX:MaxHeapSize=96m -XX:SurvivorRatio=1
|
||||
* -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=32
|
||||
* gc.survivorAlignment.TestPromotionFromEdenToTenured 10m 47 TENURED
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
|
||||
* -XX:OldSize=32m -XX:MaxHeapSize=96m
|
||||
* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=64
|
||||
* gc.survivorAlignment.TestPromotionFromEdenToTenured 10m 9 TENURED
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
|
||||
* -XX:OldSize=32m -XX:MaxHeapSize=128m
|
||||
* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=64
|
||||
* gc.survivorAlignment.TestPromotionFromEdenToTenured 10m 87 TENURED
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
|
||||
* -XX:OldSize=32M -XX:MaxHeapSize=96m -XX:SurvivorRatio=1
|
||||
* -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=128
|
||||
* gc.survivorAlignment.TestPromotionFromEdenToTenured 10m 9 TENURED
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
|
||||
* -XX:OldSize=32m -XX:MaxHeapSize=96m -XX:SurvivorRatio=1
|
||||
* -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=128
|
||||
* gc.survivorAlignment.TestPromotionFromEdenToTenured 10m 147 TENURED
|
||||
*/
|
||||
public class TestPromotionFromEdenToTenured {
|
||||
public static void main(String args[]) {
|
||||
SurvivorAlignmentTestMain test
|
||||
= SurvivorAlignmentTestMain.fromArgs(args);
|
||||
System.out.println(test);
|
||||
|
||||
long expectedMemoryUsage = test.getExpectedMemoryUsage();
|
||||
test.baselineMemoryAllocation();
|
||||
System.gc();
|
||||
// increase expected usage by current old gen usage
|
||||
expectedMemoryUsage += SurvivorAlignmentTestMain.getAlignmentHelper(
|
||||
SurvivorAlignmentTestMain.HeapSpace.TENURED)
|
||||
.getActualMemoryUsage();
|
||||
|
||||
test.allocate();
|
||||
System.gc();
|
||||
|
||||
test.verifyMemoryUsage(expectedMemoryUsage);
|
||||
}
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. 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.
|
||||
*/
|
||||
|
||||
package gc.survivorAlignment;
|
||||
|
||||
/**
|
||||
* @test gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterFullGC
|
||||
* @bug 8031323
|
||||
* @summary Verify that objects promoted from survivor space to tenured space
|
||||
* during full GC are not aligned to SurvivorAlignmentInBytes value.
|
||||
* @requires vm.gc != "Z" & vm.gc != "Shenandoah"
|
||||
* @library /test/lib
|
||||
* @library /
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
* @build sun.hotspot.WhiteBox
|
||||
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
|
||||
* -XX:OldSize=32m -XX:MaxHeapSize=160m
|
||||
* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=32
|
||||
* gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterFullGC 10m 9 TENURED
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
|
||||
* -XX:OldSize=32m -XX:MaxHeapSize=160m -XX:-ResizePLAB
|
||||
* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=32
|
||||
* gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterFullGC 20m 47
|
||||
* TENURED
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=200m -XX:MaxNewSize=200m
|
||||
* -XX:OldSize=32m -XX:MaxHeapSize=232m
|
||||
* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=64
|
||||
* gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterFullGC 10m 9 TENURED
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
|
||||
* -XX:OldSize=32m -XX:MaxHeapSize=160m
|
||||
* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=64
|
||||
* gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterFullGC 20m 87
|
||||
* TENURED
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m
|
||||
* -XX:OldSize=32M -XX:MaxHeapSize=288m
|
||||
* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=128
|
||||
* gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterFullGC 10m 9
|
||||
* TENURED
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
|
||||
* -XX:OldSize=32m -XX:MaxHeapSize=160m
|
||||
* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=128
|
||||
* gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterFullGC 20m 147
|
||||
* TENURED
|
||||
*/
|
||||
public class TestPromotionFromSurvivorToTenuredAfterFullGC {
|
||||
public static void main(String args[]) {
|
||||
SurvivorAlignmentTestMain test
|
||||
= SurvivorAlignmentTestMain.fromArgs(args);
|
||||
System.out.println(test);
|
||||
|
||||
long expectedMemoryUsage = test.getExpectedMemoryUsage();
|
||||
test.baselineMemoryAllocation();
|
||||
System.gc();
|
||||
// increase expected usage by current old gen usage
|
||||
expectedMemoryUsage += SurvivorAlignmentTestMain.getAlignmentHelper(
|
||||
SurvivorAlignmentTestMain.HeapSpace.TENURED)
|
||||
.getActualMemoryUsage();
|
||||
|
||||
test.allocate();
|
||||
SurvivorAlignmentTestMain.WHITE_BOX.youngGC();
|
||||
System.gc();
|
||||
|
||||
test.verifyMemoryUsage(expectedMemoryUsage);
|
||||
}
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. 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.
|
||||
*/
|
||||
|
||||
package gc.survivorAlignment;
|
||||
|
||||
/**
|
||||
* @test gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterMinorGC
|
||||
* @bug 8031323
|
||||
* @summary Verify that objects promoted from survivor space to tenured space
|
||||
* when their age exceeded tenuring threshold are not aligned to
|
||||
* SurvivorAlignmentInBytes value.
|
||||
* @requires vm.gc != "Z" & vm.gc != "Shenandoah"
|
||||
* @library /test/lib
|
||||
* @library /
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
* @build sun.hotspot.WhiteBox
|
||||
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
|
||||
* -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1 -XX:-ResizePLAB
|
||||
* -XX:-ExplicitGCInvokesConcurrent
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=32
|
||||
* gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9
|
||||
* TENURED
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
|
||||
* -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1 -XX:-ResizePLAB
|
||||
* -XX:-ExplicitGCInvokesConcurrent
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=32
|
||||
* gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 47
|
||||
* TENURED
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=200m -XX:MaxNewSize=200m
|
||||
* -XX:OldSize=32M -XX:MaxHeapSize=232m -XX:SurvivorRatio=1 -XX:-ResizePLAB
|
||||
* -XX:-ExplicitGCInvokesConcurrent
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=64
|
||||
* gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9
|
||||
* TENURED
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
|
||||
* -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1 -XX:-ResizePLAB
|
||||
* -XX:-ExplicitGCInvokesConcurrent
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=64
|
||||
* gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 87
|
||||
* TENURED
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m
|
||||
* -XX:OldSize=32M -XX:MaxHeapSize=288m -XX:SurvivorRatio=1 -XX:-ResizePLAB
|
||||
* -XX:-ExplicitGCInvokesConcurrent
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=128
|
||||
* gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9
|
||||
* TENURED
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
|
||||
* -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1 -XX:-ResizePLAB
|
||||
* -XX:-ExplicitGCInvokesConcurrent
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=128
|
||||
* gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 147
|
||||
* TENURED
|
||||
*/
|
||||
public class TestPromotionFromSurvivorToTenuredAfterMinorGC {
|
||||
public static void main(String args[]) throws Exception {
|
||||
SurvivorAlignmentTestMain test
|
||||
= SurvivorAlignmentTestMain.fromArgs(args);
|
||||
System.out.println(test);
|
||||
|
||||
long expectedMemoryUsage = test.getExpectedMemoryUsage();
|
||||
test.baselineMemoryAllocation();
|
||||
SurvivorAlignmentTestMain.WHITE_BOX.fullGC();
|
||||
// increase expected usage by current old gen usage
|
||||
expectedMemoryUsage += SurvivorAlignmentTestMain.getAlignmentHelper(
|
||||
SurvivorAlignmentTestMain.HeapSpace.TENURED)
|
||||
.getActualMemoryUsage();
|
||||
|
||||
test.allocate();
|
||||
for (int i = 0; i <= SurvivorAlignmentTestMain.MAX_TENURING_THRESHOLD; i++) {
|
||||
SurvivorAlignmentTestMain.WHITE_BOX.youngGC();
|
||||
}
|
||||
|
||||
// Sometimes we see that data unrelated to the test has been allocated during
|
||||
// the loop. This data is included in the expectedMemoryUsage since we look
|
||||
// through all threads to see what they allocated. If this data is still in
|
||||
// the survivor area however, it should not be included in expectedMemoryUsage
|
||||
// since the verification below only look at what's in tenured space.
|
||||
expectedMemoryUsage -= SurvivorAlignmentTestMain.getAlignmentHelper(
|
||||
SurvivorAlignmentTestMain.HeapSpace.SURVIVOR)
|
||||
.getActualMemoryUsage();
|
||||
test.verifyMemoryUsage(expectedMemoryUsage);
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. 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.
|
||||
*/
|
||||
|
||||
package gc.survivorAlignment;
|
||||
|
||||
/**
|
||||
* @test gc.survivorAlignment.TestPromotionLABLargeSurvivorAlignment
|
||||
* @bug 8060463
|
||||
* @summary Verify that objects promoted from eden space to survivor space
|
||||
* with large values for SurvivorAlignmentInBytes succeed.
|
||||
* @requires vm.opt.ExplicitGCInvokesConcurrent != true
|
||||
* @run main/othervm -Xmx128m
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=8 -XX:SurvivorRatio=1
|
||||
* -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* gc.survivorAlignment.TestPromotionLABLargeSurvivorAlignment
|
||||
* @run main/othervm -Xmx128m
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=16 -XX:SurvivorRatio=1
|
||||
* -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* gc.survivorAlignment.TestPromotionLABLargeSurvivorAlignment
|
||||
* @run main/othervm -Xmx128m
|
||||
* -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=256 -XX:SurvivorRatio=1
|
||||
* -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* gc.survivorAlignment.TestPromotionLABLargeSurvivorAlignment
|
||||
*/
|
||||
public class TestPromotionLABLargeSurvivorAlignment {
|
||||
public static void main(String args[]) {
|
||||
Object garbage[] = new Object[1000000];
|
||||
for (int i = 0; i < garbage.length; i++) {
|
||||
garbage[i] = new byte[0];
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
System.gc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. 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.
|
||||
*/
|
||||
|
||||
package gc.survivorAlignment;
|
||||
|
||||
/**
|
||||
* @test gc.survivorAlignment.TestPromotionToSurvivor
|
||||
* @bug 8031323
|
||||
* @summary Verify that objects promoted from eden space to survivor space after
|
||||
* minor GC are aligned to SurvivorAlignmentInBytes.
|
||||
* @requires vm.gc != "Z" & vm.gc != "Shenandoah"
|
||||
* @library /test/lib
|
||||
* @library /
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
* @build sun.hotspot.WhiteBox
|
||||
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
|
||||
* -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=32 -XX:OldSize=128m
|
||||
* -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* gc.survivorAlignment.TestPromotionToSurvivor 10m 9 SURVIVOR
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
|
||||
* -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=32 -XX:OldSize=128m
|
||||
* -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* gc.survivorAlignment.TestPromotionToSurvivor 20m 47 SURVIVOR
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
|
||||
* -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=64 -XX:OldSize=128m
|
||||
* -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* gc.survivorAlignment.TestPromotionToSurvivor 8m 9 SURVIVOR
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
|
||||
* -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=64 -XX:OldSize=128m
|
||||
* -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* gc.survivorAlignment.TestPromotionToSurvivor 20m 87 SURVIVOR
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m
|
||||
* -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=128 -XX:OldSize=128m
|
||||
* -XX:MaxHeapSize=384m -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* gc.survivorAlignment.TestPromotionToSurvivor 10m 9 SURVIVOR
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
|
||||
* -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
|
||||
* -XX:SurvivorAlignmentInBytes=128 -XX:OldSize=128m
|
||||
* -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB
|
||||
* gc.survivorAlignment.TestPromotionToSurvivor 20m 147 SURVIVOR
|
||||
*/
|
||||
public class TestPromotionToSurvivor {
|
||||
public static void main(String args[]) {
|
||||
SurvivorAlignmentTestMain test
|
||||
= SurvivorAlignmentTestMain.fromArgs(args);
|
||||
System.out.println(test);
|
||||
|
||||
long expectedUsage = test.getExpectedMemoryUsage();
|
||||
test.baselineMemoryAllocation();
|
||||
SurvivorAlignmentTestMain.WHITE_BOX.fullGC();
|
||||
|
||||
test.allocate();
|
||||
SurvivorAlignmentTestMain.WHITE_BOX.youngGC();
|
||||
|
||||
test.verifyMemoryUsage(expectedUsage);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user