SlideShare a Scribd company logo
Ruby
                     goes to

                        @elise_huard Euruko 2011
Monday 30 May 2011
Why Concurrency?



Monday 30 May 2011
“... 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
Concurrency !=
                       Parallellism


Monday 30 May 2011
3 threads, 2 cores


                      1                    1       2




                      2                    3
                                                   1




                       3                   3
                                                   2




                       1




                     core1   core2         core1   core2


Monday 30 May 2011
Your program




                                language VM



                                     OS
                     (kernel processes, other processes)


                          multicore - multiCPU


Monday 30 May 2011
Concurrency will melt
                    your brain

                     non-determinism
                     mutable AND shared state



Monday 30 May 2011
Actor Model




Monday 30 May 2011
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
                     received



Monday 30 May 2011
Hewitt et al. 1973


                     Generalization of the lambda
                     calculus



Monday 30 May 2011
Inspiration

                     artificial intelligence
                     ‘quantum mechanics’ - observing details
                     by which the order of arrival of
                     messages for an actor is determined
                     can affect result



Monday 30 May 2011
The point
                      only actors - no global state
                      partial order of execution




           from http://pragprog.com/titles/vspcon/programming-concurrency-on-the-jvm




Monday 30 May 2011
Implementations

                     • using threads/processes
                     • async messaging - mailbox
                     • pattern matching on incoming messages
                     • actors = state machines.

Monday 30 May 2011
Lifecycle




                     from http://pragprog.com/titles/vspcon/programming-concurrency-on-the-jvm




Monday 30 May 2011
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 leave


Monday 30 May 2011
Monday 30 May 2011
Actors in Ruby




Monday 30 May 2011
Concurrent gem

                     theoretical - different concurrency
                     models
                     https://github.com/mental/concurrent




Monday 30 May 2011
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
Revactor

               concurrent I/O for networking
               apps
               Evented rather than parallel
                     https://github.com/tarcieri/revactor



Monday 30 May 2011
Celluloid


                     thread-based actors
                     based on erlang

                      https://github.com/tarcieri/celluloid


Monday 30 May 2011
No true parallelism
                          with MRI


Monday 30 May 2011
Cheat on Ruby


Monday 30 May 2011
Erlang


                     light-weight processes
                     = actors


Monday 30 May 2011
Erlang

                     blocking receives
                     timeouts
                     supervision trees: fault-tolerance



Monday 30 May 2011
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/erlectricity
Monday 30 May 2011
Reia or Elixir


                     languages on erlang vm
                     friendlier, more ruby-like, OO



Monday 30 May 2011
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 library


Monday 30 May 2011
Akka



                actor model + software transactional memory
                               java and scala



Monday 30 May 2011
Akka

                     • sending: reply is possible or not, sync or
                       async
                     • supervision: several strategies
                     • as library or as framework
                     • local and distributed

Monday 30 May 2011
JRuby!



Monday 30 May 2011
Caveat



Monday 30 May 2011
Advantages

                     easy to grasp
                     real encapsulation -
                     separation of concerns
                     highly decentralized

Monday 30 May 2011
But


                     many messages (bandwidth)
                     livelocks are still possible



Monday 30 May 2011
Back to Ruby




Monday 30 May 2011
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
Let’s think about it.



Monday 30 May 2011
Thanks
                             @elise_huard




                     http://www.delicious.com/elisehuard/concurrency
Monday 30 May 2011
Ruby
                      goes to
                     Hollywood
                           Elise Huard LRUG 11-04-2011
Monday 30 May 2011
Ruby
                      goes to
                     Hollywood
                            Elise Huard LRUG
Monday 30 May 2011
Monday 30 May 2011

More Related Content

Similar to Ruby goes to hollywood

web标准化交流会上海站bobby分享
web标准化交流会上海站bobby分享web标准化交流会上海站bobby分享
web标准化交流会上海站bobby分享
裕波 周
 
web标准化交流会bobby分享
web标准化交流会bobby分享web标准化交流会bobby分享
web标准化交流会bobby分享
裕波 周
 
Erlang: Bult for concurrent, distributed systems
Erlang: Bult for concurrent, distributed systemsErlang: Bult for concurrent, distributed systems
Erlang: Bult for concurrent, distributed systems
Ken Pratt
 
Dev-Time Liferay
Dev-Time  LiferayDev-Time  Liferay
Dev-Time Liferay
Anton Naumov
 
Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.
Peter Neubauer
 
Our Best Practices Are Killing Us
Our Best Practices Are Killing UsOur Best Practices Are Killing Us
Our Best Practices Are Killing Us
Nicole Sullivan
 
NodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time WebNodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time WebJakub Nesetril
 
Scaling websites with RabbitMQ A(rlvaro Videla)
Scaling websites with RabbitMQ   A(rlvaro Videla)Scaling websites with RabbitMQ   A(rlvaro Videla)
Scaling websites with RabbitMQ A(rlvaro Videla)Ontico
 
Stackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content ManagementStackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content Management
Vance Lucas
 
BDD For Zend Framework With PHPSpec
BDD For Zend Framework With PHPSpecBDD For Zend Framework With PHPSpec
BDD For Zend Framework With PHPSpec
Marcello Duarte
 
Building an alarm clock with node.js
Building an alarm clock with node.jsBuilding an alarm clock with node.js
Building an alarm clock with node.js
Felix Geisendörfer
 

Similar to Ruby goes to hollywood (11)

web标准化交流会上海站bobby分享
web标准化交流会上海站bobby分享web标准化交流会上海站bobby分享
web标准化交流会上海站bobby分享
 
web标准化交流会bobby分享
web标准化交流会bobby分享web标准化交流会bobby分享
web标准化交流会bobby分享
 
Erlang: Bult for concurrent, distributed systems
Erlang: Bult for concurrent, distributed systemsErlang: Bult for concurrent, distributed systems
Erlang: Bult for concurrent, distributed systems
 
Dev-Time Liferay
Dev-Time  LiferayDev-Time  Liferay
Dev-Time Liferay
 
Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.
 
Our Best Practices Are Killing Us
Our Best Practices Are Killing UsOur Best Practices Are Killing Us
Our Best Practices Are Killing Us
 
NodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time WebNodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time Web
 
Scaling websites with RabbitMQ A(rlvaro Videla)
Scaling websites with RabbitMQ   A(rlvaro Videla)Scaling websites with RabbitMQ   A(rlvaro Videla)
Scaling websites with RabbitMQ A(rlvaro Videla)
 
Stackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content ManagementStackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content Management
 
BDD For Zend Framework With PHPSpec
BDD For Zend Framework With PHPSpecBDD For Zend Framework With PHPSpec
BDD For Zend Framework With PHPSpec
 
Building an alarm clock with node.js
Building an alarm clock with node.jsBuilding an alarm clock with node.js
Building an alarm clock with node.js
 

More from ehuard

Euroclojure 2017
Euroclojure 2017Euroclojure 2017
Euroclojure 2017
ehuard
 
Ruby goes to Hollywood
Ruby goes to HollywoodRuby goes to Hollywood
Ruby goes to Hollywood
ehuard
 
Ruby hollywood nordic
Ruby hollywood nordicRuby hollywood nordic
Ruby hollywood nordic
ehuard
 
Concurrency: Rubies, plural
Concurrency: Rubies, pluralConcurrency: Rubies, plural
Concurrency: Rubies, plural
ehuard
 
Concurrency
ConcurrencyConcurrency
Concurrency
ehuard
 
Concurrency
ConcurrencyConcurrency
Concurrencyehuard
 
12 hours to rate a rails application
12 hours to rate a rails application12 hours to rate a rails application
12 hours to rate a rails application
ehuard
 
how to rate a Rails application
how to rate a Rails applicationhow to rate a Rails application
how to rate a Rails application
ehuard
 
12 Hours To Rate A Rails Application
12 Hours To Rate A Rails Application12 Hours To Rate A Rails Application
12 Hours To Rate A Rails Application
ehuard
 
Barcamp Ghent2009
Barcamp Ghent2009Barcamp Ghent2009
Barcamp Ghent2009
ehuard
 
Tokyo Cabinet
Tokyo CabinetTokyo Cabinet
Tokyo Cabinet
ehuard
 
The real-time web
The real-time webThe real-time web
The real-time web
ehuard
 
Rails and the internet of things
Rails and the internet of thingsRails and the internet of things
Rails and the internet of things
ehuard
 
Oauth
OauthOauth
Oauth
ehuard
 

More from ehuard (14)

Euroclojure 2017
Euroclojure 2017Euroclojure 2017
Euroclojure 2017
 
Ruby goes to Hollywood
Ruby goes to HollywoodRuby goes to Hollywood
Ruby goes to Hollywood
 
Ruby hollywood nordic
Ruby hollywood nordicRuby hollywood nordic
Ruby hollywood nordic
 
Concurrency: Rubies, plural
Concurrency: Rubies, pluralConcurrency: Rubies, plural
Concurrency: Rubies, plural
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
12 hours to rate a rails application
12 hours to rate a rails application12 hours to rate a rails application
12 hours to rate a rails application
 
how to rate a Rails application
how to rate a Rails applicationhow to rate a Rails application
how to rate a Rails application
 
12 Hours To Rate A Rails Application
12 Hours To Rate A Rails Application12 Hours To Rate A Rails Application
12 Hours To Rate A Rails Application
 
Barcamp Ghent2009
Barcamp Ghent2009Barcamp Ghent2009
Barcamp Ghent2009
 
Tokyo Cabinet
Tokyo CabinetTokyo Cabinet
Tokyo Cabinet
 
The real-time web
The real-time webThe real-time web
The real-time web
 
Rails and the internet of things
Rails and the internet of thingsRails and the internet of things
Rails and the internet of things
 
Oauth
OauthOauth
Oauth
 

Recently uploaded

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 

Recently uploaded (20)

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 

Ruby goes to hollywood

  • 1. Ruby goes to @elise_huard Euruko 2011 Monday 30 May 2011
  • 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. Concurrency != Parallellism Monday 30 May 2011
  • 5. 3 threads, 2 cores 1 1 2 2 3 1 3 3 2 1 core1 core2 core1 core2 Monday 30 May 2011
  • 6. Your program language VM OS (kernel processes, other processes) multicore - multiCPU Monday 30 May 2011
  • 7. Concurrency will melt your brain non-determinism mutable AND shared state Monday 30 May 2011
  • 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 received Monday 30 May 2011
  • 10. Hewitt et al. 1973 Generalization of the lambda calculus Monday 30 May 2011
  • 11. Inspiration artificial intelligence ‘quantum mechanics’ - observing details by which the order of arrival of messages for an actor is determined can affect result Monday 30 May 2011
  • 12. The point only actors - no global state partial order of execution from http://pragprog.com/titles/vspcon/programming-concurrency-on-the-jvm Monday 30 May 2011
  • 13. Implementations • using threads/processes • async messaging - mailbox • pattern matching on incoming messages • actors = state machines. Monday 30 May 2011
  • 14. Lifecycle from http://pragprog.com/titles/vspcon/programming-concurrency-on-the-jvm Monday 30 May 2011
  • 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 leave Monday 30 May 2011
  • 17. Actors in Ruby Monday 30 May 2011
  • 18. Concurrent gem theoretical - different concurrency models https://github.com/mental/concurrent Monday 30 May 2011
  • 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. Revactor concurrent I/O for networking apps Evented rather than parallel https://github.com/tarcieri/revactor Monday 30 May 2011
  • 21. Celluloid thread-based actors based on erlang https://github.com/tarcieri/celluloid Monday 30 May 2011
  • 22. No true parallelism with MRI Monday 30 May 2011
  • 23. Cheat on Ruby Monday 30 May 2011
  • 24. Erlang light-weight processes = actors Monday 30 May 2011
  • 25. Erlang blocking receives timeouts supervision trees: fault-tolerance Monday 30 May 2011
  • 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/erlectricity Monday 30 May 2011
  • 27. Reia or Elixir languages on erlang vm friendlier, more ruby-like, OO Monday 30 May 2011
  • 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 library Monday 30 May 2011
  • 29. Akka actor model + software transactional memory java and scala Monday 30 May 2011
  • 30. Akka • sending: reply is possible or not, sync or async • supervision: several strategies • as library or as framework • local and distributed Monday 30 May 2011
  • 33. Advantages easy to grasp real encapsulation - separation of concerns highly decentralized Monday 30 May 2011
  • 34. But many messages (bandwidth) livelocks are still possible Monday 30 May 2011
  • 35. Back to Ruby Monday 30 May 2011
  • 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. Let’s think about it. Monday 30 May 2011
  • 38. Thanks @elise_huard http://www.delicious.com/elisehuard/concurrency Monday 30 May 2011
  • 39. Ruby goes to Hollywood Elise Huard LRUG 11-04-2011 Monday 30 May 2011
  • 40. Ruby goes to Hollywood Elise Huard LRUG Monday 30 May 2011