~/talk

Micro-Optimization for Fun and Profit

Talkat Scala Days 2023 Seattle · 2023-06-05..06-07· [java]
slides:none on file

Builds a simplified Cats Effect IO runtime (IO values, errors, async, fibers) and measures five micro-optimizations with JMH benchmarks on EC2 t2.large (warns against Apple Silicon). Implements an IO fiber with a continuation stack and then: replaces linked lists with an array-backed stack, encodes continuations as bytes for allocation-free continuations, removes Either allocations, adds integer tag dispatch, and hoists current IO into a parameter. Results show ~60–70% speedups overall, but a surprising 4x regression for left-associated flatMap; trade-offs acknowledged.

AI-written summary · about

  1. 0:00Intro
  2. 0:32Dont microoptimize
  3. 1:10Simplified IO
  4. 1:53GitHub
  5. 4:36Physical Factors
  6. 5:29Layers of abstraction
  7. 6:29Happy paths and unhappy paths
  8. 7:39What is slow
  9. 9:52What is fast
  10. 13:10Pro tip
  11. 14:25Implementing IO
  12. 15:39IO Fiber
  13. 16:38IL Fiber
  14. 17:40Run
  15. 18:46Continue
  16. 19:39Async
  17. 20:34Measuring
  18. 20:59SBTJMH
  19. 24:23Micro Benchmarks
  20. 27:05Micro Optimizations
  21. 27:22Allocation Free Stack
  22. 27:35Continuation Stack
  23. 29:01Dynamic Arrays
  24. 30:57Array Stack
  25. 32:35Array Copy
  26. 32:47Benchmarks
  27. 33:03Why did it get worse
  28. 33:17The results
  29. 33:35Why I tried different array bounds
  30. 35:14The problem with micro benchmarks
  31. 35:58Optimization for fun
  32. 36:28The answer
  33. 37:24The solution
  34. 40:10Bias
  35. 40:31Allocation Free Results
  36. 41:34Encoding
  37. 42:56Results
  38. 43:08Pattern Matching
  39. 43:35If Else
  40. 44:26Deftag
  41. 45:24Invoke Virtual
  42. 46:51More Stack Less Game
  43. 47:10Current
  44. 48:12Faster
  45. 48:54Takeaways
~/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.