Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Celluloid & DCell
Search
Patrick Van Stee
July 11, 2012
Programming
4
480
Celluloid & DCell
Patrick Van Stee
July 11, 2012
Tweet
Share
More Decks by Patrick Van Stee
See All by Patrick Van Stee
Raft: Consensus for Rubyists
vanstee
136
6.6k
Elixir and Ecto
vanstee
5
850
Bootstrap
vanstee
8
720
HTTP API Design for iOS Applications
vanstee
11
560
Consensus: An Introduction to Raft
vanstee
22
2.8k
Convergent Replicated Data Types
vanstee
4
690
Pour Over Brewing Method
vanstee
1
300
Map Reduce & Ruby
vanstee
10
710
Other Decks in Programming
See All in Programming
RubyLSPのマルチバイト文字対応
notfounds
0
120
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
310
C++でシェーダを書く
fadis
6
4.1k
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
600
Macとオーディオ再生 2024/11/02
yusukeito
0
370
as(型アサーション)を書く前にできること
marokanatani
9
2.6k
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
910
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
330
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
Click-free releases & the making of a CLI app
oheyadam
2
110
Remix on Hono on Cloudflare Workers
yusukebe
1
280
Featured
See All Featured
Building an army of robots
kneath
302
43k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
The Invisible Side of Design
smashingmag
298
50k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Code Reviewing Like a Champion
maltzj
520
39k
Thoughts on Productivity
jonyablonski
67
4.3k
Side Projects
sachag
452
42k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Transcript
Celluloid DCell &
@vanstee github.com/vanstee Patrick Van Stee highgroove.com
@tarcieri Revactor Reia nio4r Cryptosphere cool.io
brew install zeromq gem install dcell Setup
Celluloid General purpose concurrency framework for Ruby built on the
Actor Model
class Counter attr_reader :count def initialize @count = 0 end
def increment @count += 1 end end
class Counter attr_reader :count def initialize @count = 0 @mutex
= Mutex.new end def increment @mutex.synchronize do @count += 1 end end end
Threads are hard!
class Counter include Celluloid attr_reader :count def initialize @count =
0 end def increment @count += 1 end end
Actor Model
•No shared state •Communicate with messages •Process messages sequentially
class Counter include Celluloid def increment(count, actor) return count if
count < 10000 actor.increment( count + 1, Actor.current ) end end
& Asynchronous Method Calls Futures
counter = Counter.new # returns immediately counter.increment! puts counter.count #
returns immediately future = counter.future :increment puts future.value
module Enumerable def map(&block) futures = map do |item| Celluloid::Future.new(
item, &block ) end futures.map(&:value) end end
Caveats
• The GIL in MRI does not allow parallelism •
Threads and Fibers are expensive • Concurrency is still a hard problem [not really]
DCell
Celluloid General purpose concurrency framework for Ruby built on the
Actor Model DCell Distributed Celluloid over 0MQ
“I thought of objects being like biological cells or individual
computers on a network, only able to communicate with messages. Alan Kay
• Exposes Actors on the Network • Send messages as
you normally would
DRb DCell Threads Actors
Demo
Also Checkout Sidekiq
github.com celluloid/celluloid celluloid/dcell
Hack Night