Project Valhalla: Flat Value Types in Java
summary
Project Valhalla adds a new value modifier so small data classes flatten like primitives, removing per-instance heap headers; a 100M-point Brownian demo shows 100M allocations become zero (3 GB -> ~24 MB) and a tuned benchmark yields about 50% faster execution when allocation overhead is removed. Try it by building the Valhalla OpenJDK, enable preview, record with JFR + Java Mission Control and inspect JIT output with JITWatch; watch out for nullability/strict-init and tearing (long/double) which requires explicit non-null/tear annotations today.
AI-written summary · about
chapters (13)
- 0:00Introduction to Valhalla
- 1:50Why we need value types
- 6:01Understanding value classes
- 10:11Getting started with Valhalla
- 13:24Memory and GC analysis
- 18:00JIT compilation and performance
- 24:57Refining benchmarks
- 27:48Handling nullability
- 30:56Strict initialization
- 33:36Phase 2 feature testing
- 36:20Tearing and atomicity
- 39:15The future of Valhalla
- 42:21Q&A session








