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 1 commit
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
@@ -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);
@@ -53,6 +53,8 @@ protected void stopAllThreads() throws InterruptedException {
// Stop all threads.
for (Thread t: threads) {
t.interrupt();
}
for (Thread t: threads) {
t.join();
}
}
@@ -46,7 +46,9 @@ public class RandomAllocator {
ArrayList<Allocation> to_dealloc = new ArrayList<>();

long ticks = 0;
boolean allocationError = false;

boolean breatheIn = true;
int breatheTicks = 0;

Random localRandom;

@@ -57,20 +59,23 @@ 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;
breatheTicks ++;
tstuefe marked this conversation as resolved.
Show resolved Hide resolved
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;
breatheTicks = 0;
}
}

// Randomly choose one of the allocated in the deallocation list and deallocate it
void deallocateRandomly() {
breatheTicks ++;
tstuefe marked this conversation as resolved.
Show resolved Hide resolved
if (to_dealloc.size() == 0) {
return;
}
@@ -81,14 +86,19 @@ void deallocateRandomly() {

public void tick() {

if (!allocationError) {
if (breatheIn) {
allocateRandomly();
if(rollDice(profile.randomDeallocProbability)) {
if (rollDice(profile.randomDeallocProbability)) {
deallocateRandomly();
}
} else {
deallocateRandomly();
allocationError = false;
if (breatheTicks > 100) {
// After allocation error, breathe out a bit. Stop after 100 deallocations
// to breathe in again (should cause us to float just below the ceiling).
breatheIn = true;
breatheTicks = 0;
}
}

ticks ++;
@@ -102,6 +112,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;
@@ -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);