8275821: Optimize random number generators developed in JDK-8248862 using Math.unsignedMultiplyHigh()#6206
8275821: Optimize random number generators developed in JDK-8248862 using Math.unsignedMultiplyHigh()#6206vamsi-parasa wants to merge 8 commits intoopenjdk:masterfrom
Conversation
…sing Math.unsignedMultiplyHigh()
|
/covered |
|
👋 Welcome back vamsi-parasa! A progress list of the required criteria for merging this PR into |
|
You are already a known contributor! |
|
@vamsi-parasa The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
|
The following speedups were observed for the JMH benchmarks. L128X128MixRandom shows 8% improvement, L128x256MixRandom shows 6% improvement and L128X1024MixRandom shows 14% improvement. (Another micro workload shows 10% improvement for both L128X128MixRandom and L128x256MixRandom while L128X1024MixRandom shows 25% improvement in performance.) |
|
@JimLaskey Could you please review this PR which optimizes three of the Pseudo-Random Number Generators you implemented in https://bugs.openjdk.java.net/browse/JDK-8248862 ? |
|
@PaulSandoz Could you please also review this small PR. |
PaulSandoz
left a comment
There was a problem hiding this comment.
Looks good. Some comments on the benchmark.
| rngL128X128MixRandom = RandomGeneratorFactory.of("L128X128MixRandom").create(42); | ||
| rngL128X256MixRandom = RandomGeneratorFactory.of("L128X256MixRandom").create(174); | ||
| rngL128X1024MixRandom = RandomGeneratorFactory.of("L128X1024MixRandom").create(308); |
There was a problem hiding this comment.
You can declare parameters:
@Param({"L128X128MixRandom", "L128X256MixRandom", "L128X1024MixRandom"})
String randomGeneratorName;
@Param("1024")
int size;
long[] buffer;
RandomGenerator randomGenerator;
@Setup
public void setup() {
buffer = new long[size];
randomGenerator = RandomGeneratorFactory.of(randomGeneratorName)
.create(randomGeneratorName.hashCode());
}Then you can simplify to just two benchmark methods. Further, the benchmark can be used for other PRNGs.
There was a problem hiding this comment.
Thank you Paul! Will make the necessary changes and update the benchmark...
There was a problem hiding this comment.
@PaulSandoz Implemented the changes you suggested for the benchmark. Tested it on my side and ensured that it's working as expected...
PaulSandoz
left a comment
There was a problem hiding this comment.
Very nice, much neater, just a few more minor comments.
| @State(Scope.Thread) | ||
| public class RandomGeneratorNext { | ||
|
|
||
| public RandomGenerator randomGenerator; |
There was a problem hiding this comment.
| public RandomGenerator randomGenerator; | |
| RandomGenerator randomGenerator; |
There was a problem hiding this comment.
Incorporated your suggestion in the recent commit...
| @Param({"L128X128MixRandom", "L128X256MixRandom", "L128X1024MixRandom"}) | ||
| String randomGeneratorName; | ||
|
|
||
| public static long[] buffer; |
There was a problem hiding this comment.
| public static long[] buffer; | |
| long[] buffer; |
There was a problem hiding this comment.
Incorporated your suggestion in the recent commit...
|
|
||
| @Benchmark | ||
| @Fork(1) | ||
| public void testFillBufferWithNextLong() { |
There was a problem hiding this comment.
Return buffer after the loop completes, just in case the JIT decides it is otherwise dead code
There was a problem hiding this comment.
Added the code to return buffer at the end of the loop...
| } | ||
|
|
||
| @Benchmark | ||
| @Fork(1) |
|
|
@vamsi-parasa This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 458 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@PaulSandoz, @JimLaskey) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
@vamsi-parasa you can now integrate this and then I or someone else will sponsor it |
|
/integrate |
|
@vamsi-parasa |
|
Thank you @PaulSandoz and @JimLaskey for reviewing the PR! |
|
/sponsor |
|
Going to push as commit 38f525e.
Your commit was automatically rebased without conflicts. |
|
@sviswa7 @vamsi-parasa Pushed as commit 38f525e. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This change optimizes random number generators using Math.unsignedMultiplyHigh()
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6206/head:pull/6206$ git checkout pull/6206Update a local copy of the PR:
$ git checkout pull/6206$ git pull https://git.openjdk.java.net/jdk pull/6206/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 6206View PR using the GUI difftool:
$ git pr show -t 6206Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6206.diff