Created
October 1, 2011 16:08
-
-
Save kbuckler/1256253 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Actors & Threads @mperham | |
Concurrency | |
Two primatives: processes, threads | |
Problem: communication and coordination | |
Shared data, copied | |
IPC | |
pipes, sockets, shared mem, files | |
Threads | |
More efficent than processes | |
POSIX doesn't define comm mech | |
Locks | |
Runtime efficiency not only goal | |
Locks | |
Hard to get right | |
Non deterministic | |
Don't scale | |
Thread contention | |
Not in 1.9 due to GIL, in Jruby penalize for contention and context switch | |
Thread communication | |
Go: goroutines | |
Anonymous function, no handles to it. | |
Pass messages via channels | |
Maps well to distributed model (no handle on db, but can get socket) | |
Backed by thread pool | |
Actors | |
Unit of executon | |
mailbox | |
send message | |
actor << { :amount => 123 } | |
Thread or fiber backed | |
No application locks (message copied) | |
MRI/Jruby | |
No actors | |
Rubinius (actor.rb) | |
Not idiomatic, hard to understand | |
Celluloid | |
OO actors | |
async method invocation | |
mix of threads & fibers | |
One object == one thread (.5Mb per thread) | |
Needs actor pooling. | |
girl_friday | |
Background processing poll | |
Parallel batch operations | |
Functional over OO | |
Thread based | |
Software Transactional Memory | |
Mutation of data in a transaction | |
ACI, not ACID | |
Clojure | |
Atomic Instructions | |
XCHG swap registers | |
CPMXCHG compare and set | |
JRuby has AtomicInteger, (#incrementAndSet) | |
java.util.concurrent | |
concurrent hash map, concurrent linked queue | |
TODO | |
Standard Actor API | |
Concurrent DS | |
STM for Ruby (jruby) | |
Multiverse | |
Reading | |
Kilim | |
Disruptor | |
Actors in Scala | |
Concurrency in Erlang |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment