JDK-8248214 : Add paddings for TaskQueueSuper to reduce false-sharing cache contention
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 11
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2020-06-24
  • Updated: 2020-11-30
  • Resolved: 2020-06-30
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 11 JDK 15 JDK 8 Other
11.0.10-oracleFixed 15Fixed 8u281Fixed openjdk8u282Fixed
This ticket actually covers a tiny part from JDK-8243326, Cleanup use of volatile in taskqueue code. 

class TaskQueueSuper has two volatile variables: _bottom and _age declared side by side, and the instances are widely used by g1 and cms functions, while many atomic functions operate on these two variables during the execution of the known work stealing algorithm among a number of threads,e.g. decided by ParallelGCThreads. Therefore, false-share caching contention would occur here and there. The proposed code change can be safe enough as it does not change any function explicitly, and performance measurement on benchmarks and small cases show positive effect steadily (please note it is difficult to completely reproduce the work-stealing algorithm and cache contentions in small test cases). 

A tiny part of JDK-8243326 added padding around the two variables with DEFINE_PAD_MINUS_SIZE which fixed the mentioned potential issue by the way. However it is no need to backport the whole patch (https://hg.openjdk.java.net/jdk/jdk/rev/252a1602b4c6) due to the complex context especially the new load/store atomic functions introduced beyond jdk11u.
Fix Request (8u) I would like to backport this patch to OpenJDK8u for parity with Oracle 8u281. 8u patch has been reviewed.

8u code review: https://mail.openjdk.java.net/pipermail/jdk8u-dev/2020-October/012858.html

URL: https://hg.openjdk.java.net/jdk-updates/jdk11u/rev/08c734477683 User: clanger Date: 2020-07-29 08:06:34 +0000

URL: https://hg.openjdk.java.net/jdk-updates/jdk11u-dev/rev/08c734477683 User: goetz Date: 2020-06-30 07:51:25 +0000

Fix Request (11u) This is a revised backport (much simpler from the original changeset) to reduce the cache contention issue in class TaskQueueSuper. The potential risk of downporting this: no functionality risk, while regarding the performance, I had tests on Linux system with a couple of x86_64/aarch64 servers, while count on jdk trunk (jdk15+21 and beyond) to cover the other systems with the original patch ( https://hg.openjdk.java.net/jdk/jdk/rev/252a1602b4c6). This can be a risk if someone measured and saw a different performance result on jdk11u from jdk trunk on other testing envs. 11u RFR: https://mail.openjdk.java.net/pipermail/jdk-updates-dev/2020-June/003372.html