JDK-8237842 : Separate definitions for default cache line and padding sizes
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2020-01-24
  • Updated: 2024-01-11
  • Resolved: 2024-01-04
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 23
23 b05Fixed
Related Reports
Blocks :  
Blocks :  
Blocks :  
Relates :  
Description
Claes posted this comment in response to a comment
from David Holmes in the JDK-8235931 review:

On 12/18/19 10:03 AM, Claes Redestad wrote:
> Hi,
>
> On 2019-12-18 06:50, David Holmes wrote:
>> Hi Dan,
>>
>> On 18/12/2019 7:34 am, Daniel D. Daugherty wrote:
>>> Greetings,
>>>
>>> I'm extracting another standalone fix from the Async Monitor Deflation
>>> project (JDK-8153224) and sending it out for review (and testing)
>>> separately. This is an XXS sized fix, but since it involves cache
>>> line sizes I don't think a trivial review is appropriate. 
>>
>> Can you elaborate on why a smaller cache-line-size assumption is beneficial here? Do you have performance numbers for the bug report? 
>
> I did numerous experiments on this during work on JEP-143 and saw no
> improvement on neither "real" benchmarks nor stress tests that try to
> explicitly provoke cross-monitor false sharing on various fields in
> ObjectMonitors. I've not re-run those experiments on new hardware, so
> YMMV. Should probably check if they're still usable..
>
> Specifically, for padding values below 64 we could provoke false sharing
> effects on stress tests, with negligible movement on "real" benchmarks.
> For values above 64 we just waste space.
>
> There exists a legend that you need double the physical cache line
> padding to not provoke the wrath of false sharing in the presence of
> aggressive prefetching, which is the reason why the
> "DEFAULT_CACHE_LINE_SIZE" is set to twice the typical physical cache
> line size in bytes. If we explicitly think we need to pad two lines,
> then the constant DEFAULT_CACHE_LINE_SIZE should be named differently.
>
> The patch in question looks good to me, although I'd prefer something
> like:
>
> CACHE_LINE_SIZE 64
> DOUBLE_CACHE_LINE_SIZE 128
>
> .. and then use whichever is deemed more appropriate on a case by case
> basis. (Hint: it's probably CACHE_LINE_SIZE)
>
> $.02
>
> /Claes 


The renaming of the existing DEFAULT_CACHE_LINE_SIZE
CACHE_LINE_SIZE or DOUBLE_CACHE_LINE_SIZE is
beyond the scope of what I was doing with JDK-8235931
so I'm filing this followup RFE.

Since DEFAULT_CACHE_LINE_SIZE is used by several
of the subsystems in HotSpot, it's not really clear where
this bug should be filed. I've started with hotspot/runtime,
but the triage team may move this elsewhere.
Comments
Changeset: dd517c64 Author: Aleksey Shipilev <shade@openjdk.org> Date: 2024-01-04 08:39:50 +0000 URL: https://git.openjdk.org/jdk/commit/dd517c64047705d706b095d15d9fd4e0703ab39b
04-01-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16973 Date: 2023-12-05 11:23:31 +0000
05-12-2023

I am taking this on, because I need a clear separation for cache line sizes and padding sizes for JDK-8321137.
05-12-2023

Here's a break down on where DEFAULT_CACHE_LINE_SIZE appears in the open source tree: $ grep -r DEFAULT_CACHE_LINE_SIZE open/src | sed -e 's/:.*//' -e 's#/[^/][^/]*$##' | sort | uniq -c 1 open/src/hotspot/cpu/ppc 3 open/src/hotspot/cpu/s390 3 open/src/hotspot/cpu/sparc 5 open/src/hotspot/cpu/x86 10 open/src/hotspot/share/gc/g1 9 open/src/hotspot/share/gc/shared 36 open/src/hotspot/share/gc/shenandoah 6 open/src/hotspot/share/memory 11 open/src/hotspot/share/runtime 4 open/src/hotspot/share/utilities 1 open/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime It looks like this symbol is primarily used in the GC directories... Moving this bug from hotspot/runtime -> hotspot/gc for triage.
28-01-2020

Added [~redestad], [~dholmes], and [~mdoerr] to the interest list since all have expressed an interest in this topic.
24-01-2020