RFR 8080623 CPU overhead in FJ due to spinning in awaitWork
Paul Sandoz
paul.sandoz at oracle.com
Wed May 20 09:28:45 UTC 2015
On May 20, 2015, at 9:07 AM, David Holmes <david.holmes at oracle.com> wrote:
> On 20/05/2015 3:55 AM, Paul Sandoz wrote:
>> Hi,
>>
>> https://bugs.openjdk.java.net/browse/JDK-8080623
>>
>> diff -r ea3ca5cfc3c6 src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java
>> --- a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java Tue May 19 20:04:29 2015 +0300
>> +++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java Tue May 19 19:54:00 2015 +0200
>> @@ -1328,13 +1328,9 @@
>> /**
>> * Number of times to spin-wait before blocking. The spins (in
>> * awaitRunStateLock and awaitWork) currently use randomized
>> - * spins. If/when MWAIT-like intrinsics becomes available, they
>> - * may allow quieter spinning. The value of SPINS must be a power
>> - * of two, at least 4. The current value causes spinning for a
>> - * small fraction of typical context-switch times, well worthwhile
>> - * given the typical likelihoods that blocking is not necessary.
>> + * spins. Currently set to zero to reduce CPU usage.
>
> I'd keep the commentary even if disabling spinning at this time.
>
Some of removed commentary makes less sense given the motivation to set the value to zero. How about the following tweak:
/**
* Number of times to spin-wait before blocking. The spins (in
* awaitRunStateLock and awaitWork) currently use randomized
- * spins. If/when MWAIT-like intrinsics becomes available, they
- * may allow quieter spinning. The value of SPINS must be a power
- * of two, at least 4. The current value causes spinning for a
- * small fraction of typical context-switch times, well worthwhile
- * given the typical likelihoods that blocking is not necessary.
+ * spins. Currently set to zero to reduce CPU usage.
+ *
+ * If greater than zero the value of SPINS must be a power
+ * of two, at least 4. A value of 2048 causes spinning for a
+ * small fraction of typical context-switch times.
+ *
+ * If/when MWAIT-like intrinsics becomes available, they
+ * may allow quieter spinning.
*/
- private static final int SPINS = 1 << 11;
+ private static final int SPINS = 0;
Paul.
More information about the core-libs-dev
mailing list