FROM SCALA TO ASSEMBLY THE COST OF ABSTACTION REVISITED
summary
Claims that high-level Scala constructs are always slow get tested with real numbers: code examples compile to bytecode and assembly and are profiled with JMH, JITWatch, Java Flight Recorder / JMC, jstack and jstat. Surprise: immutable “copy” patterns often vanish under Graal JIT and become a tiny loop with almost no allocations, while monad transformers add measurable overhead compared to stacked Option/Task or plain null returns. Cache behavior also dominates: columnwise array access shows ~70% cache misses. Measure on your JVM before changing design.
AI-written summary · about
chapters (32)
- 0:00Intro
- 1:07Motivation
- 2:33Is it always true
- 5:39Premature realization
- 7:14We like numbers
- 7:58Scala is immune
- 8:31High performance
- 9:08Performance in Scala
- 12:43Immutable classes
- 13:37JavaP
- 14:23bytecode
- 14:49justintime compilation
- 17:18JVM inlining
- 20:12JMH
- 21:26Dead code elimination
- 22:19Special way to call it
- 22:31Measuring immutability
- 23:10Comparing the results
- 25:21Java Flight Recorder Java Mission Control
- 27:20Java Flight Recorder Test
- 30:00Jstack
- 31:46Safe Point Bias
- 33:04Preassembly
- 34:14JITWatch
- 35:15ReadingAssembly
- 36:27Garbage Collector
- 41:13Null
- 44:19For loop
- 45:30While
- 46:35Performance counters
- 48:14Garbage collectors
- 52:37Outro
related talks
54mWhat Lies Beneath
46mCompiling Scala Faster with GraalVM
01h 07mFrom Java to Assembly: Down the Rabbit Hole
31m5 Things you Need to Know About Scala Compilation
42mWhat Scala can learn from Rust, Swift, and C++
40mScala ♥ Graal
48mA journey to JVM Excellence: Navigating JDKs and JVMs
21mReasonable Scala Compiler
