JDK-8306000 : Add experimental -XX:+UseCompactObjectHeaders flag
  • Type: CSR
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Closed
  • Resolution: Withdrawn
  • Fix Versions: tbd
  • Submitted: 2023-04-14
  • Updated: 2024-09-17
  • Resolved: 2024-09-17
Related Reports
CSR :  
Description
Summary
-------

Add an experimental flag -XX:[+|-]UseCompactObjectHeaders that enables compact object headers.

Problem
-------

Compact Object Headers (JDK-8294992) implement a new, smaller object header layout, which significantly reduces memory requirements of Java applications running in the HotSpot JVM. In order to provide extra safety in the evolution of the HotSpot JVM, the new header layout should be guarded by an experimental flag, and the existing header layout retained when that flag is turned off.

Solution
--------

Add an experimental flag -XX:[+|-]CompactObjectHeaders, which is off by default. By enabling the feature, users can benefit from reduced memory requirements for their Java applications. When the flag is turned off, the existing legacy header layout is used. We plan to enable the flag by default in a future release once we are sufficiently confident in its stability, feature completeness, and benefits. Eventually, in an even more distant release, the flag will get removed, together with the legacy implementation.

Specification
-------------

```
diff a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp
--- a/src/hotspot/share/runtime/globals.hpp
+++ b/src/hotspot/share/runtime/globals.hpp
@@ -123,14 +123,17 @@
                                                                             \
   product(bool, UseCompressedOops, false,                                   \
           "Use 32-bit object references in 64-bit VM. "                     \
           "lp64_product means flag is always constant in 32 bit VM")        \
                                                                             \
   product(bool, UseCompressedClassPointers, false,                          \
           "Use 32-bit class pointers in 64-bit VM. "                        \
           "lp64_product means flag is always constant in 32 bit VM")        \
                                                                             \
+  product(bool, UseCompactObjectHeaders, false, EXPERIMENTAL,               \
+          "Use compact 64-bit object headers in 64-bit VM")                 \
+                                                                            \
   product(int, ObjectAlignmentInBytes, 8,                                   \
           "Default object alignment in bytes, 8 is minimum")                \
           range(8, 256)                                                     \
           constraint(ObjectAlignmentInBytesConstraintFunc, AtParse)
 
```

Comments
Since CSR is not necessary for new experimental flags, I would like to withdraw this CSR. However, I can't seem to find a 'withdraw' or 'close' action/button? How can I withdraw the CSR?
17-09-2024

Administratively, moving to Provisional.
02-05-2023

"experimental" flags do not need an approved CSR request. If at some point in the future the behaviour of the JVM changes due to the default value of this flag, then that behavioural change would require a CSR request.
01-05-2023

[~stuefe] Isn't this what I'm saying here? "there should only be no user-observable differences, besides performance changes" ? I don't intend to ever make the flag non-experimental. At some point the same flag will cover the 32bit headers, then at some later point the flag will be on-by-default, and even later the flag would go away entirely.
28-04-2023

I'm unsure about "compatibility risk". In my view, the compatibility risk is zero since this is an experimental opt-in feature, and the default behavior of the JVM would not be changed. We will need another CSR when we enable the flag by default (and remove its experimental status at the same time).
28-04-2023

> product(bool, UseCompactObjectHeaders, true, EXPERIMENTAL, Should be "false".
15-04-2023