RFR: 8309976: A JMH to create a lot of classes and compiled methods

Aleksey Shipilev shade at openjdk.org
Fri Jun 16 17:31:03 UTC 2023


On Fri, 16 Jun 2023 14:54:46 GMT, Eric Caspole <ecaspole at openjdk.org> wrote:

> Most benchmarks have a relatively small code footprint compared to enterprise applications. While trying to model an application with a very large code footprint, we developed this JMH with its own classloader generating the desired number of classes from the string literal in the file, using the existing InMemoryJavaCompiler. Then these classes are are instantiated to the desired count, and methods are called in those objects, which can fill up the code cache, possibly causing code cache sweeping or compiler shut-off. 
> This allows to create a simulation of a large application with arbitrary java heap and code cache footprint, and take advantage of the benefits of JMH at the same time.
> The defaults are set very low by default and the intent is that they would be customized for any given study.

I think the benchmark code needs massaging for style and other issues.
See e.g. the cursory review:

test/micro/org/openjdk/bench/vm/compiler/CodeCacheStress.java line 2:

> 1: /*
> 2:  * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.

The format looks odd, missing comma?

test/micro/org/openjdk/bench/vm/compiler/CodeCacheStress.java line 76:

> 74:     public int recurse;
> 75: 
> 76:     // How many instances of each generated class to create and call in the measured phase

Suggestion:

    // How many instances of each generated class to create and call in the measurement phase

test/micro/org/openjdk/bench/vm/compiler/CodeCacheStress.java line 87:

> 85:     Map<Object, Method[]> table1 = new HashMap<>();
> 86:     ArrayList<Map<String, Integer>> mapList = new ArrayList<>();
> 87:     Map<Class, Object[]> instList = new HashMap<>();

All these have too generic names, not clear what they hold.

test/micro/org/openjdk/bench/vm/compiler/CodeCacheStress.java line 188:

> 186:                 + " "
> 187:                 + " "
> 188:                 + "   public Integer get( Map m, String k, Integer depth) { "

Suggestion:

                + "   public Integer get(Map m, String k, Integer depth) { "


...and later...

test/micro/org/openjdk/bench/vm/compiler/CodeCacheStress.java line 438:

> 436:                 Integer result = callTheMethod(m, r, k, map);
> 437:                 assert result != null && result >= v;
> 438:                 sum += result;

This performs boxed addition.

-------------

Changes requested by shade (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/14521#pullrequestreview-1483780194
PR Review Comment: https://git.openjdk.org/jdk/pull/14521#discussion_r1232411469
PR Review Comment: https://git.openjdk.org/jdk/pull/14521#discussion_r1232411699
PR Review Comment: https://git.openjdk.org/jdk/pull/14521#discussion_r1232412769
PR Review Comment: https://git.openjdk.org/jdk/pull/14521#discussion_r1232536237
PR Review Comment: https://git.openjdk.org/jdk/pull/14521#discussion_r1232536502


More information about the hotspot-compiler-dev mailing list