Applied the fixes as suggested in the issue. I applied the fix in #30900 on top
of the fix in this PR to observe the differences.
Before the fix, one would see:
$ TEST="micro:org.openjdk.bench.java.lang.MinMaxVector.longReductionSimpleMax"
MICRO="FORK=1;OPTIONS=-p probability=100 -jvmArgsAppend -XX:-UseSuperWord
-jvmArgsAppend -XX:+PrintMethodData" make test
...
------------------------------------------------------------------------
static java.lang.Math::max(JJ)J
interpreter_invocation_count: 488657
invocation_counter: 488657
backedge_counter: 0
decompile_count: 0
mdo size: 328 bytes
0 lload_0
1 lload_2
2 lcmp
3 iflt 10
0 bci: 3 BranchData taken(447750) displacement(56)
not taken(40372)
6 lload_0
7 goto 11
32 bci: 7 JumpData taken(40372) displacement(24)
10 lload_2
11 lreturn
We see that branch taken is ~90% instead of the desired 100%. Also, the high
branch taken is the opposite of what the `probability` java doc states.
After the fix we see:
$ TEST="micro:org.openjdk.bench.java.lang.MinMaxVector.longReductionSimpleMax"
MICRO="FORK=1;OPTIONS=-p probability=100 -jvmArgsAppend -XX:-UseSuperWord
-jvmArgsAppend -XX:+PrintMethodData" make test
...
static java.lang.Math::max(JJ)J
interpreter_invocation_count: 551119
invocation_counter: 551119
backedge_counter: 0
decompile_count: 0
mdo size: 328 bytes
0 lload_0
1 lload_2
2 lcmp
3 iflt 10
0 bci: 3 BranchData taken(1721) displacement(56)
not taken(548864)
6 lload_0
7 goto 11
32 bci: 7 JumpData taken(548865) displacement(24)
10 lload_2
11 lreturn
With the fix the branch not taken is ~99%, which is almost the 100% we defined
in the probability. Also, the branch not taken aligns with the behavior
specified in the java doc of `probability`.
---------
- [X] I confirm that I make this contribution in accordance with the [OpenJDK
Interim AI Policy](https://openjdk.org/legal/ai).
-------------
Commit messages:
- Adjusted the probability javadoc
- Avoid min/max equals values and reverse order of parameters
Changes: https://git.openjdk.org/jdk/pull/30912/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=30912&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8382881
Stats: 17 lines in 1 file changed: 1 ins; 0 del; 16 mod
Patch: https://git.openjdk.org/jdk/pull/30912.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/30912/head:pull/30912
PR: https://git.openjdk.org/jdk/pull/30912