Inlining anonymous functions with macros
summary
Claim: compile‑time macros rewrite anonymous function literals into direct code so the JVM can optimize tight loops. Tooling: Scala macros with quasiquotes (Macro Paradise), a Transformer that substitutes parameters and removes tuples. Measured effect: typical cases show about 2x slowdown without inlining, a constructed case hits ~5x. Built artifact: a macro that generates inlined methods and anonymous instances, mostly working but not yet production (careful owners/side‑effects and generated bytecode size).
AI-written summary · about
chapters (21)
- 0:00Intro
- 0:29Inlining anonymous functions with macros
- 1:31Purpose of this talk
- 3:50What are macros?
- 4:29What are anonymous functions?
- 5:05What was different?
- 5:43Doesn't the JVM already do this?
- 7:44So what's the "inlining problem" problem?
- 9:46Oxur programs are 10x slower!!??
- 11:13Is it worth it?
- 11:44Using macros to inline functions
- 12:59Why do we need literal functions?
- 13:42What does a macro look like?
- 14:44What does an Expr (AST) look like?
- 17:11So what does an inlining transformation look like?
- 19:36How do you build a tree?
- 20:36How do the AST transformations work?
- 26:07What's an example of generating anonymous classes?
- 31:57What are the advantages?
- 33:30What are some problems?
- 37:07The End. Questions?
related talks
54mThe Things Scala js Does to Make Your Code Fast
33mUnshackling JavaScript with Macros
29mExtreme JavaScript Performance
31mJavaScript Compilation Techniques or "Wasn't JavaScript supposed to be slow?"
29mJavaScript in JavaScript: Inception
22mOptimizing Your Code with Babel
26mJavaScript JITs
20mPartial Evaluation, Whole-Program Compilation
