A DESCRIPTION OF THE PROBLEM : When using -XX:ContendedPaddingWidth=256 the argument has no effect on the padding of the Thread and ConcurrentHashMap$CounterCell class. No impact on the tlr contended group using in Thread for the threadLocalRandomSeed, threadLocalRandomProbe and threadLocalRandomSecondarySeed If I use Unsafe to print the field offsets what I get is: Memory layout for: java.lang.Thread field=priority, offset=12, field type=int field=eetop, offset=16, field type=long field=stackSize, offset=24, field type=long field=tid, offset=32, field type=long field=threadStatus, offset=40, field type=int field=daemon, offset=44, field type=boolean field=interrupted, offset=45, field type=boolean field=stillborn, offset=46, field type=boolean field=name, offset=48, field type=java.lang.String field=target, offset=52, field type=java.lang.Runnable field=group, offset=56, field type=java.lang.ThreadGroup field=contextClassLoader, offset=60, field type=java.lang.ClassLoader field=inheritedAccessControlContext, offset=64, field type=java.security.AccessControlContext field=threadLocals, offset=68, field type=java.lang.ThreadLocal$ThreadLocalMap field=inheritableThreadLocals, offset=72, field type=java.lang.ThreadLocal$ThreadLocalMap field=parkBlocker, offset=76, field type=java.lang.Object field=blocker, offset=80, field type=sun.nio.ch.Interruptible field=blockerLock, offset=84, field type=java.lang.Object field=uncaughtExceptionHandler, offset=88, field type=java.lang.Thread$UncaughtExceptionHandler field=threadLocalRandomSeed, offset=224, field type=long field=threadLocalRandomProbe, offset=232, field type=int field=threadLocalRandomSecondarySeed, offset=236, field type=int We can see that threadLocalRandomSeed offest is 224 which means: 88 (uncaughtExceptionHandler offset) + 4 (reference size) + 4 (block alignment) + 128 (contended padding) I believe that the same problem can happen with ConcurrentHashMap$CounterCell but weirdly not with Striped64$Cell. I did not observe that problem on Java 8 and 11 REGRESSION : Last worked in version 11.0.19 STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : * Start the JVM with -XX:ContendedPaddingWidth=256 * Instantiate a Thread class * Look at the field offsets EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - The padding surrounding the the threadLocalRandomSeed, threadLocalRandomProbe and threadLocalRandomSecondarySeed fields should be 256 before and 256 after. ACTUAL - The padding stay 128 which is the default value FREQUENCY : always
|