Concurrent Message Processing using Transactional Memory in the Actor Model WTM 2013 Pascal Felber, Derin Harmanci, Yaroslav Hayduk and Anita Sobe
The Actor Model Hewitt & Baker - „Laws for Communicating Parallel Processes“ Motivated by the prospect of highly parallel computing machines with many microprocessors + own local memory Yaroslav Hayduk2
The Actor Model – basic principles everything is an actor (VS an object) asynchronous message passing has access to its local state only strong encapsulation inherently concurrent Yaroslav Hayduk3
OOP and Actors: Communication Yaroslav Hayduk4 Object A Object B Actor A Object B ObjectB.publicField=10 ObjectB.publicMethod() ActorA [SendMessageTo] ActorB VS asynchronous message passing direct access
Essential Actor properties Processes one message at a time – Yey! No race conditions or other hazards No (access to) shared state Can send messages to other actors only Switch its behavior Yaroslav Hayduk5
Behind the (Actor) scenes Yaroslav Hayduk6 Mailbox … Contains 2 Insert Local Actor state In progress: Contains 8 C C A A B B A “List” Actor Remove 9
Main issues 1. The processing of one message at a time Yaroslav Hayduk7
Notable Related Work Scholliers et al. – Parallel Actor Monitors – does not use STM for processing messages concurrently Shams et al. – Habanero Scala – async-finish programming model – processes parts of one message (and not many messages) concurrently Yaroslav Hayduk8
Idea: Process multiple messages concurrently Problem: the list can be easily corrupted Solution: Wrap each message processing in an STM transaction. When conflicts happen, (roll back and) repeat the message processing Yaroslav Hayduk9
Concurrent message processing Yaroslav Hayduk10 Actor Mailbox … Contains 2 Insert Local Actor state A “List” Actor Messages In progress A “List” Actor Messages In progress Contains 6 Insert 12 … Each message is processed in a transaction
Coordinated Transactions Yaroslav Hayduk11 A A A List Range (1..25) Actor Global list sum A List Range ( ) Actor ……….
Local Actor Sum: Zoom-in Yaroslav Hayduk Local Actor state A List Range Actor Messages In progress A List Range Actor Messages In progress 1.Calculate local sum 2.Forward new partial sum 3.Block (for consistency) New partial sum Prev partial sum
Main issues 2. Extensive blocking of actors involved in a coordinated transaction Yaroslav Hayduk13
Idea: Remove blocking; process other messages speculatively Pre-commit the local coordinated transaction Process other messages in a transaction speculatively Yaroslav Hayduk14
Non-blocking coordinated transactions Yaroslav Hayduk Local Actor state A List Range Actor Messages In progress A List Range Actor Messages In progress Saved: Partially committed local coordinated transaction Actor Mailbox … Contains 2 List sum Speculatively process: Insert 3
Evaluation Yaroslav Hayduk16
Evaluation Yaroslav Hayduk17
Summary By using speculation, we can achieve a higher message throughput in the Actor Model By using STM we guarantee that the Actor’s state is never corrupted Yaroslav Hayduk18
Thank you Questions?