JDK-8256303 : revisit ObjectMonitor padding between fields
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 16
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2020-11-12
  • Updated: 2024-10-01
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 25
25Unresolved
Related Reports
Relates :  
Relates :  
Description
[~rehn] mentioned this RFE during the JDK-8253064 review: 

 src/hotspot/share/runtime/objectMonitor.hpp
  DEFINE_PAD_MINUS_SIZE(0, OM_CACHE_LINE_SIZE, sizeof(volatile markWord) +
                        sizeof(WeakHandle) + sizeof(AllocationState));
                        sizeof(WeakHandle));
  // Used by async deflation as a marker in the _owner field:


I have test with and without padding, I saw no difference.

Comments
$ pahole -M -C ObjectMonitor build/linux-x64/images/jdk/lib/server/libjvm.so class ObjectMonitor : public CHeapObj<(MemTag)26> { public: /* class CHeapObj<(MemTag)26> <ancestor>; */ /* 0 0 */ /* XXX last struct has 1 byte of padding */ static class OopStorage * _oop_storage; /* 0 0 */ volatile uintptr_t _metadata; /* 0 8 */ class WeakHandle _object; /* 8 8 */ char _pad_buf0[48]; /* 16 48 */ /* Bitfield combined with previous fields */ static const uintptr_t DEFLATER_MARKER_VALUE = 2; /* 0 0 */ static const uintptr_t ANONYMOUS_OWNER = 1; /* 0 0 */ /* --- cacheline 1 boundary (64 bytes) --- */ volatile void * _owner; /* 64 8 */ volatile uint64_t _previous_owner_tid; /* 72 8 */ char _pad_buf1[48]; /* 80 48 */ /* --- cacheline 2 boundary (128 bytes) --- */ class ObjectMonitor * _next_om; /* 128 8 */ volatile intx _recursions; /* 136 8 */ volatile class ObjectWaiter * _EntryList; /* 144 8 */ volatile class ObjectWaiter * _cxq; /* 152 8 */ volatile class JavaThread * _succ; /* 160 8 */ volatile int _SpinDuration; /* 168 4 */ int _contentions; /* 172 4 */ volatile class ObjectWaiter * _WaitSet; /* 176 8 */ volatile int _waiters; /* 184 4 */ volatile int _WaitSetLock; /* 188 4 */ /* Bitfield combined with previous fields */ static PerfCounter * _sync_ContendedLockAttempts; /* 0 0 */ static PerfCounter * _sync_FutileWakeups; /* 0 0 */ static PerfCounter * _sync_Parks; /* 0 0 */ static PerfCounter * _sync_Notifications; /* 0 0 */ static PerfCounter * _sync_Inflations; /* 0 0 */ static PerfCounter * _sync_Deflations; /* 0 0 */ static class PerfLongVariable * _sync_MonExtant; /* 0 0 */ static int Knob_SpinLimit; /* 0 0 */ /* size: 192, cachelines: 3, members: 17, static members: 11 */ /* paddings: 1, sum paddings: 1 */ };
30-09-2024

I won't have time to investigate this issue for JDK19.
04-05-2022

The dust has not settled on the performance bugs that were logged against JDK-8253064 so making more changes that might make performance worse would not be a good idea. Changing to 'tbd'.
20-05-2021

[~rehn] - Feel free to edit the bug to make things more clear since all I did was copy stuff from the PR.
12-11-2020