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

Accommodate changes in Java 15 object layout #2057

Closed
simonbasle opened this issue Feb 26, 2020 · 2 comments
Closed

Accommodate changes in Java 15 object layout #2057

simonbasle opened this issue Feb 26, 2020 · 2 comments
Labels
area/java9 This belongs to the java9 compatibility theme area/performance This belongs to the performance theme type/enhancement A general enhancement
Milestone

Comments

@simonbasle
Copy link
Member

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.

@simonbasle simonbasle added type/enhancement A general enhancement area/java9 This belongs to the java9 compatibility theme area/performance This belongs to the performance theme labels Feb 26, 2020
@simonbasle simonbasle added this to the Backlog milestone Feb 26, 2020
@akarnokd
Copy link
Contributor

I bet @nitsanw will love this JDK change.

@simonbasle simonbasle modified the milestones: 3.4.x Backlog, 3.6 planning Sep 9, 2021
@simonbasle
Copy link
Member Author

obi-wan-@nitsanw you are my only hope. in the Java 17 timeline, is there a recommendation to avoid false sharing?

I've struggled to replace 15 long padding fields with 120 byte/boolean padding fields.
While experimenting I was looking at the layout with JOL (in a test) and it didn't seem to help...
That said I might have made some mistake in the process.

I wonder, is -XX:-RestrictContented that much impractical for libraries like us?

We could maybe add diagnostic code that checks if RestrictContented is lifted via the RuntimeMXBean and warn users of perf impact via a WARN log otherwise? 🤔

@simonbasle simonbasle added the help wanted We need contributions on this label Sep 9, 2021
@chemicL chemicL removed this from the 3.6 planning milestone Mar 15, 2024
@chemicL chemicL removed the help wanted We need contributions on this label Mar 15, 2024
@chemicL chemicL added this to the 3.4.23 milestone Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/java9 This belongs to the java9 compatibility theme area/performance This belongs to the performance theme type/enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants