Skip to content

Commit

Permalink
8303815: Improve Metaspace test speed
Browse files Browse the repository at this point in the history
Reviewed-by: stefank, dholmes
  • Loading branch information
tstuefe committed Aug 24, 2023
1 parent 3699666 commit de0e46c
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 22 deletions.
4 changes: 2 additions & 2 deletions test/hotspot/gtest/metaspace/test_chunkManager_stress.cpp
Expand Up @@ -194,7 +194,7 @@ class ChunkManagerRandomChunkAllocTest {

IntRange rand(100);

for (int j = 0; j < 1000; j++) {
for (int j = 0; j < 750; j++) {

bool force_alloc = false;
bool force_free = true;
Expand Down Expand Up @@ -249,7 +249,7 @@ class ChunkManagerRandomChunkAllocTest {
// {}

void do_tests() {
const int num_runs = 5;
const int num_runs = 3;
for (int n = 0; n < num_runs; n++) {
one_test();
}
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/gtest/metaspace/test_freeblocks.cpp
Expand Up @@ -130,7 +130,7 @@ class FreeBlocksTest {
bool forcefeed = false;
bool draining = false;
bool stop = false;
int iter = 100000; // safety stop
int iter = 25000; // safety stop
while (!stop && iter > 0) {
iter --;
int surprise = (int)os::random() % 10;
Expand Down
Expand Up @@ -380,7 +380,7 @@ class MetaspaceArenaTest {
// - (rarely) deallocate (simulates metaspace deallocation, e.g. class redefinitions)
// - delete a test bed (simulates collection of a loader and subsequent return of metaspace to freelists)

const int iterations = 10000;
const int iterations = 2500;

// Lets have a ceiling on number of words allocated (this is independent from the commit limit)
const size_t max_allocation_size = 8 * M;
Expand Down
15 changes: 5 additions & 10 deletions test/hotspot/gtest/metaspace/test_virtualspacenode.cpp
Expand Up @@ -355,7 +355,7 @@ class VirtualSpaceNodeTest {
TestMap testmap(c->word_size());
assert(testmap.get_num_set() == 0, "Sanity");

for (int run = 0; run < 1000; run++) {
for (int run = 0; run < 750; run++) {

const size_t committed_words_before = testmap.get_num_set();
ASSERT_EQ(_commit_limiter.committed_words(), committed_words_before);
Expand Down Expand Up @@ -425,7 +425,7 @@ class VirtualSpaceNodeTest {

assert(_commit_limit >= _vs_word_size, "No commit limit here pls");

// Allocate a root chunk and commit a random part of it. Then repeatedly split
// Allocate a root chunk and commit a part of it. Then repeatedly split
// it and merge it back together; observe the committed regions of the split chunks.

Metachunk* c = alloc_root_chunk();
Expand Down Expand Up @@ -562,15 +562,10 @@ TEST_VM(metaspace, virtual_space_node_test_2) {
}

TEST_VM(metaspace, virtual_space_node_test_3) {
double d = os::elapsedTime();
// Test committing uncommitting arbitrary ranges
for (int run = 0; run < 100; run++) {
VirtualSpaceNodeTest test(metaspace::chunklevel::MAX_CHUNK_WORD_SIZE,
metaspace::chunklevel::MAX_CHUNK_WORD_SIZE);
test.test_split_and_merge_chunks();
}
double d2 = os::elapsedTime();
LOG("%f", (d2-d));
VirtualSpaceNodeTest test(metaspace::chunklevel::MAX_CHUNK_WORD_SIZE,
metaspace::chunklevel::MAX_CHUNK_WORD_SIZE);
test.test_split_and_merge_chunks();
}

TEST_VM(metaspace, virtual_space_node_test_4) {
Expand Down
Expand Up @@ -54,7 +54,24 @@
* @run main/othervm/timeout=400
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:VerifyMetaspaceInterval=10
* TestMetaspaceAllocationMT1
* TestMetaspaceAllocationMT1 3
*/

/*
* @test id=debug-default-strict
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @build jdk.test.whitebox.WhiteBox
* @key randomness
* @requires (vm.debug == true)
*
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
*
* @run main/othervm/manual
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:VerifyMetaspaceInterval=10
* TestMetaspaceAllocationMT1 10
*/

/*
Expand All @@ -72,7 +89,7 @@
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:VerifyMetaspaceInterval=10
* -XX:+MetaspaceGuardAllocations
* TestMetaspaceAllocationMT1
* TestMetaspaceAllocationMT1 3
*/

/*
Expand All @@ -88,7 +105,7 @@
*
* @run main/othervm/timeout=400
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* TestMetaspaceAllocationMT1
* TestMetaspaceAllocationMT1 3
*/

public class TestMetaspaceAllocationMT1 {
Expand All @@ -97,7 +114,7 @@ public static void main(String[] args) throws Exception {

final long testAllocationCeiling = 1024 * 1024 * 8; // 8m words = 64M on 64bit
final int numThreads = 4;
final int seconds = 10;
final int seconds = Integer.parseInt(args[0]);

for (int i = 0; i < 3; i ++) {

Expand Down
Expand Up @@ -54,7 +54,24 @@
* @run main/othervm/timeout=400
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:VerifyMetaspaceInterval=10
* TestMetaspaceAllocationMT2
* TestMetaspaceAllocationMT2 3
*/

/*
* @test id=debug-default-strict
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @build jdk.test.whitebox.WhiteBox
* @key randomness
* @requires (vm.debug == true)
*
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
*
* @run main/othervm/manual
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:VerifyMetaspaceInterval=10
* TestMetaspaceAllocationMT2 10
*/

/*
Expand All @@ -72,7 +89,7 @@
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:VerifyMetaspaceInterval=10
* -XX:+MetaspaceGuardAllocations
* TestMetaspaceAllocationMT2
* TestMetaspaceAllocationMT2 3
*/

/*
Expand All @@ -88,7 +105,7 @@
*
* @run main/othervm/timeout=400
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* TestMetaspaceAllocationMT2
* TestMetaspaceAllocationMT2 3
*/

public class TestMetaspaceAllocationMT2 {
Expand All @@ -97,7 +114,7 @@ public static void main(String[] args) throws Exception {

final long testAllocationCeiling = 1024 * 1024 * 6; // 8m words = 64M on 64bit
final int numThreads = 4;
final int seconds = 10;
final int seconds = Integer.parseInt(args[0]);

for (int i = 0; i < 3; i ++) {

Expand Down

3 comments on commit de0e46c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tstuefe
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u

@openjdk
Copy link

@openjdk openjdk bot commented on de0e46c Aug 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tstuefe the backport was successfully created on the branch tstuefe-backport-de0e46c2 in my personal fork of openjdk/jdk21u. To create a pull request with this backport targeting openjdk/jdk21u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit de0e46c2 from the openjdk/jdk repository.

The commit being backported was authored by Thomas Stuefe on 24 Aug 2023 and was reviewed by Stefan Karlsson and David Holmes.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u:

$ git fetch https://github.com/openjdk-bots/jdk21u.git tstuefe-backport-de0e46c2:tstuefe-backport-de0e46c2
$ git checkout tstuefe-backport-de0e46c2
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u.git tstuefe-backport-de0e46c2

Please sign in to comment.