RFR: 8276162: Optimise unsigned comparison pattern
Jie Fu
jiefu at openjdk.java.net
Fri Oct 29 09:48:34 UTC 2021
On Fri, 29 Oct 2021 07:23:56 GMT, Mai Đặng Quân Anh <duke at openjdk.java.net> wrote:
> I created a simple benchmark, the benchmark is run on Intel i7-7700HQ, the result is as follow:
>
> ```
> Before:
> Benchmark Mode Cnt Score Error Units
> App.runInt avgt 25 3.963 ± 0.181 ns/op
> App.runLong avgt 25 4.431 ± 0.101 ns/op
>
> After:
> Benchmark Mode Cnt Score Error Units
> App.runInt avgt 25 3.678 ± 0.192 ns/op
> App.runLong avgt 25 3.814 ± 0.085 ns/op
> ```
>
> This is the source code of the benchmark:
>
> ```
> package io.github.merykitty.simplebenchmark;
>
> import java.io.IOException;
> import java.util.concurrent.TimeUnit;
>
> import org.openjdk.jmh.annotations.*;
> import org.openjdk.jmh.infra.Blackhole;
>
> @BenchmarkMode(Mode.AverageTime)
> @State(Scope.Benchmark)
> @OutputTimeUnit(TimeUnit.NANOSECONDS)
> @Warmup(iterations = 5)
> @Measurement(iterations = 5)
> public class App {
> @CompilerControl(CompilerControl.Mode.DONT_INLINE)
> public long test(int arg0, int arg1) {
> return arg0 + Integer.MIN_VALUE < arg1 + Integer.MIN_VALUE ? 1 : 0;
> }
>
> @CompilerControl(CompilerControl.Mode.DONT_INLINE)
> public long test(long arg0, long arg1) {
> return arg0 + Long.MIN_VALUE < arg1 + Long.MIN_VALUE ? 1 : 0;
> }
>
> @Benchmark
> public void runInt() {
> test(0, -1);
> test(-1, 0);
> }
>
> @Benchmark
> public void runLong() {
> test(0L, -1L);
> test(-1L, 0L);
> }
>
> public static void main( String[] args ) throws IOException {
> org.openjdk.jmh.Main.main(args);
> }
> }
> ```
>
> Do I need to add the benchmark to the patch? If yes then where should I put it in?
>
> Thank you very much.
I think you can put it under `test/micro/org/openjdk/bench/vm/compiler` with a more meaningful class name.
Please note that the jcheck failed in your PR, which seems to prevent the RFR email from sending out.
> I have just pushed the microbenchmark, I am not sure what to put in the copyright line, though.
>
> The check failure seems to be due to this PR does not refer to an existing issue.
>
> Thank you very much.
Filed https://bugs.openjdk.java.net/browse/JDK-8276162 for you.
Thanks.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6101
More information about the hotspot-compiler-dev
mailing list