Withdrawn: CODETOOLS-7903484: JMH: Use ThreadMXBean.getTotalThreadAllocatedBytes for -prof gc
Aleksey Shipilev
shade at openjdk.org
Tue Jun 6 13:56:21 UTC 2023
On Thu, 1 Jun 2023 10:30:42 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> JDK 21 comes with a new method that gives the total allocated rate for all the threads, [JDK-8304074](https://bugs.openjdk.org/browse/JDK-8304074). JMH -prof gc can use it, when available. This allows catching the totality of the thread allocations, regardless whether the threads went in or out during the lifetime of the benchmark. Current `-prof gc` is missing those threads most of the time.
>
> Example benchmark:
>
>
> @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
> @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
> @Fork(value = 1, jvmArgsAppend = {"-Xmx1g", "-Xms1g", "-XX:+AlwaysPreTouch", "-XX:+UseParallelGC"})
> @BenchmarkMode(Mode.Throughput)
> @OutputTimeUnit(TimeUnit.SECONDS)
> @State(Scope.Thread)
> public class TAB {
>
> @Benchmark
> public void inline(Blackhole bh) throws InterruptedException {
> bh.consume(new byte[1_000_000]);
> }
>
> @Benchmark
> public void separate(Blackhole bh) throws InterruptedException {
> Thread thread = new Thread(() -> { bh.consume(new byte[1_000_000]); });
> thread.start();
> thread.join();
> }
> }
>
>
> Current JDK 20:
>
>
> Benchmark Mode Cnt Score Error Units
>
> TAB.inline thrpt 5 100632,205 ± 1237,322 ops/s
> TAB.inline:·gc.alloc.rate thrpt 5 95961,825 ± 1181,577 MB/sec
> TAB.inline:·gc.alloc.rate.norm thrpt 5 1000016,004 ± 0,001 B/op
> TAB.inline:·gc.count thrpt 5 1432,000 counts
> TAB.inline:·gc.time thrpt 5 207,000 ms
>
> TAB.separate thrpt 5 18169,567 ± 374,656 ops/s
> TAB.separate:·gc.alloc.rate thrpt 5 5,822 ± 0,120 MB/sec ; <--- missing allocations
> TAB.separate:·gc.alloc.rate.norm thrpt 5 336,024 ± 0,010 B/op ; <--- missing allocations
> TAB.separate:·gc.count thrpt 5 2023,000 counts
> TAB.separate:·gc.time thrpt 5 229,000 ms
>
>
> Self-built JDK 21-ea:
>
>
> Benchmark Mode Cnt Score Error Units
>
> TAB.inline thrpt 5 103061,266 ± 2086,154 ops/s
> TAB.inline:·gc.alloc.rate thrpt 5 98277,065 ± 1988,502 MB/sec
> TAB.inline:·gc.alloc.rate.norm thrpt 5 1000016,056 ± 0,001 B/op
> TAB.inline:·gc.count thrpt 5 1466,000 counts
> TAB...
This pull request has been closed without being integrated.
-------------
PR: https://git.openjdk.org/jmh/pull/106
More information about the jmh-dev
mailing list