Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[RubyConf.tw 2014] Cores unleashed - Exploiting Parallelism in Ruby with STM

[RubyConf.tw 2014] Cores unleashed - Exploiting Parallelism in Ruby with STM


Szu-Kai Hsu (brucehsu)

April 26, 2014

More Decks by Szu-Kai Hsu (brucehsu)

Other Decks in Programming


  1. Cores Unleashed Exploiting Parallelism in Ruby with STM Szu-Kai Hsu

  2. @brucehsu

  3. None
  4. There was a time...

  5. There was a time... when programmers were happy (relatively)

  6. None
  7. None
  8. None
  9. None
  10. None
  11. None
  12. None
  13. None
  14. “Global Interpreter Lock is a mechanism used in computer language

    interpreters to synchronize the execution of threads so that only one thread can execute at a time. An interpreter which uses GIL will always allow exactly one thread to execute at a time, even if run on a Multi-core processor. Some popular interpreters that have GIL are CPython and Ruby MRI.” http://en.wikipedia.org/wiki/ GlobalInterpreterLock
  15. Alternative implementations Those using fine-grained locks » JRuby » Rubinius

    » MacRuby
  16. None
  17. None
  18. None
  19. Beautiful Concurrency, Simon Peyton Jones 2007 1.Taking too few locks

    2.Taking too many locks 3.Taking the wrong locks 4.Taking locks in the wrong orders 5.Error recovery 6.Lost wake-ups and erroneous retries
  20. Software Transactional Memory

  21. Transaction Attributes - Atomicity - Consistency - Isolation - Durability

  22. None
  23. STM is a sound Abstraction of locks

  24. How do we implement STM in Ruby?

  25. Why not in Go?

  26. Why not a new VM?

  27. RunVM

  28. Live Demo?

  29. None
  30. Why Go? And I say, why not? » Easier to

    write » Good performance » Growing community and resources » Goroutines and channels » Go is for Hipsters
  31. None
  32. RunVM Specification » Subset of tinyrb » Stack-based VM »

    Thanks to Ruby Under a Microscope
  33. Transactional Locking II

  34. None
  35. None
  36. Thanks!