Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inheritance based padding #65

Merged
merged 4 commits into from
Dec 24, 2024
Merged

Conversation

lokok8
Copy link
Contributor

@lokok8 lokok8 commented Sep 10, 2024

Hi,

I want to start with noting that I am no expert in this domain, but while curiously browsing JDK23 release notes I stumbled onto the deprecation of -XX:+UseEmptySlotsInSupers in JDK-8330607 which then lead me into finding about field layout changes in JDK15+ which can affect padding for avoiding false-sharing.

Long story short, it appears that padding now should be done with bytes instead of longs.

Unfortunately I did not yet get into doing any actual performance testing. Any feedback is highly appreciated.

Some relevant reading material:

@lokok8
Copy link
Contributor Author

lokok8 commented Sep 10, 2024

I still didn't work out all the details, but after reading more into chapter 10 of Aleksey Shipilёvs article, there is much more in this topic.

@jac18281828
Copy link
Collaborator

Thank you for the detailed write up and explanation. At a minimum for this change to be accepted you will need to replace bytes in both locations that exhibit this pattern. I would recommend using 128 bytes also rather than 64 to avoid cache prefetch. Finally be sure both locations include the 'sumToAvoidOptimization' trick so that the bytes do not get optimized out. I note that in my version of AbstractWaitingCondition this is omitted.

@lokok8
Copy link
Contributor Author

lokok8 commented Sep 17, 2024

replace bytes in both locations that exhibit this pattern

Done. I noticed this pattern in 4 locations in total. I assume this change woule be beneficial for all of them?


I would recommend using 128 bytes also rather than 64 to avoid cache prefetch

Done.


include the 'sumToAvoidOptimization' trick so that the bytes do not get optimized out

Done. I omitted +headCache+tailCache in two of the classes as they are not unused. (However, I am not sure this optimization is actually necessary for Java. I believe unused fields will never be removed.)


Thank you for your comment! I will follow up with a brief explanation of my understanding of this inheritance based field padding. Still no performance testing done from my side.

@lokok8 lokok8 marked this pull request as draft September 17, 2024 19:55
@lokok8
Copy link
Contributor Author

lokok8 commented Sep 17, 2024

Here is my current understanding of the topic. Basically all of my information is from this article by Aleksey Shipilёv which I recommend reading.

It turns out that in general the actual field layout is not the same as the declaration order see §10.1, even before JDK15. This means the "c-style" padding strategy for preventing false sharing is in general not reliable in Java see §10.2.

I tried out jol-cli for printing out the field layout of the relevant classes in conversant disruptor.

currently working

AbstractWaitingCondition (master, JDK22)
temurin-22.0.2/bin/java -jar jol-cli-latest.jar internals -cp disruptor-1.2.22-SNAPSHOT.jar com.conversantmedia.util.concurrent.AbstractWaitingCondition
Failed to find matching constructor, falling back to class-only introspection.

com.conversantmedia.util.concurrent.AbstractWaitingCondition object internals:
OFF  SZ                                               TYPE DESCRIPTION                          VALUE
0   8                                                    (object header: mark)                N/A
8   4                                                    (object header: class)               N/A
12   4              java.util.concurrent.atomic.LongAdder AbstractWaitingCondition.waitCount   N/A
16   8                                               long AbstractWaitingCondition.r1          N/A
24   8                                               long AbstractWaitingCondition.r2          N/A
32   8                                               long AbstractWaitingCondition.r3          N/A
40   8                                               long AbstractWaitingCondition.r4          N/A
48   8                                               long AbstractWaitingCondition.r5          N/A
56   8                                               long AbstractWaitingCondition.r6          N/A
64   8                                               long AbstractWaitingCondition.r7          N/A
72   8                                               long AbstractWaitingCondition.waitCache   N/A
80   8                                               long AbstractWaitingCondition.c1          N/A
88   8                                               long AbstractWaitingCondition.c2          N/A
96   8                                               long AbstractWaitingCondition.c3          N/A
104   8                                               long AbstractWaitingCondition.c4          N/A
112   8                                               long AbstractWaitingCondition.c5          N/A
120   8                                               long AbstractWaitingCondition.c6          N/A
128   8                                               long AbstractWaitingCondition.c7          N/A
136   8                                               long AbstractWaitingCondition.c8          N/A
144   4   java.util.concurrent.atomic.AtomicReferenceArray AbstractWaitingCondition.waiter      N/A
148   4                                                    (object alignment gap)               
Instance size: 152 bytes
Space losses: 0 bytes internal + 4 bytes external = 4 bytes total

Here is the current layout of AbstractWaitingCondition. It actually happens to have the desired field layout with waitCache squeezed inbetween rx and cy. I did the same for PushPullConcurrentQueue and MultithreadConcurrentQueue, which also have the desired layout (see attachment). Obviously, this is only by chance and I do not really have an understanding whether this can break in any regular condition, in the current state.

currently broken

MPMCConcurrentQueue$Cell (master, JDK22)
temurin-22.0.2/bin/java -jar jol-cli-latest.jar internals -cp disruptor-1.2.22-SNAPSHOT.jar com.conversantmedia.util.concurrent.MPMCConcurrentQueue\$Cell 
Instantiated the sample instance via com.conversantmedia.util.concurrent.MPMCConcurrentQueue$Cell(long)

com.conversantmedia.util.concurrent.MPMCConcurrentQueue$Cell object internals:
OFF  SZ                                                      TYPE DESCRIPTION               VALUE
0   8                                                           (object header: mark)     0x0000000000000001 (non-biasable; age: 0)
8   4                                                           (object header: class)    0x01012400
12   4   com.conversantmedia.util.concurrent.ContendedAtomicLong Cell.seq                  (object)
16   8                                                      long Cell.p1                   0
24   8                                                      long Cell.p2                   0
32   8                                                      long Cell.p3                   0
40   8                                                      long Cell.p4                   0
48   8                                                      long Cell.p5                   0
56   8                                                      long Cell.p6                   0
64   8                                                      long Cell.p7                   0
72   8                                                      long Cell.a1                   0
80   8                                                      long Cell.a2                   0
88   8                                                      long Cell.a3                   0
96   8                                                      long Cell.a4                   0
104   8                                                      long Cell.a5                   0
112   8                                                      long Cell.a6                   0
120   8                                                      long Cell.a7                   0
128   8                                                      long Cell.a8                   0
136   4                                          java.lang.Object Cell.entry                null
140   4                                                           (object alignment gap)    
Instance size: 144 bytes
Space losses: 0 bytes internal + 4 bytes external = 4 bytes total

Looking at MPMCConcurrentQueue$Cell however, the Layout does not appear to be in the desired layout with Cell.entry being at the end.

broken example

As an experiment, I hacked long waitCache to int waitCache in AbstractWaitingCondition

AbstractWaitingCondition (hacked int waitCache, JDK22)
temurin-22.0.2/bin/java -jar jol-cli-latest.jar internals -cp disruptor-1.2.22-SNAPSHOT.jar com.conversantmedia.util.concurrent.AbstractWaitingCondition
Failed to find matching constructor, falling back to class-only introspection.

com.conversantmedia.util.concurrent.AbstractWaitingCondition object internals:
OFF  SZ                                               TYPE DESCRIPTION                          VALUE
0   8                                                    (object header: mark)                N/A
8   4                                                    (object header: class)               N/A
12   4                                                int AbstractWaitingCondition.waitCache   N/A
16   8                                               long AbstractWaitingCondition.r1          N/A
24   8                                               long AbstractWaitingCondition.r2          N/A
32   8                                               long AbstractWaitingCondition.r3          N/A
40   8                                               long AbstractWaitingCondition.r4          N/A
48   8                                               long AbstractWaitingCondition.r5          N/A
56   8                                               long AbstractWaitingCondition.r6          N/A
64   8                                               long AbstractWaitingCondition.r7          N/A
72   8                                               long AbstractWaitingCondition.c1          N/A
80   8                                               long AbstractWaitingCondition.c2          N/A
88   8                                               long AbstractWaitingCondition.c3          N/A
96   8                                               long AbstractWaitingCondition.c4          N/A
104   8                                               long AbstractWaitingCondition.c5          N/A
112   8                                               long AbstractWaitingCondition.c6          N/A
120   8                                               long AbstractWaitingCondition.c7          N/A
128   8                                               long AbstractWaitingCondition.c8          N/A
136   4              java.util.concurrent.atomic.LongAdder AbstractWaitingCondition.waitCount   N/A
140   4   java.util.concurrent.atomic.AtomicReferenceArray AbstractWaitingCondition.waiter      N/A
Instance size: 144 bytes
Space losses: 0 bytes internal + 0 bytes external = 0 bytes total

Here we can see that the layout was reordered and waitCache was placed at the very beginning, breaking the padding. Similarly in §10.2 the layout is reorded when there are different datatypes.

broken fix

The same happened in my first more or less blind "fix" in 453b8eb which evidently actually broke the layout of AbstractWaitingCondition.

AbstractWaitingCondition (453b8eb, JDK22)
temurin-22.0.2/bin/java -jar jol-cli-latest.jar internals -cp disruptor-1.2.22-SNAPSHOT.jar com.conversantmedia.util.concurrent.AbstractWaitingCondition
Failed to find matching constructor, falling back to class-only introspection.

com.conversantmedia.util.concurrent.AbstractWaitingCondition object internals:
OFF  SZ                                               TYPE DESCRIPTION                          VALUE
0   8                                                    (object header: mark)                N/A
8   4                                                    (object header: class)               N/A
12   1                                               byte AbstractWaitingCondition.r11         N/A
13   1                                               byte AbstractWaitingCondition.r12         N/A
14   1                                               byte AbstractWaitingCondition.r13         N/A
15   1                                               byte AbstractWaitingCondition.r14         N/A
16   8                                               long AbstractWaitingCondition.waitCache   N/A
24   1                                               byte AbstractWaitingCondition.r15         N/A
25   1                                               byte AbstractWaitingCondition.r16         N/A
26   1                                               byte AbstractWaitingCondition.r17         N/A
27   1                                               byte AbstractWaitingCondition.r18         N/A
28   1                                               byte AbstractWaitingCondition.r21         N/A
29   1                                               byte AbstractWaitingCondition.r22         N/A
30   1                                               byte AbstractWaitingCondition.r23         N/A
31   1                                               byte AbstractWaitingCondition.r24         N/A
32   1                                               byte AbstractWaitingCondition.r25         N/A
33   1                                               byte AbstractWaitingCondition.r26         N/A
34   1                                               byte AbstractWaitingCondition.r27         N/A
35   1                                               byte AbstractWaitingCondition.r28         N/A
36   1                                               byte AbstractWaitingCondition.r31         N/A
37   1                                               byte AbstractWaitingCondition.r32         N/A
38   1                                               byte AbstractWaitingCondition.r33         N/A
39   1                                               byte AbstractWaitingCondition.r34         N/A
40   1                                               byte AbstractWaitingCondition.r35         N/A
41   1                                               byte AbstractWaitingCondition.r36         N/A
42   1                                               byte AbstractWaitingCondition.r37         N/A
43   1                                               byte AbstractWaitingCondition.r38         N/A
44   1                                               byte AbstractWaitingCondition.r41         N/A
45   1                                               byte AbstractWaitingCondition.r42         N/A
46   1                                               byte AbstractWaitingCondition.r43         N/A
47   1                                               byte AbstractWaitingCondition.r44         N/A
48   1                                               byte AbstractWaitingCondition.r45         N/A
49   1                                               byte AbstractWaitingCondition.r46         N/A
50   1                                               byte AbstractWaitingCondition.r47         N/A
51   1                                               byte AbstractWaitingCondition.r48         N/A
52   1                                               byte AbstractWaitingCondition.r51         N/A
53   1                                               byte AbstractWaitingCondition.r52         N/A
54   1                                               byte AbstractWaitingCondition.r53         N/A
55   1                                               byte AbstractWaitingCondition.r54         N/A
56   1                                               byte AbstractWaitingCondition.r55         N/A
57   1                                               byte AbstractWaitingCondition.r56         N/A
58   1                                               byte AbstractWaitingCondition.r57         N/A
59   1                                               byte AbstractWaitingCondition.r58         N/A
60   1                                               byte AbstractWaitingCondition.r61         N/A
61   1                                               byte AbstractWaitingCondition.r62         N/A
62   1                                               byte AbstractWaitingCondition.r63         N/A
63   1                                               byte AbstractWaitingCondition.r64         N/A
64   1                                               byte AbstractWaitingCondition.r65         N/A
65   1                                               byte AbstractWaitingCondition.r66         N/A
66   1                                               byte AbstractWaitingCondition.r67         N/A
67   1                                               byte AbstractWaitingCondition.r68         N/A
68   1                                               byte AbstractWaitingCondition.r71         N/A
69   1                                               byte AbstractWaitingCondition.r72         N/A
70   1                                               byte AbstractWaitingCondition.r73         N/A
71   1                                               byte AbstractWaitingCondition.r74         N/A
72   1                                               byte AbstractWaitingCondition.r75         N/A
73   1                                               byte AbstractWaitingCondition.r76         N/A
74   1                                               byte AbstractWaitingCondition.r77         N/A
75   1                                               byte AbstractWaitingCondition.r78         N/A
76   1                                               byte AbstractWaitingCondition.c11         N/A
77   1                                               byte AbstractWaitingCondition.c12         N/A
78   1                                               byte AbstractWaitingCondition.c13         N/A
79   1                                               byte AbstractWaitingCondition.c14         N/A
80   1                                               byte AbstractWaitingCondition.c15         N/A
81   1                                               byte AbstractWaitingCondition.c16         N/A
82   1                                               byte AbstractWaitingCondition.c17         N/A
83   1                                               byte AbstractWaitingCondition.c18         N/A
84   1                                               byte AbstractWaitingCondition.c21         N/A
85   1                                               byte AbstractWaitingCondition.c22         N/A
86   1                                               byte AbstractWaitingCondition.c23         N/A
87   1                                               byte AbstractWaitingCondition.c24         N/A
88   1                                               byte AbstractWaitingCondition.c25         N/A
89   1                                               byte AbstractWaitingCondition.c26         N/A
90   1                                               byte AbstractWaitingCondition.c27         N/A
91   1                                               byte AbstractWaitingCondition.c28         N/A
92   1                                               byte AbstractWaitingCondition.c31         N/A
93   1                                               byte AbstractWaitingCondition.c32         N/A
94   1                                               byte AbstractWaitingCondition.c33         N/A
95   1                                               byte AbstractWaitingCondition.c34         N/A
96   1                                               byte AbstractWaitingCondition.c35         N/A
97   1                                               byte AbstractWaitingCondition.c36         N/A
98   1                                               byte AbstractWaitingCondition.c37         N/A
99   1                                               byte AbstractWaitingCondition.c38         N/A
100   1                                               byte AbstractWaitingCondition.c41         N/A
101   1                                               byte AbstractWaitingCondition.c42         N/A
102   1                                               byte AbstractWaitingCondition.c43         N/A
103   1                                               byte AbstractWaitingCondition.c44         N/A
104   1                                               byte AbstractWaitingCondition.c45         N/A
105   1                                               byte AbstractWaitingCondition.c46         N/A
106   1                                               byte AbstractWaitingCondition.c47         N/A
107   1                                               byte AbstractWaitingCondition.c48         N/A
108   1                                               byte AbstractWaitingCondition.c51         N/A
109   1                                               byte AbstractWaitingCondition.c52         N/A
110   1                                               byte AbstractWaitingCondition.c53         N/A
111   1                                               byte AbstractWaitingCondition.c54         N/A
112   1                                               byte AbstractWaitingCondition.c55         N/A
113   1                                               byte AbstractWaitingCondition.c56         N/A
114   1                                               byte AbstractWaitingCondition.c57         N/A
115   1                                               byte AbstractWaitingCondition.c58         N/A
116   1                                               byte AbstractWaitingCondition.c61         N/A
117   1                                               byte AbstractWaitingCondition.c62         N/A
118   1                                               byte AbstractWaitingCondition.c63         N/A
119   1                                               byte AbstractWaitingCondition.c64         N/A
120   1                                               byte AbstractWaitingCondition.c65         N/A
121   1                                               byte AbstractWaitingCondition.c66         N/A
122   1                                               byte AbstractWaitingCondition.c67         N/A
123   1                                               byte AbstractWaitingCondition.c68         N/A
124   1                                               byte AbstractWaitingCondition.c71         N/A
125   1                                               byte AbstractWaitingCondition.c72         N/A
126   1                                               byte AbstractWaitingCondition.c73         N/A
127   1                                               byte AbstractWaitingCondition.c74         N/A
128   1                                               byte AbstractWaitingCondition.c75         N/A
129   1                                               byte AbstractWaitingCondition.c76         N/A
130   1                                               byte AbstractWaitingCondition.c77         N/A
131   1                                               byte AbstractWaitingCondition.c78         N/A
132   1                                               byte AbstractWaitingCondition.c81         N/A
133   1                                               byte AbstractWaitingCondition.c82         N/A
134   1                                               byte AbstractWaitingCondition.c83         N/A
135   1                                               byte AbstractWaitingCondition.c84         N/A
136   1                                               byte AbstractWaitingCondition.c85         N/A
137   1                                               byte AbstractWaitingCondition.c86         N/A
138   1                                               byte AbstractWaitingCondition.c87         N/A
139   1                                               byte AbstractWaitingCondition.c88         N/A
140   4              java.util.concurrent.atomic.LongAdder AbstractWaitingCondition.waitCount   N/A
144   4   java.util.concurrent.atomic.AtomicReferenceArray AbstractWaitingCondition.waiter      N/A
148   4                                                    (object alignment gap)               
Instance size: 152 bytes
Space losses: 0 bytes internal + 4 bytes external = 4 bytes total

current draft PR, working

As a workaround we can use inheritance to construct the desired field layout see §11.3. Here we abuse an implementation detail where fields are ordered by the inheritance of the classes.

However, now we reach the issue since JDK15 where fields can be reordered "across classes" see first half of §11.5. To workaround this new issue padding should always be done with bytes instead of longs see second half of §11.5.

Explanation in the linked JMH Sample:

It is important to use the smallest data type, so that layouter would not generate any gaps that can be taken by later protected subclasses fields. Depending on the actual field layout of classes that bear the protected fields, we might need more padding to account for "lost" padding fields pulled into in their superclass gaps.

Using inheritance for padding and using bytes has the following results:

MPMCConcurrentQueue$Cell (current PR, JDK22)
temurin-22.0.2/bin/java -jar jol-cli-latest.jar internals -cp disruptor-1.2.22-SNAPSHOT.jar com.conversantmedia.util.concurrent.MPMCConcurrentQueue\$Cell 
Instantiated the sample instance via com.conversantmedia.util.concurrent.MPMCConcurrentQueue$Cell(long)

com.conversantmedia.util.concurrent.MPMCConcurrentQueue$Cell object internals:
OFF  SZ                                                      TYPE DESCRIPTION               VALUE
0   8                                                           (object header: mark)     0x0000000000000001 (non-biasable; age: 0)
8   4                                                           (object header: class)    0x01013410
12   1                                                      byte CellLhsPadding.p11        0
13   1                                                      byte CellLhsPadding.p12        0
14   1                                                      byte CellLhsPadding.p13        0
15   1                                                      byte CellLhsPadding.p14        0
16   1                                                      byte CellLhsPadding.p15        0
17   1                                                      byte CellLhsPadding.p16        0
18   1                                                      byte CellLhsPadding.p17        0
19   1                                                      byte CellLhsPadding.p18        0
20   1                                                      byte CellLhsPadding.p21        0
21   1                                                      byte CellLhsPadding.p22        0
22   1                                                      byte CellLhsPadding.p23        0
23   1                                                      byte CellLhsPadding.p24        0
24   1                                                      byte CellLhsPadding.p25        0
25   1                                                      byte CellLhsPadding.p26        0
26   1                                                      byte CellLhsPadding.p27        0
27   1                                                      byte CellLhsPadding.p28        0
28   1                                                      byte CellLhsPadding.p31        0
29   1                                                      byte CellLhsPadding.p32        0
30   1                                                      byte CellLhsPadding.p33        0
31   1                                                      byte CellLhsPadding.p34        0
32   1                                                      byte CellLhsPadding.p35        0
33   1                                                      byte CellLhsPadding.p36        0
34   1                                                      byte CellLhsPadding.p37        0
35   1                                                      byte CellLhsPadding.p38        0
36   1                                                      byte CellLhsPadding.p41        0
37   1                                                      byte CellLhsPadding.p42        0
38   1                                                      byte CellLhsPadding.p43        0
39   1                                                      byte CellLhsPadding.p44        0
40   1                                                      byte CellLhsPadding.p45        0
41   1                                                      byte CellLhsPadding.p46        0
42   1                                                      byte CellLhsPadding.p47        0
43   1                                                      byte CellLhsPadding.p48        0
44   1                                                      byte CellLhsPadding.p51        0
45   1                                                      byte CellLhsPadding.p52        0
46   1                                                      byte CellLhsPadding.p53        0
47   1                                                      byte CellLhsPadding.p54        0
48   1                                                      byte CellLhsPadding.p55        0
49   1                                                      byte CellLhsPadding.p56        0
50   1                                                      byte CellLhsPadding.p57        0
51   1                                                      byte CellLhsPadding.p58        0
52   1                                                      byte CellLhsPadding.p61        0
53   1                                                      byte CellLhsPadding.p62        0
54   1                                                      byte CellLhsPadding.p63        0
55   1                                                      byte CellLhsPadding.p64        0
56   1                                                      byte CellLhsPadding.p65        0
57   1                                                      byte CellLhsPadding.p66        0
58   1                                                      byte CellLhsPadding.p67        0
59   1                                                      byte CellLhsPadding.p68        0
60   1                                                      byte CellLhsPadding.p71        0
61   1                                                      byte CellLhsPadding.p72        0
62   1                                                      byte CellLhsPadding.p73        0
63   1                                                      byte CellLhsPadding.p74        0
64   1                                                      byte CellLhsPadding.p75        0
65   1                                                      byte CellLhsPadding.p76        0
66   1                                                      byte CellLhsPadding.p77        0
67   1                                                      byte CellLhsPadding.p78        0
68   1                                                      byte CellLhsPadding.p81        0
69   1                                                      byte CellLhsPadding.p82        0
70   1                                                      byte CellLhsPadding.p83        0
71   1                                                      byte CellLhsPadding.p84        0
72   1                                                      byte CellLhsPadding.p85        0
73   1                                                      byte CellLhsPadding.p86        0
74   1                                                      byte CellLhsPadding.p87        0
75   1                                                      byte CellLhsPadding.p88        0
76   1                                                      byte CellLhsPadding.p91        0
77   1                                                      byte CellLhsPadding.p92        0
78   1                                                      byte CellLhsPadding.p93        0
79   1                                                      byte CellLhsPadding.p94        0
80   1                                                      byte CellLhsPadding.p95        0
81   1                                                      byte CellLhsPadding.p96        0
82   1                                                      byte CellLhsPadding.p97        0
83   1                                                      byte CellLhsPadding.p98        0
84   1                                                      byte CellLhsPadding.p101       0
85   1                                                      byte CellLhsPadding.p102       0
86   1                                                      byte CellLhsPadding.p103       0
87   1                                                      byte CellLhsPadding.p104       0
88   1                                                      byte CellLhsPadding.p105       0
89   1                                                      byte CellLhsPadding.p106       0
90   1                                                      byte CellLhsPadding.p107       0
91   1                                                      byte CellLhsPadding.p108       0
92   1                                                      byte CellLhsPadding.p111       0
93   1                                                      byte CellLhsPadding.p112       0
94   1                                                      byte CellLhsPadding.p113       0
95   1                                                      byte CellLhsPadding.p114       0
96   1                                                      byte CellLhsPadding.p115       0
97   1                                                      byte CellLhsPadding.p116       0
98   1                                                      byte CellLhsPadding.p117       0
99   1                                                      byte CellLhsPadding.p118       0
100   1                                                      byte CellLhsPadding.p121       0
101   1                                                      byte CellLhsPadding.p122       0
102   1                                                      byte CellLhsPadding.p123       0
103   1                                                      byte CellLhsPadding.p124       0
104   1                                                      byte CellLhsPadding.p125       0
105   1                                                      byte CellLhsPadding.p126       0
106   1                                                      byte CellLhsPadding.p127       0
107   1                                                      byte CellLhsPadding.p128       0
108   1                                                      byte CellLhsPadding.p131       0
109   1                                                      byte CellLhsPadding.p132       0
110   1                                                      byte CellLhsPadding.p133       0
111   1                                                      byte CellLhsPadding.p134       0
112   1                                                      byte CellLhsPadding.p135       0
113   1                                                      byte CellLhsPadding.p136       0
114   1                                                      byte CellLhsPadding.p137       0
115   1                                                      byte CellLhsPadding.p138       0
116   1                                                      byte CellLhsPadding.p141       0
117   1                                                      byte CellLhsPadding.p142       0
118   1                                                      byte CellLhsPadding.p143       0
119   1                                                      byte CellLhsPadding.p144       0
120   1                                                      byte CellLhsPadding.p145       0
121   1                                                      byte CellLhsPadding.p146       0
122   1                                                      byte CellLhsPadding.p147       0
123   1                                                      byte CellLhsPadding.p148       0
124   1                                                      byte CellLhsPadding.p151       0
125   1                                                      byte CellLhsPadding.p152       0
126   1                                                      byte CellLhsPadding.p153       0
127   1                                                      byte CellLhsPadding.p154       0
128   1                                                      byte CellLhsPadding.p155       0
129   1                                                      byte CellLhsPadding.p156       0
130   1                                                      byte CellLhsPadding.p157       0
131   1                                                      byte CellLhsPadding.p158       0
132   4                                          java.lang.Object CellEntry.entry           null
136   1                                                      byte CellRhsPadding.a11        0
137   1                                                      byte CellRhsPadding.a12        0
138   1                                                      byte CellRhsPadding.a13        0
139   1                                                      byte CellRhsPadding.a14        0
140   1                                                      byte CellRhsPadding.a15        0
141   1                                                      byte CellRhsPadding.a16        0
142   1                                                      byte CellRhsPadding.a17        0
143   1                                                      byte CellRhsPadding.a18        0
144   1                                                      byte CellRhsPadding.a21        0
145   1                                                      byte CellRhsPadding.a22        0
146   1                                                      byte CellRhsPadding.a23        0
147   1                                                      byte CellRhsPadding.a24        0
148   1                                                      byte CellRhsPadding.a25        0
149   1                                                      byte CellRhsPadding.a26        0
150   1                                                      byte CellRhsPadding.a27        0
151   1                                                      byte CellRhsPadding.a28        0
152   1                                                      byte CellRhsPadding.a31        0
153   1                                                      byte CellRhsPadding.a32        0
154   1                                                      byte CellRhsPadding.a33        0
155   1                                                      byte CellRhsPadding.a34        0
156   1                                                      byte CellRhsPadding.a35        0
157   1                                                      byte CellRhsPadding.a36        0
158   1                                                      byte CellRhsPadding.a37        0
159   1                                                      byte CellRhsPadding.a38        0
160   1                                                      byte CellRhsPadding.a41        0
161   1                                                      byte CellRhsPadding.a42        0
162   1                                                      byte CellRhsPadding.a43        0
163   1                                                      byte CellRhsPadding.a44        0
164   1                                                      byte CellRhsPadding.a45        0
165   1                                                      byte CellRhsPadding.a46        0
166   1                                                      byte CellRhsPadding.a47        0
167   1                                                      byte CellRhsPadding.a48        0
168   1                                                      byte CellRhsPadding.a51        0
169   1                                                      byte CellRhsPadding.a52        0
170   1                                                      byte CellRhsPadding.a53        0
171   1                                                      byte CellRhsPadding.a54        0
172   1                                                      byte CellRhsPadding.a55        0
173   1                                                      byte CellRhsPadding.a56        0
174   1                                                      byte CellRhsPadding.a57        0
175   1                                                      byte CellRhsPadding.a58        0
176   1                                                      byte CellRhsPadding.a61        0
177   1                                                      byte CellRhsPadding.a62        0
178   1                                                      byte CellRhsPadding.a63        0
179   1                                                      byte CellRhsPadding.a64        0
180   1                                                      byte CellRhsPadding.a65        0
181   1                                                      byte CellRhsPadding.a66        0
182   1                                                      byte CellRhsPadding.a67        0
183   1                                                      byte CellRhsPadding.a68        0
184   1                                                      byte CellRhsPadding.a71        0
185   1                                                      byte CellRhsPadding.a72        0
186   1                                                      byte CellRhsPadding.a73        0
187   1                                                      byte CellRhsPadding.a74        0
188   1                                                      byte CellRhsPadding.a75        0
189   1                                                      byte CellRhsPadding.a76        0
190   1                                                      byte CellRhsPadding.a77        0
191   1                                                      byte CellRhsPadding.a78        0
192   1                                                      byte CellRhsPadding.a81        0
193   1                                                      byte CellRhsPadding.a82        0
194   1                                                      byte CellRhsPadding.a83        0
195   1                                                      byte CellRhsPadding.a84        0
196   1                                                      byte CellRhsPadding.a85        0
197   1                                                      byte CellRhsPadding.a86        0
198   1                                                      byte CellRhsPadding.a87        0
199   1                                                      byte CellRhsPadding.a88        0
200   1                                                      byte CellRhsPadding.a91        0
201   1                                                      byte CellRhsPadding.a92        0
202   1                                                      byte CellRhsPadding.a93        0
203   1                                                      byte CellRhsPadding.a94        0
204   1                                                      byte CellRhsPadding.a95        0
205   1                                                      byte CellRhsPadding.a96        0
206   1                                                      byte CellRhsPadding.a97        0
207   1                                                      byte CellRhsPadding.a98        0
208   1                                                      byte CellRhsPadding.a101       0
209   1                                                      byte CellRhsPadding.a102       0
210   1                                                      byte CellRhsPadding.a103       0
211   1                                                      byte CellRhsPadding.a104       0
212   1                                                      byte CellRhsPadding.a105       0
213   1                                                      byte CellRhsPadding.a106       0
214   1                                                      byte CellRhsPadding.a107       0
215   1                                                      byte CellRhsPadding.a108       0
216   1                                                      byte CellRhsPadding.a111       0
217   1                                                      byte CellRhsPadding.a112       0
218   1                                                      byte CellRhsPadding.a113       0
219   1                                                      byte CellRhsPadding.a114       0
220   1                                                      byte CellRhsPadding.a115       0
221   1                                                      byte CellRhsPadding.a116       0
222   1                                                      byte CellRhsPadding.a117       0
223   1                                                      byte CellRhsPadding.a118       0
224   1                                                      byte CellRhsPadding.a121       0
225   1                                                      byte CellRhsPadding.a122       0
226   1                                                      byte CellRhsPadding.a123       0
227   1                                                      byte CellRhsPadding.a124       0
228   1                                                      byte CellRhsPadding.a125       0
229   1                                                      byte CellRhsPadding.a126       0
230   1                                                      byte CellRhsPadding.a127       0
231   1                                                      byte CellRhsPadding.a128       0
232   1                                                      byte CellRhsPadding.a131       0
233   1                                                      byte CellRhsPadding.a132       0
234   1                                                      byte CellRhsPadding.a133       0
235   1                                                      byte CellRhsPadding.a134       0
236   1                                                      byte CellRhsPadding.a135       0
237   1                                                      byte CellRhsPadding.a136       0
238   1                                                      byte CellRhsPadding.a137       0
239   1                                                      byte CellRhsPadding.a138       0
240   1                                                      byte CellRhsPadding.a141       0
241   1                                                      byte CellRhsPadding.a142       0
242   1                                                      byte CellRhsPadding.a143       0
243   1                                                      byte CellRhsPadding.a144       0
244   1                                                      byte CellRhsPadding.a145       0
245   1                                                      byte CellRhsPadding.a146       0
246   1                                                      byte CellRhsPadding.a147       0
247   1                                                      byte CellRhsPadding.a148       0
248   1                                                      byte CellRhsPadding.a151       0
249   1                                                      byte CellRhsPadding.a152       0
250   1                                                      byte CellRhsPadding.a153       0
251   1                                                      byte CellRhsPadding.a154       0
252   1                                                      byte CellRhsPadding.a155       0
253   1                                                      byte CellRhsPadding.a156       0
254   1                                                      byte CellRhsPadding.a157       0
255   1                                                      byte CellRhsPadding.a158       0
256   1                                                      byte CellRhsPadding.a161       0
257   1                                                      byte CellRhsPadding.a162       0
258   1                                                      byte CellRhsPadding.a163       0
259   1                                                      byte CellRhsPadding.a164       0
260   1                                                      byte CellRhsPadding.a165       0
261   1                                                      byte CellRhsPadding.a166       0
262   1                                                      byte CellRhsPadding.a167       0
263   1                                                      byte CellRhsPadding.a168       0
264   4   com.conversantmedia.util.concurrent.ContendedAtomicLong Cell.seq                  (object)
268   4                                                           (object alignment gap)    
Instance size: 272 bytes
Space losses: 0 bytes internal + 4 bytes external = 4 bytes total

CellEntry.entry is padded as desired

current PR working-ish

AbstractWaitingCondition (current PR, JDK22)
temurin-22.0.2/bin/java -jar jol-cli-latest.jar internals -cp disruptor-1.2.22-SNAPSHOT.jar com.conversantmedia.util.concurrent.AbstractWaitingCondition
Failed to find matching constructor, falling back to class-only introspection.

com.conversantmedia.util.concurrent.AbstractWaitingCondition object internals:
OFF  SZ                                               TYPE DESCRIPTION                                   VALUE
0   8                                                    (object header: mark)                         N/A
8   4                                                    (object header: class)                        N/A
12   1                                               byte AbstractWaitingConditionLhsPadding.r11        N/A
13   1                                               byte AbstractWaitingConditionLhsPadding.r12        N/A
14   1                                               byte AbstractWaitingConditionLhsPadding.r13        N/A
15   1                                               byte AbstractWaitingConditionLhsPadding.r14        N/A
16   1                                               byte AbstractWaitingConditionLhsPadding.r15        N/A
17   1                                               byte AbstractWaitingConditionLhsPadding.r16        N/A
18   1                                               byte AbstractWaitingConditionLhsPadding.r17        N/A
19   1                                               byte AbstractWaitingConditionLhsPadding.r18        N/A
20   1                                               byte AbstractWaitingConditionLhsPadding.r21        N/A
21   1                                               byte AbstractWaitingConditionLhsPadding.r22        N/A
22   1                                               byte AbstractWaitingConditionLhsPadding.r23        N/A
23   1                                               byte AbstractWaitingConditionLhsPadding.r24        N/A
24   1                                               byte AbstractWaitingConditionLhsPadding.r25        N/A
25   1                                               byte AbstractWaitingConditionLhsPadding.r26        N/A
26   1                                               byte AbstractWaitingConditionLhsPadding.r27        N/A
27   1                                               byte AbstractWaitingConditionLhsPadding.r28        N/A
28   1                                               byte AbstractWaitingConditionLhsPadding.r31        N/A
29   1                                               byte AbstractWaitingConditionLhsPadding.r32        N/A
30   1                                               byte AbstractWaitingConditionLhsPadding.r33        N/A
31   1                                               byte AbstractWaitingConditionLhsPadding.r34        N/A
32   1                                               byte AbstractWaitingConditionLhsPadding.r35        N/A
33   1                                               byte AbstractWaitingConditionLhsPadding.r36        N/A
34   1                                               byte AbstractWaitingConditionLhsPadding.r37        N/A
35   1                                               byte AbstractWaitingConditionLhsPadding.r38        N/A
36   1                                               byte AbstractWaitingConditionLhsPadding.r41        N/A
37   1                                               byte AbstractWaitingConditionLhsPadding.r42        N/A
38   1                                               byte AbstractWaitingConditionLhsPadding.r43        N/A
39   1                                               byte AbstractWaitingConditionLhsPadding.r44        N/A
40   1                                               byte AbstractWaitingConditionLhsPadding.r45        N/A
41   1                                               byte AbstractWaitingConditionLhsPadding.r46        N/A
42   1                                               byte AbstractWaitingConditionLhsPadding.r47        N/A
43   1                                               byte AbstractWaitingConditionLhsPadding.r48        N/A
44   1                                               byte AbstractWaitingConditionLhsPadding.r51        N/A
45   1                                               byte AbstractWaitingConditionLhsPadding.r52        N/A
46   1                                               byte AbstractWaitingConditionLhsPadding.r53        N/A
47   1                                               byte AbstractWaitingConditionLhsPadding.r54        N/A
48   1                                               byte AbstractWaitingConditionLhsPadding.r55        N/A
49   1                                               byte AbstractWaitingConditionLhsPadding.r56        N/A
50   1                                               byte AbstractWaitingConditionLhsPadding.r57        N/A
51   1                                               byte AbstractWaitingConditionLhsPadding.r58        N/A
52   1                                               byte AbstractWaitingConditionLhsPadding.r61        N/A
53   1                                               byte AbstractWaitingConditionLhsPadding.r62        N/A
54   1                                               byte AbstractWaitingConditionLhsPadding.r63        N/A
55   1                                               byte AbstractWaitingConditionLhsPadding.r64        N/A
56   1                                               byte AbstractWaitingConditionLhsPadding.r65        N/A
57   1                                               byte AbstractWaitingConditionLhsPadding.r66        N/A
58   1                                               byte AbstractWaitingConditionLhsPadding.r67        N/A
59   1                                               byte AbstractWaitingConditionLhsPadding.r68        N/A
60   1                                               byte AbstractWaitingConditionLhsPadding.r71        N/A
61   1                                               byte AbstractWaitingConditionLhsPadding.r72        N/A
62   1                                               byte AbstractWaitingConditionLhsPadding.r73        N/A
63   1                                               byte AbstractWaitingConditionLhsPadding.r74        N/A
64   1                                               byte AbstractWaitingConditionLhsPadding.r75        N/A
65   1                                               byte AbstractWaitingConditionLhsPadding.r76        N/A
66   1                                               byte AbstractWaitingConditionLhsPadding.r77        N/A
67   1                                               byte AbstractWaitingConditionLhsPadding.r78        N/A
68   1                                               byte AbstractWaitingConditionLhsPadding.r81        N/A
69   1                                               byte AbstractWaitingConditionLhsPadding.r82        N/A
70   1                                               byte AbstractWaitingConditionLhsPadding.r83        N/A
71   1                                               byte AbstractWaitingConditionLhsPadding.r84        N/A
72   1                                               byte AbstractWaitingConditionLhsPadding.r85        N/A
73   1                                               byte AbstractWaitingConditionLhsPadding.r86        N/A
74   1                                               byte AbstractWaitingConditionLhsPadding.r87        N/A
75   1                                               byte AbstractWaitingConditionLhsPadding.r88        N/A
76   1                                               byte AbstractWaitingConditionLhsPadding.r91        N/A
77   1                                               byte AbstractWaitingConditionLhsPadding.r92        N/A
78   1                                               byte AbstractWaitingConditionLhsPadding.r93        N/A
79   1                                               byte AbstractWaitingConditionLhsPadding.r94        N/A
80   1                                               byte AbstractWaitingConditionLhsPadding.r95        N/A
81   1                                               byte AbstractWaitingConditionLhsPadding.r96        N/A
82   1                                               byte AbstractWaitingConditionLhsPadding.r97        N/A
83   1                                               byte AbstractWaitingConditionLhsPadding.r98        N/A
84   1                                               byte AbstractWaitingConditionLhsPadding.r101       N/A
85   1                                               byte AbstractWaitingConditionLhsPadding.r102       N/A
86   1                                               byte AbstractWaitingConditionLhsPadding.r103       N/A
87   1                                               byte AbstractWaitingConditionLhsPadding.r104       N/A
88   1                                               byte AbstractWaitingConditionLhsPadding.r105       N/A
89   1                                               byte AbstractWaitingConditionLhsPadding.r106       N/A
90   1                                               byte AbstractWaitingConditionLhsPadding.r107       N/A
91   1                                               byte AbstractWaitingConditionLhsPadding.r108       N/A
92   1                                               byte AbstractWaitingConditionLhsPadding.r111       N/A
93   1                                               byte AbstractWaitingConditionLhsPadding.r112       N/A
94   1                                               byte AbstractWaitingConditionLhsPadding.r113       N/A
95   1                                               byte AbstractWaitingConditionLhsPadding.r114       N/A
96   1                                               byte AbstractWaitingConditionLhsPadding.r115       N/A
97   1                                               byte AbstractWaitingConditionLhsPadding.r116       N/A
98   1                                               byte AbstractWaitingConditionLhsPadding.r117       N/A
99   1                                               byte AbstractWaitingConditionLhsPadding.r118       N/A
100   1                                               byte AbstractWaitingConditionLhsPadding.r121       N/A
101   1                                               byte AbstractWaitingConditionLhsPadding.r122       N/A
102   1                                               byte AbstractWaitingConditionLhsPadding.r123       N/A
103   1                                               byte AbstractWaitingConditionLhsPadding.r124       N/A
104   1                                               byte AbstractWaitingConditionLhsPadding.r125       N/A
105   1                                               byte AbstractWaitingConditionLhsPadding.r126       N/A
106   1                                               byte AbstractWaitingConditionLhsPadding.r127       N/A
107   1                                               byte AbstractWaitingConditionLhsPadding.r128       N/A
108   1                                               byte AbstractWaitingConditionLhsPadding.r131       N/A
109   1                                               byte AbstractWaitingConditionLhsPadding.r132       N/A
110   1                                               byte AbstractWaitingConditionLhsPadding.r133       N/A
111   1                                               byte AbstractWaitingConditionLhsPadding.r134       N/A
112   1                                               byte AbstractWaitingConditionLhsPadding.r135       N/A
113   1                                               byte AbstractWaitingConditionLhsPadding.r136       N/A
114   1                                               byte AbstractWaitingConditionLhsPadding.r137       N/A
115   1                                               byte AbstractWaitingConditionLhsPadding.r138       N/A
116   1                                               byte AbstractWaitingConditionLhsPadding.r141       N/A
117   1                                               byte AbstractWaitingConditionLhsPadding.r142       N/A
118   1                                               byte AbstractWaitingConditionLhsPadding.r143       N/A
119   1                                               byte AbstractWaitingConditionLhsPadding.r144       N/A
120   1                                               byte AbstractWaitingConditionLhsPadding.r145       N/A
121   1                                               byte AbstractWaitingConditionLhsPadding.r146       N/A
122   1                                               byte AbstractWaitingConditionLhsPadding.r147       N/A
123   1                                               byte AbstractWaitingConditionLhsPadding.r148       N/A
124   1                                               byte AbstractWaitingConditionLhsPadding.r151       N/A
125   1                                               byte AbstractWaitingConditionLhsPadding.r152       N/A
126   1                                               byte AbstractWaitingConditionLhsPadding.r153       N/A
127   1                                               byte AbstractWaitingConditionLhsPadding.r154       N/A
128   1                                               byte AbstractWaitingConditionLhsPadding.r155       N/A
129   1                                               byte AbstractWaitingConditionLhsPadding.r156       N/A
130   1                                               byte AbstractWaitingConditionLhsPadding.r157       N/A
131   1                                               byte AbstractWaitingConditionLhsPadding.r158       N/A
132   1                                               byte AbstractWaitingConditionRhsPadding.c11        N/A
133   1                                               byte AbstractWaitingConditionRhsPadding.c12        N/A
134   1                                               byte AbstractWaitingConditionRhsPadding.c13        N/A
135   1                                               byte AbstractWaitingConditionRhsPadding.c14        N/A
136   8                                               long AbstractWaitingConditionWaitCache.waitCache   N/A
144   1                                               byte AbstractWaitingConditionRhsPadding.c15        N/A
145   1                                               byte AbstractWaitingConditionRhsPadding.c16        N/A
146   1                                               byte AbstractWaitingConditionRhsPadding.c17        N/A
147   1                                               byte AbstractWaitingConditionRhsPadding.c18        N/A
148   1                                               byte AbstractWaitingConditionRhsPadding.c21        N/A
149   1                                               byte AbstractWaitingConditionRhsPadding.c22        N/A
150   1                                               byte AbstractWaitingConditionRhsPadding.c23        N/A
151   1                                               byte AbstractWaitingConditionRhsPadding.c24        N/A
152   1                                               byte AbstractWaitingConditionRhsPadding.c25        N/A
153   1                                               byte AbstractWaitingConditionRhsPadding.c26        N/A
154   1                                               byte AbstractWaitingConditionRhsPadding.c27        N/A
155   1                                               byte AbstractWaitingConditionRhsPadding.c28        N/A
156   1                                               byte AbstractWaitingConditionRhsPadding.c31        N/A
157   1                                               byte AbstractWaitingConditionRhsPadding.c32        N/A
158   1                                               byte AbstractWaitingConditionRhsPadding.c33        N/A
159   1                                               byte AbstractWaitingConditionRhsPadding.c34        N/A
160   1                                               byte AbstractWaitingConditionRhsPadding.c35        N/A
161   1                                               byte AbstractWaitingConditionRhsPadding.c36        N/A
162   1                                               byte AbstractWaitingConditionRhsPadding.c37        N/A
163   1                                               byte AbstractWaitingConditionRhsPadding.c38        N/A
164   1                                               byte AbstractWaitingConditionRhsPadding.c41        N/A
165   1                                               byte AbstractWaitingConditionRhsPadding.c42        N/A
166   1                                               byte AbstractWaitingConditionRhsPadding.c43        N/A
167   1                                               byte AbstractWaitingConditionRhsPadding.c44        N/A
168   1                                               byte AbstractWaitingConditionRhsPadding.c45        N/A
169   1                                               byte AbstractWaitingConditionRhsPadding.c46        N/A
170   1                                               byte AbstractWaitingConditionRhsPadding.c47        N/A
171   1                                               byte AbstractWaitingConditionRhsPadding.c48        N/A
172   1                                               byte AbstractWaitingConditionRhsPadding.c51        N/A
173   1                                               byte AbstractWaitingConditionRhsPadding.c52        N/A
174   1                                               byte AbstractWaitingConditionRhsPadding.c53        N/A
175   1                                               byte AbstractWaitingConditionRhsPadding.c54        N/A
176   1                                               byte AbstractWaitingConditionRhsPadding.c55        N/A
177   1                                               byte AbstractWaitingConditionRhsPadding.c56        N/A
178   1                                               byte AbstractWaitingConditionRhsPadding.c57        N/A
179   1                                               byte AbstractWaitingConditionRhsPadding.c58        N/A
180   1                                               byte AbstractWaitingConditionRhsPadding.c61        N/A
181   1                                               byte AbstractWaitingConditionRhsPadding.c62        N/A
182   1                                               byte AbstractWaitingConditionRhsPadding.c63        N/A
183   1                                               byte AbstractWaitingConditionRhsPadding.c64        N/A
184   1                                               byte AbstractWaitingConditionRhsPadding.c65        N/A
185   1                                               byte AbstractWaitingConditionRhsPadding.c66        N/A
186   1                                               byte AbstractWaitingConditionRhsPadding.c67        N/A
187   1                                               byte AbstractWaitingConditionRhsPadding.c68        N/A
188   1                                               byte AbstractWaitingConditionRhsPadding.c71        N/A
189   1                                               byte AbstractWaitingConditionRhsPadding.c72        N/A
190   1                                               byte AbstractWaitingConditionRhsPadding.c73        N/A
191   1                                               byte AbstractWaitingConditionRhsPadding.c74        N/A
192   1                                               byte AbstractWaitingConditionRhsPadding.c75        N/A
193   1                                               byte AbstractWaitingConditionRhsPadding.c76        N/A
194   1                                               byte AbstractWaitingConditionRhsPadding.c77        N/A
195   1                                               byte AbstractWaitingConditionRhsPadding.c78        N/A
196   1                                               byte AbstractWaitingConditionRhsPadding.c81        N/A
197   1                                               byte AbstractWaitingConditionRhsPadding.c82        N/A
198   1                                               byte AbstractWaitingConditionRhsPadding.c83        N/A
199   1                                               byte AbstractWaitingConditionRhsPadding.c84        N/A
200   1                                               byte AbstractWaitingConditionRhsPadding.c85        N/A
201   1                                               byte AbstractWaitingConditionRhsPadding.c86        N/A
202   1                                               byte AbstractWaitingConditionRhsPadding.c87        N/A
203   1                                               byte AbstractWaitingConditionRhsPadding.c88        N/A
204   1                                               byte AbstractWaitingConditionRhsPadding.c91        N/A
205   1                                               byte AbstractWaitingConditionRhsPadding.c92        N/A
206   1                                               byte AbstractWaitingConditionRhsPadding.c93        N/A
207   1                                               byte AbstractWaitingConditionRhsPadding.c94        N/A
208   1                                               byte AbstractWaitingConditionRhsPadding.c95        N/A
209   1                                               byte AbstractWaitingConditionRhsPadding.c96        N/A
210   1                                               byte AbstractWaitingConditionRhsPadding.c97        N/A
211   1                                               byte AbstractWaitingConditionRhsPadding.c98        N/A
212   1                                               byte AbstractWaitingConditionRhsPadding.c101       N/A
213   1                                               byte AbstractWaitingConditionRhsPadding.c102       N/A
214   1                                               byte AbstractWaitingConditionRhsPadding.c103       N/A
215   1                                               byte AbstractWaitingConditionRhsPadding.c104       N/A
216   1                                               byte AbstractWaitingConditionRhsPadding.c105       N/A
217   1                                               byte AbstractWaitingConditionRhsPadding.c106       N/A
218   1                                               byte AbstractWaitingConditionRhsPadding.c107       N/A
219   1                                               byte AbstractWaitingConditionRhsPadding.c108       N/A
220   1                                               byte AbstractWaitingConditionRhsPadding.c111       N/A
221   1                                               byte AbstractWaitingConditionRhsPadding.c112       N/A
222   1                                               byte AbstractWaitingConditionRhsPadding.c113       N/A
223   1                                               byte AbstractWaitingConditionRhsPadding.c114       N/A
224   1                                               byte AbstractWaitingConditionRhsPadding.c115       N/A
225   1                                               byte AbstractWaitingConditionRhsPadding.c116       N/A
226   1                                               byte AbstractWaitingConditionRhsPadding.c117       N/A
227   1                                               byte AbstractWaitingConditionRhsPadding.c118       N/A
228   1                                               byte AbstractWaitingConditionRhsPadding.c121       N/A
229   1                                               byte AbstractWaitingConditionRhsPadding.c122       N/A
230   1                                               byte AbstractWaitingConditionRhsPadding.c123       N/A
231   1                                               byte AbstractWaitingConditionRhsPadding.c124       N/A
232   1                                               byte AbstractWaitingConditionRhsPadding.c125       N/A
233   1                                               byte AbstractWaitingConditionRhsPadding.c126       N/A
234   1                                               byte AbstractWaitingConditionRhsPadding.c127       N/A
235   1                                               byte AbstractWaitingConditionRhsPadding.c128       N/A
236   1                                               byte AbstractWaitingConditionRhsPadding.c131       N/A
237   1                                               byte AbstractWaitingConditionRhsPadding.c132       N/A
238   1                                               byte AbstractWaitingConditionRhsPadding.c133       N/A
239   1                                               byte AbstractWaitingConditionRhsPadding.c134       N/A
240   1                                               byte AbstractWaitingConditionRhsPadding.c135       N/A
241   1                                               byte AbstractWaitingConditionRhsPadding.c136       N/A
242   1                                               byte AbstractWaitingConditionRhsPadding.c137       N/A
243   1                                               byte AbstractWaitingConditionRhsPadding.c138       N/A
244   1                                               byte AbstractWaitingConditionRhsPadding.c141       N/A
245   1                                               byte AbstractWaitingConditionRhsPadding.c142       N/A
246   1                                               byte AbstractWaitingConditionRhsPadding.c143       N/A
247   1                                               byte AbstractWaitingConditionRhsPadding.c144       N/A
248   1                                               byte AbstractWaitingConditionRhsPadding.c145       N/A
249   1                                               byte AbstractWaitingConditionRhsPadding.c146       N/A
250   1                                               byte AbstractWaitingConditionRhsPadding.c147       N/A
251   1                                               byte AbstractWaitingConditionRhsPadding.c148       N/A
252   1                                               byte AbstractWaitingConditionRhsPadding.c151       N/A
253   1                                               byte AbstractWaitingConditionRhsPadding.c152       N/A
254   1                                               byte AbstractWaitingConditionRhsPadding.c153       N/A
255   1                                               byte AbstractWaitingConditionRhsPadding.c154       N/A
256   1                                               byte AbstractWaitingConditionRhsPadding.c155       N/A
257   1                                               byte AbstractWaitingConditionRhsPadding.c156       N/A
258   1                                               byte AbstractWaitingConditionRhsPadding.c157       N/A
259   1                                               byte AbstractWaitingConditionRhsPadding.c158       N/A
260   1                                               byte AbstractWaitingConditionRhsPadding.c161       N/A
261   1                                               byte AbstractWaitingConditionRhsPadding.c162       N/A
262   1                                               byte AbstractWaitingConditionRhsPadding.c163       N/A
263   1                                               byte AbstractWaitingConditionRhsPadding.c164       N/A
264   1                                               byte AbstractWaitingConditionRhsPadding.c165       N/A
265   1                                               byte AbstractWaitingConditionRhsPadding.c166       N/A
266   1                                               byte AbstractWaitingConditionRhsPadding.c167       N/A
267   1                                               byte AbstractWaitingConditionRhsPadding.c168       N/A
268   4              java.util.concurrent.atomic.LongAdder AbstractWaitingCondition.waitCount            N/A
272   4   java.util.concurrent.atomic.AtomicReferenceArray AbstractWaitingCondition.waiter               N/A
276   4                                                    (object alignment gap)                        
Instance size: 280 bytes
Space losses: 0 bytes internal + 4 bytes external = 4 bytes total

The new AbstractWaitingCondition looks almost good.

130   1      byte AbstractWaitingConditionLhsPadding.r157       N/A
131   1      byte AbstractWaitingConditionLhsPadding.r158       N/A
132   1      byte AbstractWaitingConditionRhsPadding.c11        N/A
133   1      byte AbstractWaitingConditionRhsPadding.c12        N/A
134   1      byte AbstractWaitingConditionRhsPadding.c13        N/A
135   1      byte AbstractWaitingConditionRhsPadding.c14        N/A
136   8      long AbstractWaitingConditionWaitCache.waitCache   N/A
144   1      byte AbstractWaitingConditionRhsPadding.c15        N/A
145   1      byte AbstractWaitingConditionRhsPadding.c16        N/A

The only remaining quirk is that waitCache is not exactly squished inbetween the two paddings, but instead slightly shifted.

I assume this is because of the following mentioned issue in the JMH comment, which I still have to investigate.

we might need more padding to account for "lost", padding fields pulled into in their superclass gaps

``PushPullConcurrentQueueandMultithreadConcurrentQueue``` show exactly the same behaviour, as seen in the attachment

pr_jdk22.txt
master_jdk22.txt

@lokok8 lokok8 changed the title use bytes for false-sharing padding inheritance based padding Sep 17, 2024
@jac18281828
Copy link
Collaborator

@lokok8 thank you for the fantastic and detailed write up this is super helpful.

  1. MPMCConcurrentQueue$Cell (master, JDK22) - can be ignored or field padding removed. The entry will not be contended because of the use of ContendedAtomicLong. That is overkill and I lean toward removal. Seq (ref) is never written so it will not result in false sharing.

  2. Again I am calling byte padding here 'over kill' on my part. waiter is an array of sufficient size to avoid sharing. waiter (ref) is never updated and therefore will never contend with waitCache. waitCount, waiter and waitCache should all have separate memory at allocation time. Padding here should be removed to save memory.

  3. I like the field based approach using the inheritance to work around the layout issues. Contended is another options but is somewhat problematic in that it is an internal annotation. I am okay with either solution as they both appear to have about the same complexity and problem space associated with the optimization benefit.

I'd say those changes are good enough to change this to a regular pr and we can do a final round of benchmarking and certification and it would be good to merge.

@lokok8
Copy link
Contributor Author

lokok8 commented Oct 11, 2024

Thank you for your feedback, I'll get to it sometime in the early part of next week.

@lokok8 lokok8 force-pushed the byte-padding branch 2 times, most recently from e225c1d to 5e4c9d3 Compare October 16, 2024 14:11
@lokok8
Copy link
Contributor Author

lokok8 commented Oct 16, 2024

@jac18281828, I hope you don't mind me force pushing the changes.

I removed the field padding in MPMCConcurrentQueue$Cell and also in AbstractWaitingCondition. If I understood your second bullet point correctly, you are talking about AbstractWaitingCondition specifically? Please let me know if that is not the case.

sumToAvoidOptimization() is now formatted to be single column - I agree that it works better. Unfortunately all of these padding variables are quite unwieldy 😄 .

@lokok8 lokok8 marked this pull request as ready for review October 16, 2024 14:22
Copy link
Collaborator

@jac18281828 jac18281828 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this looks good. Thank you for all your help. I will test and merge today if it passes.

🎉🔥

@jac18281828
Copy link
Collaborator

I did not perform a super scientific benchmark but I did sanity check. I'd say the results are neutral to positive. In particular I notice a nice performance improvement in the highly contended multi thread case. I believe the changes in the single thread performance are within the error bounds and therefore of no significance. I also note an improvement in ARM performance although this project was never intended for ARM and LMAX seems like a much better solution on that platform architecture.

Nice work! ⛏️🚀

Standard benchmark (1.2.22) - no changes

16 core M3 Max (AARCH64) MacBook Pro

Benchmark                                       Mode  Cnt     Score     Error  Units
ArrayBlockingQueueBenchmark.sendOneM            avgt   15    78.717 ?  13.735  ms/op
ArrayBlockingQueueBenchmark.sendOneMWaiting     avgt   15    36.801 ?   1.114  ms/op
DisruptorBlockingQueueBenchmark.addOneM         avgt   15    47.153 ?   0.722  ms/op
DisruptorBlockingQueueBenchmark.addOneMNThread  avgt   15  1446.343 ? 131.524  ms/op
DisruptorBlockingQueueBenchmark.addOneMWaiting  avgt   15    37.967 ?   2.383  ms/op
LMAXDisruptorBenchmark.addOneM                  avgt   15    14.730 ?   1.629  ms/op
LMAXDisruptorPushPullBenchmark.addOneM          avgt   15    13.525 ?   0.612  ms/op
LinkedBlockingQueueBenchmark.sendOneM           avgt   15    99.522 ?  24.730  ms/op
LinkedBlockingQueueBenchmark.sendOneMWaiting    avgt   15    74.779 ?  10.835  ms/op
LinkedTransferQueueBenchmark.sendOneM           avgt   15    25.129 ?   1.179  ms/op
LinkedTransferQueueBenchmark.sendOneMWaiting    avgt   15    22.483 ?   0.684  ms/op
MPMCBlockingQueueBenchmark.addOneM              avgt   15     6.747 ?   0.113  ms/op
MPMCBlockingQueueBenchmark.addOneMNThread       avgt   15  2140.811 ? 313.584  ms/op
MPMCBlockingQueueBenchmark.addOneMWaiting       avgt   15     6.923 ?   0.099  ms/op
PushPullBlockingQueueBenchmark.sendOneM         avgt   15    34.710 ?   2.031  ms/op
PushPullBlockingQueueBenchmark.sendOneMWaiting  avgt   15    56.499 ?   1.766  ms/op


4 core Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz
RAM 16gb

Benchmark                                       Mode  Cnt    Score     Error  Units
ArrayBlockingQueueBenchmark.sendOneM            avgt   15  315.258 ±  36.928  ms/op
ArrayBlockingQueueBenchmark.sendOneMWaiting     avgt   15  262.610 ±  57.522  ms/op
DisruptorBlockingQueueBenchmark.addOneM         avgt   15   55.379 ±  19.726  ms/op
DisruptorBlockingQueueBenchmark.addOneMNThread  avgt   15  914.995 ± 389.736  ms/op
DisruptorBlockingQueueBenchmark.addOneMWaiting  avgt   15   70.769 ±  30.516  ms/op
LMAXDisruptorBenchmark.addOneM                  avgt   15  114.867 ±  13.912  ms/op
LMAXDisruptorPushPullBenchmark.addOneM          avgt   15   46.827 ±   7.246  ms/op
LinkedBlockingQueueBenchmark.sendOneM           avgt   15  379.783 ± 206.856  ms/op
LinkedBlockingQueueBenchmark.sendOneMWaiting    avgt   15  257.589 ±  58.619  ms/op
LinkedTransferQueueBenchmark.sendOneM           avgt   15  140.403 ±  33.544  ms/op
LinkedTransferQueueBenchmark.sendOneMWaiting    avgt   15  169.149 ±  41.117  ms/op
MPMCBlockingQueueBenchmark.addOneM              avgt   15   51.677 ±   6.406  ms/op
MPMCBlockingQueueBenchmark.addOneMNThread       avgt   15  385.027 ±  30.777  ms/op
MPMCBlockingQueueBenchmark.addOneMWaiting       avgt   15   49.708 ±   7.932  ms/op
PushPullBlockingQueueBenchmark.sendOneM         avgt   15  179.232 ±  32.487  ms/op
PushPullBlockingQueueBenchmark.sendOneMWaiting  avgt   15  160.854 ±  20.096  ms/op


Updated byte padding

16 core M3 Max (AARCH64) MacBook Pro

# Run complete. Total time: 00:06:38

Benchmark                                       Mode  Cnt     Score     Error  Units
ArrayBlockingQueueBenchmark.sendOneM            avgt   15    97.925 ?   8.332  ms/op
ArrayBlockingQueueBenchmark.sendOneMWaiting     avgt   15    34.298 ?   0.736  ms/op
DisruptorBlockingQueueBenchmark.addOneM         avgt   15    23.422 ?   3.908  ms/op
DisruptorBlockingQueueBenchmark.addOneMNThread  avgt   15   818.751 ? 105.817  ms/op
DisruptorBlockingQueueBenchmark.addOneMWaiting  avgt   15    37.621 ?   0.796  ms/op
LMAXDisruptorBenchmark.addOneM                  avgt   15    14.800 ?   0.485  ms/op
LMAXDisruptorPushPullBenchmark.addOneM          avgt   15    13.883 ?   0.363  ms/op
LinkedBlockingQueueBenchmark.sendOneM           avgt   15    72.898 ?  27.302  ms/op
LinkedBlockingQueueBenchmark.sendOneMWaiting    avgt   15    89.593 ?  12.666  ms/op
LinkedTransferQueueBenchmark.sendOneM           avgt   15    25.004 ?   0.430  ms/op
LinkedTransferQueueBenchmark.sendOneMWaiting    avgt   15    21.850 ?   0.550  ms/op
MPMCBlockingQueueBenchmark.addOneM              avgt   15    12.294 ?   0.142  ms/op
MPMCBlockingQueueBenchmark.addOneMNThread       avgt   15  1112.766 ?  84.219  ms/op
MPMCBlockingQueueBenchmark.addOneMWaiting       avgt   15    15.887 ?   0.225  ms/op
PushPullBlockingQueueBenchmark.sendOneM         avgt   15    36.343 ?   3.899  ms/op
PushPullBlockingQueueBenchmark.sendOneMWaiting  avgt   15    55.108 ?   7.115  ms/op

4 core Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz
RAM 16gb


Benchmark                                       Mode  Cnt    Score     Error  Units
ArrayBlockingQueueBenchmark.sendOneM            avgt   15  348.456 ±  43.982  ms/op
ArrayBlockingQueueBenchmark.sendOneMWaiting     avgt   15  269.750 ±  51.663  ms/op
DisruptorBlockingQueueBenchmark.addOneM         avgt   15   70.440 ±  19.453  ms/op
DisruptorBlockingQueueBenchmark.addOneMNThread  avgt   15  736.397 ± 338.496  ms/op
DisruptorBlockingQueueBenchmark.addOneMWaiting  avgt   15   72.977 ±  39.717  ms/op
LMAXDisruptorBenchmark.addOneM                  avgt   15  108.534 ±  17.603  ms/op
LMAXDisruptorPushPullBenchmark.addOneM          avgt   15   45.895 ±   9.540  ms/op
LinkedBlockingQueueBenchmark.sendOneM           avgt   15  178.702 ±  35.551  ms/op
LinkedBlockingQueueBenchmark.sendOneMWaiting    avgt   15  215.844 ±  42.241  ms/op
LinkedTransferQueueBenchmark.sendOneM           avgt   15  132.198 ±  33.980  ms/op
LinkedTransferQueueBenchmark.sendOneMWaiting    avgt   15  115.969 ±  16.208  ms/op
MPMCBlockingQueueBenchmark.addOneM              avgt   15   42.388 ±   8.679  ms/op
MPMCBlockingQueueBenchmark.addOneMNThread       avgt   15  375.047 ±  32.054  ms/op
MPMCBlockingQueueBenchmark.addOneMWaiting       avgt   15   40.780 ±   4.697  ms/op
PushPullBlockingQueueBenchmark.sendOneM         avgt   15  181.913 ±  22.893  ms/op
PushPullBlockingQueueBenchmark.sendOneMWaiting  avgt   15  144.750 ±  21.253  ms/op

@jac18281828 jac18281828 merged commit ec6889f into conversant:master Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants