RFR: 8325403: Add SystemGC JMH benchmarks [v3]

Andrey Turbanov aturbanov at openjdk.org
Wed Feb 14 09:09:58 UTC 2024


On Tue, 13 Feb 2024 14:12:06 GMT, Stefan Johansson <sjohanss at openjdk.org> wrote:

>> Please review this change to add some System GC JMH benchmarks.
>> 
>> **Summary**
>> When developing and improving the Full GC implementation for the different GCs, using `System.gc()` to test performance is sometime very useful. This change adds a set of System GC benchmarks using JMH. The tests all have the same structure, a `@Setup` function that generates heap contents and a `@Benchmark` function which only calls `System.gc()`. The different scenarios covers some basic use-cases but more can certainly be added going forward. 
>> 
>> Since the benchmark function is just a single call to trigger the GC it makes sense to use the single shot JMH mode and fork a new JVM for each run. The tests also specify default heap options to avoid triggering GC during object creation to give all runs more or less the same heap layout.
>> 
>> **Testing**
>> Local and aurora testing verifying that results are fairly stable.
>
> Stefan Johansson has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Add AlwaysPreTouch to jvmArgsAppend

test/micro/org/openjdk/bench/vm/gc/system_gc/GarbageGenerator.java line 40:

> 38:      */
> 39:     static ArrayList<Object[]> generateObjectArrays() {
> 40:         ArrayList<Object[]>  tmp = new ArrayList<>();

Suggestion:

        ArrayList<Object[]> tmp = new ArrayList<>();

test/micro/org/openjdk/bench/vm/gc/system_gc/GarbageGenerator.java line 63:

> 61:         // the average size is ~ 4k.
> 62:         Object[] tmp = new Object[sameSize ? M : M / 4];
> 63:         for(int i = 0 ; i < tmp.length; i++) {

Suggestion:

        for (int i = 0; i < tmp.length; i++) {

test/micro/org/openjdk/bench/vm/gc/system_gc/GarbageGenerator.java line 77:

> 75:         HashMap<Integer, byte[]> tmp = new HashMap<>();
> 76:         int numberOfObjects = sameSize ? M : M / 4;
> 77:         for(int i = 0 ; i < numberOfObjects; i++) {

Suggestion:

        for (int i = 0; i < numberOfObjects; i++) {

test/micro/org/openjdk/bench/vm/gc/system_gc/GarbageGenerator.java line 91:

> 89:         TreeMap<Integer, byte[]> tmp = new TreeMap<>();
> 90:         int numberOfObjects = sameSize ? M : M / 4;
> 91:         for(int i = 0 ; i < numberOfObjects; i++) {

Suggestion:

        for (int i = 0; i < numberOfObjects; i++) {

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17784#discussion_r1489136069
PR Review Comment: https://git.openjdk.org/jdk/pull/17784#discussion_r1489136330
PR Review Comment: https://git.openjdk.org/jdk/pull/17784#discussion_r1489136617
PR Review Comment: https://git.openjdk.org/jdk/pull/17784#discussion_r1489136858


More information about the hotspot-gc-dev mailing list