JEP 519:紧凑对象头
JEP 519: Compact Object Headers

原始链接: https://openjdk.org/jeps/519

本提案旨在将紧凑对象头(Compact Object Headers)从实验性功能升级为 JDK 25 中完全支持的产品功能。紧凑对象头通过 JEP 450 在 JDK 24 中引入,它提供了一种旨在提高性能的替代对象头布局。Oracle 和亚马逊的广泛测试,包括在 JDK 21 和 JDK 17 反向移植版本上的生产部署,已经证明了其稳定性和性能优势。将其升级为产品功能将不再需要 `-XX:+UnlockExperimentalVMOptions` 标志。本提案承认未来可能需要额外的头位,并指出了为 Valhalla 项目保留的位,以及利用 Lilliput 项目技术调整压缩类指针和身份哈希码的可能性。由于之前进行了严格的评估,因此认为无需进一步测试。

JEP 519 promotes Compact Object Headers in OpenJDK from experimental to a product feature, aiming for memory footprint reduction and performance improvements. Previous experimental versions (JEP 450) have been tested extensively at Oracle and Amazon, demonstrating positive performance results, including a 10% improvement in JSON parsing. Despite the promising results, Compact Object Headers won't be enabled by default. This cautious approach is typical in the JVM world due to concerns about potential compatibility issues. Enabling it still requires specific flags. One commenter inquired about its impact on GraalVM Native Image, but another clarified it primarily affects the HotSpot JVM, and Native Image likely already uses smaller headers. Making it non-experimental simply means it is ready for product use, not that it will become the default behavior.

原文
OwnerRoman Kennke
TypeFeature
ScopeImplementation
StatusTargeted
Release25
Componenthotspot / runtime
Discussionhotspot dash dev at openjdk dot org
EffortS
DurationXS
Relates toJEP 450: Compact Object Headers (Experimental)
Reviewed byColeen Phillimore, Stefan Karlsson, Vladimir Kozlov
Endorsed byVladimir Kozlov
Created2025/04/15 14:01
Updated2025/05/21 16:18
Issue8354672

Summary

Change compact object headers from an experimental feature to a product feature.

Non-Goals

It is not a goal to make compact object headers be the default object-header layout.

Motivation

Compact object headers were introduced as an alternative object-header layout by JEP 450 in JDK 24. Features of this size are best introduced carefully and gradually, so we introduced it as an experimental feature.

Since JDK 24, compact object headers have proven their stability and performance.

They have been tested at Oracle by running the full JDK test suite. They have also been tested at Amazon by hundreds of services in production, most of them using backports of the feature to JDK 21 and JDK 17.

Various experiments demonstrate that enabling compact object headers improves performance:

It is time to change compact object headers from an experimental feature to a product feature.

Description

Compact object headers are enabled in JDK 24 via the command-line options

$ java -XX:+UnlockExperimentalVMOptions -XX:+UseCompactObjectHeaders ...

The first option, -XX:+UnlockExperimentalVMOptions, will no longer be needed once they are a product feature.

Testing

Compact object headers were subjected to massive testing as part of JEP 450, in addition to the testing mentioned above. No further testing is required.

Some tests currently supply the -XX:+UnlockExperimentalVMOptions command-line option when enabling compact object headers. This will no longer be needed, so we will adjust these tests accordingly.

Risks and Assumptions

As discussed in JEP 450, future features may require additional object-header bits. We have already reserved four bits for Project Valhalla. If a need for even more bits arises then we can shrink compressed class pointers and identity hash codes even further, using techniques we have already prototyped in Project Lilliput.

联系我们 contact @ memedata.com