8252329: runtime/LoadClass/TestResize.java timed out
Reviewed-by: hseigel, iklam
This commit is contained in:
parent
3e60e82814
commit
f93beacd2f
src/hotspot/share/classfile
test/hotspot/jtreg/runtime/LoadClass
@ -992,14 +992,23 @@ void ClassLoaderData::print_on(outputStream* out) const {
|
|||||||
}
|
}
|
||||||
out->print_cr(" - handles %d", _handles.count());
|
out->print_cr(" - handles %d", _handles.count());
|
||||||
out->print_cr(" - dependency count %d", _dependency_count);
|
out->print_cr(" - dependency count %d", _dependency_count);
|
||||||
out->print (" - klasses {");
|
out->print (" - klasses { ");
|
||||||
PrintKlassClosure closure(out);
|
if (Verbose) {
|
||||||
((ClassLoaderData*)this)->classes_do(&closure);
|
PrintKlassClosure closure(out);
|
||||||
|
((ClassLoaderData*)this)->classes_do(&closure);
|
||||||
|
} else {
|
||||||
|
out->print("...");
|
||||||
|
}
|
||||||
out->print_cr(" }");
|
out->print_cr(" }");
|
||||||
out->print_cr(" - packages " INTPTR_FORMAT, p2i(_packages));
|
out->print_cr(" - packages " INTPTR_FORMAT, p2i(_packages));
|
||||||
out->print_cr(" - module " INTPTR_FORMAT, p2i(_modules));
|
out->print_cr(" - module " INTPTR_FORMAT, p2i(_modules));
|
||||||
out->print_cr(" - unnamed module " INTPTR_FORMAT, p2i(_unnamed_module));
|
out->print_cr(" - unnamed module " INTPTR_FORMAT, p2i(_unnamed_module));
|
||||||
out->print_cr(" - dictionary " INTPTR_FORMAT, p2i(_dictionary));
|
if (_dictionary != nullptr) {
|
||||||
|
out->print (" - dictionary " INTPTR_FORMAT " ", p2i(_dictionary));
|
||||||
|
_dictionary->print_size(out);
|
||||||
|
} else {
|
||||||
|
out->print_cr(" - dictionary " INTPTR_FORMAT, p2i(_dictionary));
|
||||||
|
}
|
||||||
if (_jmethod_ids != NULL) {
|
if (_jmethod_ids != NULL) {
|
||||||
out->print (" - jmethod count ");
|
out->print (" - jmethod count ");
|
||||||
Method::print_jmethod_ids_count(this, out);
|
Method::print_jmethod_ids_count(this, out);
|
||||||
|
@ -586,13 +586,17 @@ void DictionaryEntry::print_count(outputStream *st) {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void Dictionary::print_size(outputStream* st) const {
|
||||||
|
st->print_cr("Java dictionary (table_size=%d, classes=%d, resizable=%s)",
|
||||||
|
table_size(), number_of_entries(), BOOL_TO_STR(_resizable));
|
||||||
|
}
|
||||||
|
|
||||||
void Dictionary::print_on(outputStream* st) const {
|
void Dictionary::print_on(outputStream* st) const {
|
||||||
ResourceMark rm;
|
ResourceMark rm;
|
||||||
|
|
||||||
assert(loader_data() != NULL, "loader data should not be null");
|
assert(loader_data() != NULL, "loader data should not be null");
|
||||||
assert(!loader_data()->has_class_mirror_holder(), "cld should have a ClassLoader holder not a Class holder");
|
assert(!loader_data()->has_class_mirror_holder(), "cld should have a ClassLoader holder not a Class holder");
|
||||||
st->print_cr("Java dictionary (table_size=%d, classes=%d, resizable=%s)",
|
print_size(st);
|
||||||
table_size(), number_of_entries(), BOOL_TO_STR(_resizable));
|
|
||||||
st->print_cr("^ indicates that initiating loader is different from defining loader");
|
st->print_cr("^ indicates that initiating loader is different from defining loader");
|
||||||
|
|
||||||
for (int index = 0; index < table_size(); index++) {
|
for (int index = 0; index < table_size(); index++) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -79,6 +79,7 @@ public:
|
|||||||
TRAPS);
|
TRAPS);
|
||||||
|
|
||||||
void print_on(outputStream* st) const;
|
void print_on(outputStream* st) const;
|
||||||
|
void print_size(outputStream* st) const;
|
||||||
void verify();
|
void verify();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -46,6 +46,7 @@ import java.util.Scanner;
|
|||||||
public class TestResize {
|
public class TestResize {
|
||||||
|
|
||||||
static double MAX_LOAD_FACTOR = 5.0; // see _resize_load_trigger in dictionary.cpp
|
static double MAX_LOAD_FACTOR = 5.0; // see _resize_load_trigger in dictionary.cpp
|
||||||
|
static int CLASSES_TO_LOAD = 30000;
|
||||||
|
|
||||||
static int getInt(String string) {
|
static int getInt(String string) {
|
||||||
int start = 0;
|
int start = 0;
|
||||||
@ -73,6 +74,7 @@ public class TestResize {
|
|||||||
analyzer.shouldHaveExitValue(0);
|
analyzer.shouldHaveExitValue(0);
|
||||||
|
|
||||||
boolean resized = false;
|
boolean resized = false;
|
||||||
|
boolean checked_load_factor = false;
|
||||||
|
|
||||||
// Split string into lines using platform independent end of line marker.
|
// Split string into lines using platform independent end of line marker.
|
||||||
String[] lines = output.split("\\R");
|
String[] lines = output.split("\\R");
|
||||||
@ -82,45 +84,57 @@ public class TestResize {
|
|||||||
if (line.contains("resizing system dictionaries")) {
|
if (line.contains("resizing system dictionaries")) {
|
||||||
resized = true;
|
resized = true;
|
||||||
}
|
}
|
||||||
} else if (resized && line.startsWith("Java dictionary (")) {
|
} else if (resized) {
|
||||||
// ex. Java dictionary (table_size=10103, classes=5002)
|
int index = -1;
|
||||||
Scanner scanner = new Scanner(line);
|
if ((index = line.indexOf("Java dictionary (")) != -1) {
|
||||||
scanner.next(); // skip "Java"
|
// ex. Java dictionary (table_size=10103, classes=5002)
|
||||||
scanner.next(); // skip "dictionary"
|
String dict = line.substring(index);
|
||||||
int table_size = getInt(scanner.next()); // process "(table_size=40423"
|
Scanner scanner = new Scanner(dict);
|
||||||
int classes = getInt(scanner.next()); // process ", classes=50002"
|
scanner.next(); // skip "Java"
|
||||||
scanner.close();
|
scanner.next(); // skip "dictionary"
|
||||||
|
int table_size = getInt(scanner.next()); // process "(table_size=40423"
|
||||||
|
int classes = getInt(scanner.next()); // process ", classes=50002"
|
||||||
|
scanner.close();
|
||||||
|
|
||||||
double loadFactor = (double)classes / (double)table_size;
|
checked_load_factor = classes >= CLASSES_TO_LOAD;
|
||||||
if (loadFactor > MAX_LOAD_FACTOR) {
|
|
||||||
|
|
||||||
// We've hit an error, so print all of the output.
|
double loadFactor = (double)classes / (double)table_size;
|
||||||
System.out.println(output);
|
if (loadFactor > MAX_LOAD_FACTOR) {
|
||||||
|
|
||||||
throw new RuntimeException("Load factor too high, expected MAX " + MAX_LOAD_FACTOR +
|
// We've hit an error, so print all of the output.
|
||||||
", got " + loadFactor + " [table size " + table_size + ", number of clases " + classes + "]");
|
System.out.println(output);
|
||||||
} else {
|
|
||||||
System.out.println("PASS table_size: " + table_size + ", classes: " + classes +
|
throw new RuntimeException("Load factor too high, expected MAX " + MAX_LOAD_FACTOR +
|
||||||
", load factor: " + loadFactor + " <= " + MAX_LOAD_FACTOR);
|
", got " + loadFactor + " [table size " + table_size + ", number of clases " + classes + "]");
|
||||||
// There are more than one system dictionary to check, so keep looking...
|
} else {
|
||||||
|
checked_load_factor = true;
|
||||||
|
System.out.println("PASS table_size: " + table_size + ", classes: " + classes +
|
||||||
|
", load factor: " + loadFactor + " <= " + MAX_LOAD_FACTOR);
|
||||||
|
// There are more than one system dictionary to check, so keep looking...
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resized) {
|
if (!resized) {
|
||||||
System.out.println("PASS trivially. No resizing occurred, so did not check the load.");
|
System.out.println("PASS trivially. No resizing occurred, so did not check the load.");
|
||||||
|
} else {
|
||||||
|
// Make sure the load factor was checked
|
||||||
|
if (!checked_load_factor) {
|
||||||
|
throw new RuntimeException("Test didn't check load factor");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
// -XX:+PrintSystemDictionaryAtExit will print the details of system dictionary,
|
// -XX:+PrintClassLoaderDataGraphAtExit will print the summary of the dictionaries,
|
||||||
// that will allow us to calculate the table's load factor.
|
// that will allow us to calculate the table's load factor.
|
||||||
// -Xlog:safepoint+cleanup will print out cleanup details at safepoint
|
// -Xlog:safepoint+cleanup will print out cleanup details at safepoint
|
||||||
// that will allow us to detect if the system dictionary resized.
|
// that will allow us to detect if the system dictionary resized.
|
||||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintSystemDictionaryAtExit",
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintClassLoaderDataGraphAtExit",
|
||||||
"-Xlog:safepoint+cleanup",
|
"-Xlog:safepoint+cleanup",
|
||||||
"TriggerResize",
|
"TriggerResize",
|
||||||
"50000");
|
String.valueOf(CLASSES_TO_LOAD));
|
||||||
analyzeOutputOn(pb);
|
analyzeOutputOn(pb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user