Ruby                     goes to                        @elise_huard Euruko 2011Monday 30 May 2011
Why Concurrency?Monday 30 May 2011
“... for the first time in history, no one is                     building a much faster sequential processor.             ...
Concurrency !=                       ParallellismMonday 30 May 2011
3 threads, 2 cores                      1                    1       2                      2                    3        ...
Your program                                language VM                                     OS                     (kernel...
Concurrency will melt                    your brain                     non-determinism                     mutable AND sh...
Actor ModelMonday 30 May 2011
Hewitt et al. 1973                     no shared state                     in response to a message, an actor can:        ...
Hewitt et al. 1973                     Generalization of the lambda                     calculusMonday 30 May 2011
Inspiration                     artificial intelligence                     ‘quantum mechanics’ - observing details        ...
The point                      only actors - no global state                      partial order of execution           fro...
Implementations                     • using threads/processes                     • async messaging - mailbox             ...
Lifecycle                     from http://pragprog.com/titles/vspcon/programming-concurrency-on-the-jvmMonday 30 May 2011
Sleeping barber                     shop with x chairs                     1 barber                         no customer: s...
Monday 30 May 2011
Actors in RubyMonday 30 May 2011
Concurrent gem                     theoretical - different concurrency                     models                     http...
Rubinius Actors                     require actor                     actor = Actor.spawn(Actor.current) do |master|      ...
Revactor               concurrent I/O for networking               apps               Evented rather than parallel        ...
Celluloid                     thread-based actors                     based on erlang                      https://github....
No true parallelism                          with MRIMonday 30 May 2011
Cheat on RubyMonday 30 May 2011
Erlang                     light-weight processes                     = actorsMonday 30 May 2011
Erlang                     blocking receives                     timeouts                     supervision trees: fault-tol...
Erlectricity              require rubygems              require erlectricity              receive do |f|                f....
Reia or Elixir                     languages on erlang vm                     friendlier, more ruby-like, OOMonday 30 May ...
Scala                     “We also included enhancements to make it                     easier to call from Ruby into Scal...
Akka                actor model + software transactional memory                               java and scalaMonday 30 May ...
Akka                     • sending: reply is possible or not, sync or                       async                     • su...
JRuby!Monday 30 May 2011
CaveatMonday 30 May 2011
Advantages                     easy to grasp                     real encapsulation -                     separation of co...
But                     many messages (bandwidth)                     livelocks are still possibleMonday 30 May 2011
Back to RubyMonday 30 May 2011
Time to control                         shared state ?                     Change RubySpec:                     default: v...
Let’s think about it.Monday 30 May 2011
Thanks                             @elise_huard                     http://www.delicious.com/elisehuard/concurrencyMonday ...
Ruby                      goes to                     Hollywood                           Elise Huard LRUG 11-04-2011Monda...
Ruby                      goes to                     Hollywood                            Elise Huard LRUGMonday 30 May 2...
Monday 30 May 2011
Upcoming SlideShare
Loading in...5
×

Ruby goes to hollywood

6,480

Published on

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
6,480
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
40
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Ruby goes to hollywood

  1. 1. Ruby goes to @elise_huard Euruko 2011Monday 30 May 2011
  2. 2. Why Concurrency?Monday 30 May 2011
  3. 3. “... for the first time in history, no one is building a much faster sequential processor. If you want your programs to run significantly faster (...) you’re going to have to parallelize your program.” Hennessy and Patterson “Computer Architectures” (4th edition, 2007)Monday 30 May 2011
  4. 4. Concurrency != ParallellismMonday 30 May 2011
  5. 5. 3 threads, 2 cores 1 1 2 2 3 1 3 3 2 1 core1 core2 core1 core2Monday 30 May 2011
  6. 6. Your program language VM OS (kernel processes, other processes) multicore - multiCPUMonday 30 May 2011
  7. 7. Concurrency will melt your brain non-determinism mutable AND shared stateMonday 30 May 2011
  8. 8. Actor ModelMonday 30 May 2011
  9. 9. Hewitt et al. 1973 no shared state in response to a message, an actor can: make local decisions create more actors send more messages determine how to respond to the next message receivedMonday 30 May 2011
  10. 10. Hewitt et al. 1973 Generalization of the lambda calculusMonday 30 May 2011
  11. 11. Inspiration artificial intelligence ‘quantum mechanics’ - observing details by which the order of arrival of messages for an actor is determined can affect resultMonday 30 May 2011
  12. 12. The point only actors - no global state partial order of execution from http://pragprog.com/titles/vspcon/programming-concurrency-on-the-jvmMonday 30 May 2011
  13. 13. Implementations • using threads/processes • async messaging - mailbox • pattern matching on incoming messages • actors = state machines.Monday 30 May 2011
  14. 14. Lifecycle from http://pragprog.com/titles/vspcon/programming-concurrency-on-the-jvmMonday 30 May 2011
  15. 15. Sleeping barber shop with x chairs 1 barber no customer: sleep. customers: cut hairs customer if barber is sleeping: wake him up else if enough chairs take a chair else leaveMonday 30 May 2011
  16. 16. Monday 30 May 2011
  17. 17. Actors in RubyMonday 30 May 2011
  18. 18. Concurrent gem theoretical - different concurrency models https://github.com/mental/concurrentMonday 30 May 2011
  19. 19. Rubinius Actors require actor actor = Actor.spawn(Actor.current) do |master| msg = Actor.receive master.send msg end actor.send "test" msg = Actor.receive # msg == "test"Monday 30 May 2011
  20. 20. Revactor concurrent I/O for networking apps Evented rather than parallel https://github.com/tarcieri/revactorMonday 30 May 2011
  21. 21. Celluloid thread-based actors based on erlang https://github.com/tarcieri/celluloidMonday 30 May 2011
  22. 22. No true parallelism with MRIMonday 30 May 2011
  23. 23. Cheat on RubyMonday 30 May 2011
  24. 24. Erlang light-weight processes = actorsMonday 30 May 2011
  25. 25. Erlang blocking receives timeouts supervision trees: fault-toleranceMonday 30 May 2011
  26. 26. Erlectricity require rubygems require erlectricity receive do |f| f.when([:echo, String]) do |text| f.send!([:result, "You said: #{text}"]) f.receive_loop end end https://github.com/mojombo/erlectricityMonday 30 May 2011
  27. 27. Reia or Elixir languages on erlang vm friendlier, more ruby-like, OOMonday 30 May 2011
  28. 28. Scala “We also included enhancements to make it easier to call from Ruby into Scala libraries, which has enabled the Lift web framework to offer support for Ruby.” Charles Nutter, ‘JRuby 1.6 released, now what ?’ http://www.engineyard.com/blog/2011/jruby-1-6-released-now-what/ Actors in standard libraryMonday 30 May 2011
  29. 29. Akka actor model + software transactional memory java and scalaMonday 30 May 2011
  30. 30. Akka • sending: reply is possible or not, sync or async • supervision: several strategies • as library or as framework • local and distributedMonday 30 May 2011
  31. 31. JRuby!Monday 30 May 2011
  32. 32. CaveatMonday 30 May 2011
  33. 33. Advantages easy to grasp real encapsulation - separation of concerns highly decentralizedMonday 30 May 2011
  34. 34. But many messages (bandwidth) livelocks are still possibleMonday 30 May 2011
  35. 35. Back to RubyMonday 30 May 2011
  36. 36. Time to control shared state ? Change RubySpec: default: variables not shared between threads? integrate better concurrency primitives into the Ruby stdlib ?Monday 30 May 2011
  37. 37. Let’s think about it.Monday 30 May 2011
  38. 38. Thanks @elise_huard http://www.delicious.com/elisehuard/concurrencyMonday 30 May 2011
  39. 39. Ruby goes to Hollywood Elise Huard LRUG 11-04-2011Monday 30 May 2011
  40. 40. Ruby goes to Hollywood Elise Huard LRUGMonday 30 May 2011
  41. 41. Monday 30 May 2011
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×