On 11/05/2021 17:04, Сергей Цыпанов wrote:
Hello

I've run into performance drop-down when using Class.gerResource().

When I run the following benchmark with JDK 16 downloaded from the internet

@State(Scope.Benchmark)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Fork(jvmArgsAppend = {"-Xms2g", "-Xmx2g"})
public class ClassGetResourceBenchmark {
   private final Class<?> clazz = getClass();

   @Benchmark
   public URL getResource() {
     return 
clazz.getResource("/com/tsypanov/sbb/ClassGetResourceBenchmark.class");
   }
}

getResource() method takes about 2 us and consumes 1704 bytes.

But then I take the code from https://github.com/openjdk/jdk and build it as

~ bash configure --with-boot-jdk=/home/s.tsypanov/.jdks/openjdk-16.0.1 
--with-jtreg=/home/s.tsypanov/jtreg5
~ make images

the same benchmark run on this ad hoc build takes 129 us and consumes 111506 
bytes.


Can you check if you are using an exploded build? In the output directly you need to configure the IDE to use images/jdk for an images-build. Also part of the issue may be an IDE bug where it puts the directories for all the system modules on the class path.

-Alan

Reply via email to