RFR: 8296746: NativePRNG SecureRandom doesn't scale with threads
Xubo Zhang
duke at openjdk.org
Thu Nov 10 01:26:54 UTC 2022
NativePRNG SecureRandom doesn’t scale with number of threads. The performance starts dropping as we increase the number of threads. Even going from 1 thread to 2 threads shows significant drop. The bottleneck is the singleton RandomIO instance. Making the RandomIO ThreadLocal helps in removing this bottleneck.
Here are the jmh thrpt ops/s data for SecureRandomBench.nextBytes, algorithm=NativePRNGNonBlocking, datasize=64, notshared:
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 15">
<link id=Main-File rel=Main-File
href="file:///C:/Users/xbzhang/AppData/Local/Temp/msohtmlclip1/01/clip.htm">
<link rel=File-List
href="file:///C:/Users/xbzhang/AppData/Local/Temp/msohtmlclip1/01/clip_filelist.xml">
</head>
<body link="#0563C1" vlink="#954F72">
#threads | singleton RandomIO | ThreadLocal RandomIO
-- | -- | --
1 | 1269133 | 1279088
2 | 862923 | 1362066
3 | 819734 | 1630522
4 | 809128 | 1614500
5 | 821514 | 1594965
6 | 808795 | 1545045
7 | 783050 | 1499388
8 | 787236 | 1470004
</body>
</html>
-------------
Commit messages:
- cleanup
- removed print statements
- Initial change with Sandhya's patch
Changes: https://git.openjdk.org/jdk/pull/11069/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=11069&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8296746
Stats: 30 lines in 1 file changed: 3 ins; 0 del; 27 mod
Patch: https://git.openjdk.org/jdk/pull/11069.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/11069/head:pull/11069
PR: https://git.openjdk.org/jdk/pull/11069
More information about the security-dev
mailing list