RFR: 7903910: JMH: Strengthen manual hierarchical padding

Claes Redestad redestad at openjdk.org
Sun Dec 15 19:26:50 UTC 2024


On Fri, 13 Dec 2024 17:34:24 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> We pad with `byte`-s deliberately to avoid exposing any holes in superclasses that can be taken by subclass fields with JDK 15+ field layouter: https://shipilev.net/jvm/objects-inside-out/#_observation_hierarchy_tower_padding_trick_collapse_in_jdk_15 :)

Ah, what fun!

Yet I couldn't help thinking it might be enough to emit just enough `byte`s to fill out any such padding gaps in the enclosing class? That would means maximum 8 internal + 8 external padding bytes on 64-bit aligned VMs, so 16 bytes. Then fill up the rest with `long`s. I set up an experiment (https://github.com/openjdk/jmh/pull/147) and see a ~20% reduction in jmh-samples code size with this.

Maybe something to consider in light of https://bugs.openjdk.org/browse/JDK-8345302

-------------

PR Comment: https://git.openjdk.org/jmh/pull/146#issuecomment-2544012657


More information about the jmh-dev mailing list