8349007: The jtreg test ResolvedMethodTableHash takes excessive time
Reviewed-by: lmesnik, matsaave
This commit is contained in:
parent
5f2a604b63
commit
6352ee1a6e
@ -175,7 +175,13 @@ oop ResolvedMethodTable::find_method(const Method* method) {
|
||||
|
||||
ResolvedMethodTableLookup lookup(thread, method_hash(method), method);
|
||||
ResolvedMethodGet rmg(thread, method);
|
||||
_local_table->get(thread, lookup, rmg);
|
||||
bool rehash_warning = false;
|
||||
_local_table->get(thread, lookup, rmg, &rehash_warning);
|
||||
if (rehash_warning) {
|
||||
// if load factor is low but we need to rehash that's a problem with the hash function.
|
||||
log_info(membername, table)("Rehash warning, load factor %g", get_load_factor());
|
||||
trigger_concurrent_work();
|
||||
}
|
||||
|
||||
return rmg.get_res_oop();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2025, 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
|
||||
@ -25,7 +25,11 @@
|
||||
* @test
|
||||
* @bug 8249719
|
||||
* @summary ResolvedMethodTable hash function should take method class into account
|
||||
* @run main/othervm/manual -Xmx256m -XX:MaxMetaspaceSize=256m ResolvedMethodTableHash 200000
|
||||
* @requires vm.flagless
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
* @run driver ResolvedMethodTableHash
|
||||
*/
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
@ -35,11 +39,15 @@ import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// The test generates thousands MethodHandles to the methods of the same name
|
||||
// and the same signature. This should not take too long, unless Method hash
|
||||
// function takes only the name and the signature as an input.
|
||||
public class ResolvedMethodTableHash extends ClassLoader {
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
// The test generates a thousand MethodHandles to the methods of the same name
|
||||
// and the same signature. The rehash warning shouldn't be returned, unless Method hash
|
||||
// function takes only the name and the signature as an input.
|
||||
public class ResolvedMethodTableHash {
|
||||
|
||||
public static class ResolvedMethodTableHashTest extends ClassLoader {
|
||||
// Generate a MethodHandle for ClassName.m()
|
||||
private MethodHandle generate(String className) throws ReflectiveOperationException {
|
||||
byte[] buf = new byte[100];
|
||||
@ -52,7 +60,7 @@ public class ResolvedMethodTableHash extends ClassLoader {
|
||||
byte[] buf = new byte[100];
|
||||
int size = writeClass(buf, "MH$$");
|
||||
// use different classloader instances to load the classes with the same name
|
||||
Class<?> cls = new ResolvedMethodTableHash().defineClass(null, buf, 0, size);
|
||||
Class<?> cls = new ResolvedMethodTableHashTest().defineClass(null, buf, 0, size);
|
||||
return MethodHandles.publicLookup().findStatic(cls, "m", MethodType.methodType(void.class));
|
||||
}
|
||||
|
||||
@ -84,10 +92,11 @@ public class ResolvedMethodTableHash extends ClassLoader {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ResolvedMethodTableHash generator = new ResolvedMethodTableHash();
|
||||
|
||||
ResolvedMethodTableHashTest generator = new ResolvedMethodTableHashTest();
|
||||
List<MethodHandle> handles = new ArrayList<>();
|
||||
|
||||
int count = args.length > 0 ? Integer.parseInt(args[0]) : 200000;
|
||||
int count = 1001;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
// prevents metaspace oom
|
||||
@ -104,3 +113,15 @@ public class ResolvedMethodTableHash extends ClassLoader {
|
||||
System.out.println("Test passed");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// Running the table with only 1000 entries should not provoke a needs rehash warning, unless the hash code is bad.
|
||||
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:membername+table",
|
||||
ResolvedMethodTableHashTest.class.getName());
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldNotContain("[membername,table] Rehash warning, load factor");
|
||||
output.shouldContain("Generated 1000 handles");
|
||||
output.shouldHaveExitValue(0);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user