[prev in list] [next in list] [prev in thread] [next in thread]
List: openjdk-hotspot-compiler-dev
Subject: Re: RFR: 8276162: Optimise unsigned comparison pattern
From: Mai =?UTF-8?B?xJDhurduZw==?= =?UTF-8?B?IA==?= =?UTF-8?B?UXXDom4=?= Anh <duke () ope
Date: 2021-10-29 9:48:34
Message-ID: 8mMToQfY2jwnP4ASypeTpEGcS_RK4c0tQnkUe4uy9dc=.febcbe8f-109b-460b-97b7-0c7f8df8f078 () github ! com
[Download RAW message or body]
On Mon, 25 Oct 2021 10:15:42 GMT, Mai Đặng Quân Anh <duke@openjdk.java.net> \
wrote:
> This patch changes operations in the form `x +- Integer.MIN_VALUE <=> y +- \
> Integer.MIN_VALUE`, which is a pattern used to do unsigned comparisons, into `x \
> u<=> y`.
> In addition to being basic operations, they may be utilised to implement range \
> checks such as the methods in `jdk.internal.util.Preconditions`, or in places where \
> the compiler cannot deduce the non-negativeness of the bound as in \
> `java.util.ArrayList`.
> Thank you very much.
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 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.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6101
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic