Skip to content

Accommodate changes in Java 15 object layout #2057

@simonbasle

Description

@simonbasle

The way fields are laid out is changing in Java 15, allowing fields from a sub-class to be stored in the unused space of a super-class's field (and breaking the assumption that fields of a sub-class are always laid out after all the fields of the super class).

See https://bugs.openjdk.java.net/browse/JDK-8237767

This can have an impact on the low-level classes that introduce artificial padding to avoid false sharing, like QueueDrainSubscriber or most classes in the reactor.util.concurrent package.

Note that the behavior in question can be manually disabled using a new VM option -XX:-UseEmptySlotsInSupers.

@Contested isn't an option as of JDK 9 due to its sun.misc nature.

The only current durable solution on our side to ensure no false sharing seems to be using the inheritance of padding classes trick, but with boolean padding fields instead of long. This is because on a boolean, you cannot have "unused" space, as the smallest boolean takes as much space as the largest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/java9This belongs to the java9 compatibility themearea/performanceThis belongs to the performance themetype/enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions