~/talk

How the JVM Optimizes Generic Code - A Deep Dive

Talkat JavaOne 2026 · 2026-03-17..03-19· [java, compilers-and-language-design]
slides:none on file

Uses a QuickSort benchmark on JDK 25 to show JVM generics can match C++ when the VM produces monomorphic code: a hand‑specialized int sort runs ~10.5μs for 1,000 elements, boxed integers are ~3× slower, bimorphic profiles slow from ~12μs to ~47μs and saturated profiles hit ~70μs. Two practical fixes are demonstrated: hidden‑class cloning of the algorithm via method handles to get clean profiles, and aggressive caller‑side inlining/method‑handle customization; both restore near hand‑specialized speed. Project Valhalla’s specialized generics is the long‑term roadmap.

AI-written summary · about

  1. 0:00Introduction
  2. 1:37Generic performance concepts
  3. 4:02Benchmarks and quicksort analysis
  4. 7:27Reflective quicksort and Valhalla
  5. 10:59Hotspot optimization techniques
  6. 13:35Monomorphism and performance cliffs
  7. 18:04Degradation of saturated profiles
  8. 24:11Strategies for reclaiming static performance
  9. 30:30Experimental repair techniques
  10. 35:12Force-inline and future directions
  11. 40:21Comparison with C++ and concluding thoughts
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.