Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK-8275608: runtime/Metaspace/elastic/TestMetaspaceAllocationMT2 too slow #6041

Closed
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -25,8 +25,6 @@

import sun.hotspot.WhiteBox;

import java.util.concurrent.atomic.AtomicLong;

public class MetaspaceTestArena {

long arena;
@@ -38,7 +36,7 @@ public class MetaspaceTestArena {
long numAllocated = 0;
long deallocatedWords = 0;
long numDeallocated = 0;
long numAllocationFailures = 0;
volatile long numAllocationFailures = 0;

private synchronized boolean reachedCeiling() {
return (allocatedWords - deallocatedWords) > allocationCeiling;
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020 SAP SE. All rights reserved.
* Copyright (c) 2021 SAP SE. All rights reserved.
* Copyright (c) 2021, 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
@@ -63,7 +63,7 @@ public void runTest() throws Exception {
Thread.sleep(200);

for (RandomAllocatorThread t: threads) {
if (t.allocator.arena.numAllocationFailures > 0) {
if (t.allocator.arena.numAllocationFailures > 1000) {
tstuefe marked this conversation as resolved.
Show resolved Hide resolved
t.interrupt();
t.join();
context.destroyArena(t.allocator.arena);
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020 SAP SE. All rights reserved.
* Copyright (c) 2021 SAP SE. All rights reserved.
* Copyright (c) 2021, 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
@@ -23,8 +23,6 @@
*
*/

import java.util.Set;

public class MetaspaceTestWithThreads {

// The context to use.
@@ -53,6 +51,8 @@ protected void stopAllThreads() throws InterruptedException {
// Stop all threads.
for (Thread t: threads) {
t.interrupt();
}
for (Thread t: threads) {
t.join();
}
}
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020 SAP SE. All rights reserved.
* Copyright (c) 2021 SAP SE. All rights reserved.
* Copyright (c) 2021, 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
@@ -46,7 +46,11 @@ public class RandomAllocator {
ArrayList<Allocation> to_dealloc = new ArrayList<>();

long ticks = 0;
boolean allocationError = false;

// Allocate (breathe in) until arena is full, then - to test the arena deallocator - deallocate some allocations
// and breathe in again until full.
boolean breatheIn = true;
int breatheOutTicks = 0;

Random localRandom;

@@ -57,15 +61,16 @@ private boolean rollDice(double probability) {

// Allocate a random amount from the arena. If dice hits right, add this to the deallocation list.
void allocateRandomly() {
allocationError = false;
long word_size = profile.randomAllocationSize();
Allocation a = arena.allocate(word_size);
if (a != null) {
if (to_dealloc.size() < 10000) {
to_dealloc.add(a);
}
} else {
allocationError = true;
// On allocation error, breathe out a bit
breatheIn = false;
breatheOutTicks = 0;
}
}

@@ -80,19 +85,20 @@ void deallocateRandomly() {
}

public void tick() {

if (!allocationError) {
if (breatheIn) {
// allocate until we hit the ceiling
allocateRandomly();
if(rollDice(profile.randomDeallocProbability)) {
if (rollDice(profile.randomDeallocProbability)) {
deallocateRandomly();
}
} else {
deallocateRandomly();
allocationError = false;
if (++breatheOutTicks < 100) {
deallocateRandomly();
} else {
breatheIn = true;
}
}

ticks ++;

}

public RandomAllocator(MetaspaceTestArena arena) {
@@ -102,6 +108,10 @@ public RandomAllocator(MetaspaceTestArena arena) {
this.localRandom = new Random(RandomHelper.random().nextInt());
}

long numAllocationFailures() {
return arena.numAllocationFailures;
}

@Override
public String toString() {
return arena.toString() + ", ticks=" + ticks;
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020 SAP SE. All rights reserved.
* Copyright (c) 2021 SAP SE. All rights reserved.
* Copyright (c) 2021, 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
@@ -23,7 +23,6 @@
*
*/

import java.util.Random;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

@@ -55,9 +54,7 @@ public void run() {
}

while (!Thread.interrupted()) {
for (int i = 0; i < 1000; i++) {
allocator.tick();
}
allocator.tick();
}

// System.out.println("+ [" + id + "] " + allocator);
@@ -41,7 +41,7 @@
*/

/*
* @test id=debug-default
* @test id=debugdefault
Copy link
Contributor

@shipilev shipilev Oct 29, 2021

Choose a reason for hiding this comment

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

Why these changes?

Copy link
Contributor

@shipilev shipilev Oct 29, 2021

Choose a reason for hiding this comment

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

Nevermind, got my reply.

Copy link
Member Author

@tstuefe tstuefe Oct 29, 2021

Choose a reason for hiding this comment

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

As I wrote, I changed the test names, because I want to be able to call them individually with '#bla' and that does not work if the subtest name contains non-alphanumerics. I can do it in a separate RFE if you prefer.

Copy link
Contributor

@shipilev shipilev Oct 29, 2021

Choose a reason for hiding this comment

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

Yes, I don't mind doing it here.

Copy link
Member Author

@tstuefe tstuefe Oct 29, 2021

Choose a reason for hiding this comment

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

I removed the renaming from this patch, its maybe cleaner to do it separately. Or, idk, maybe fix jtreg itself.

Copy link
Contributor

@shipilev shipilev Oct 29, 2021

Choose a reason for hiding this comment

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

Fixing jteg would be nice. There are plenty of tests with these dashed IDs, IIRC.

Copy link
Member Author

@tstuefe tstuefe Oct 29, 2021

Choose a reason for hiding this comment

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

Copy link
Member Author

@tstuefe tstuefe Oct 29, 2021

Choose a reason for hiding this comment

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

Not a committer to code-tools though. I'll need a sponsor.

* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
@@ -58,7 +58,7 @@
*/

/*
* @test id=debug-none
* @test id=debugnone
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
@@ -76,7 +76,7 @@
*/

/*
* @test id=debug-aggressive
* @test id=debugaggressive
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
@@ -94,7 +94,7 @@
*/

/*
* @test id=debug-guard
* @test id=debugguard
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
@@ -112,7 +112,7 @@
*/

/*
* @test id=ndebug-default
* @test id=ndebugdefault
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
@@ -128,7 +128,7 @@
*/

/*
* @test id=ndebug-none
* @test id=ndebugnone
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
@@ -145,7 +145,7 @@
*/

/*
* @test id=ndebug-aggressive
* @test id=ndebugaggressive
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management