Value Classes Heap Flattening - What to expect from JEP 401
summary
JEP 401 brings value classes that are identity-less and mostly immutable, enabling heap flattening that reduces headers and indirection to improve memory density and GC work; a prototype shows 40M-node binary tree: 4.5s → 2s when C2 and flat arrays align with access patterns. Practical limits include layout padding and a required null marker byte, atomic updates limited to machine-atomic sizes, and runtime gaps where interpreter/C1 require heap buffering while atomic ops ≤64 bits constrain which values get flattened.
AI-written summary · about
chapters (21)
- 0:00Heap flattening intro and JEP 401
- 1:25Why flattening isn’t default
- 3:10Memory and GC benefits
- 6:04Performance with flattened arrays
- 8:11When heap flattening helps and when it doesn’t
- 9:17JEP 401 value class changes
- 10:01Non-atomicity and tearing
- 12:49Atomicity trade-offs
- 14:11Nullability impact
- 16:02JVM preloading value classes
- 17:24Flattened value layouts
- 19:10Avoiding unused layout costs
- 21:19VM support for new layouts
- 22:23Array flattening limits
- 23:05Null overhead alternatives
- 24:31Future beyond JEP 401
- 25:56Q&A: Profiling access patterns
- 27:23Q&A: Sealed interfaces flattening
- 27:45Q&A: Heap buffering C1/interpreter
- 29:31Q&A: Residual pointers C1/C2
- 30:17Q&A: Tearing in locked programs
related talks
20mCache Me If You Can: Speed Up Your JVM with Project Valhalla
45mMinimal Values Under the Hood
51mProject Valhalla: Flat Value Types in Java
52mValue Objects in Valhalla
57mJava Value Types: what is it and why are they important
56mValhalla Nullness Emotion
47mValue Objects - The Next Big Thing in Java
55mNew Bytecodes, New Objects
