Cache Me If You Can: Speed Up Your JVM with Project Valhalla
summary
Project Valhalla adds JEP 401 value classes (classes without identity) and null-restricted value classes to let the JVM flatten objects into dense, cache-friendly layouts; flattening is limited by atomic-access size (often as small as 32 bits) and nullable values can blow up memory (a single null bit can force 32-bit alignment). OpenJ9 prototypes and OpenJDK early access builds exist to test throughput gains for numeric, linear-algebra, and ML workloads; opting into loosely-consistent access allows larger flattened instances at the cost of atomicity.
AI-written summary · about
chapters (13)
- 0:00Project Valhalla intro
- 1:09Memory fetch costs matter
- 3:22Cache locality impact
- 5:12Java objects memory layout
- 7:02Object headers overhead
- 8:27Identity-free objects
- 10:18Flatten objects for cache
- 11:01Value Classes in Valhalla
- 13:54Flattened null challenges
- 14:42Null-restricted value classes
- 16:31Atomic access relaxation
- 17:16Value class takeaways
- 18:27Experiment with Valhalla








