~/talk

@inline and @specialized What Do They Do? Should I Be Using Them?

Talkat Scala Days Berlin 2016 · 2016-06-15..06-17· [scala]
github:cb372
slides:none on file

Explains what @inline and @specialized actually do on the JVM, shows bytecode and microbenchmarks: compile-time inlining (requires -optimise flag and emits -Yinline-warnings if it fails) removes invokevirtual overhead and yields 3–4× speedup vs unoptimized runs and Scala 2.12 adds ~10% more; hotspot often already inlines so annotations can be redundant. Specialization eliminates boxing but multiplies classes (risk of code size explosion); results vary — a bloom filter shows no gain, an append-only int buffer shows double the speed when specialized.

AI-written summary · about

  1. 0:00Start
  2. 5:33Removes function call overhead
  3. 7:03invokevirtual
  4. 8:15Enables further optimisations
  5. 9:50Answer: Code is data
  6. 11:04Inlining in HotSpot Conditions for inlining
  7. 12:27Inlining in Scala
  8. 13:30Inlining heuristics (Scala 2.10.0 -2.11.)
  9. 15:27New optimiser in 2.12
  10. 19:13Let's benchmark!
  11. 19:27Fast Fourier Transform
  12. 22:26Further reading
  13. 22:52Types in the JVM Primitive types
  14. 23:36Generic methods in Java
  15. 25:31Scala types
  16. 25:55Generic methods in Scala
  17. 26:59Specialisation
  18. 28:24How does the caller know? specialized is a static annotation stored in the class's ScalaSignature
  19. 29:29Space tradeoff
  20. 30:47Boxing in the Scala stdlib (as of 2.11.8)
  21. 31:29Alternatives
  22. 32:35Bloom filter
  23. 33:27Benchmark results
  24. 33:57Mutable buffer
  25. 37:14Summary
~/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.