JDK-7189139 : BigInteger's staticRandom field can be a source of bottlenecks.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.math
  • Affected Version: 8
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-08-03
  • Updated: 2013-10-25
  • Resolved: 2013-10-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b113Fixed
Related Reports
Relates :  
Description
This is a SUNBUG for https://bugs.openjdk.java.net/show_bug.cgi?id=100218

See also these references:

http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-January/009176.html
http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-January/008880.html

Description

Created an attachment (id=251) [details]
hg diff -g of BigInteger.java

The static field 'staticRandom' in BigInteger can be a source of bottlenecks
for concurrent code. This can be seen by calling isProbablePrime from several
threads running in parallel and noting that there is no appreciable speedup
over running linearly. 

The proposed fix is change the static volatile staticRandom field to a
ThreadLocal. This will allow each thread to hold their own copy of staticRandom
and not have to wait for other threads when trying to access it.

Comments
I will be adding to the discussion in the core libraries mailing list in a few minutes. Bill Pugh's original suggestion about adding a new method should be considered.
03-09-2013