Table of Contents
Fetching ...

Speak Now: Safe Actor Programming with Multiparty Session Types

Simon Fowler, Raymond Hu

TL;DR

This paper introduces Maty, the first actor language design supporting both static multiparty session typing and the full power of actors taking part in multiple sessions, and extends it to support Erlang-style supervision and cascading failure, and shows that this preserves Maty's strong metatheory.

Abstract

Actor languages such as Erlang and Elixir are widely used for implementing scalable and reliable distributed applications, but the informally-specified nature of actor communication patterns leaves systems vulnerable to costly errors such as communication mismatches and deadlocks. Multiparty session types (MPSTs) rule out communication errors early in the development process, but until now, the many-sender, single-receiver nature of actor communication has made it difficult for actor languages to benefit from session types. This paper introduces Maty, the first actor language design supporting both static multiparty session typing and the full power of actors taking part in multiple sessions. Maty therefore combines the error prevention mechanism of session types with the scalability and fault tolerance of actor languages. Our main insight is to enforce session typing through a flow-sensitive effect system, combined with an event-driven programming style and first-class message handlers. Using MPSTs allows us to guarantee communication safety: a process will never send or receive an unexpected message, nor will a session get stuck because an actor is waiting for a message that will never be sent. We extend Maty to support Erlang-style supervision and cascading failure, and show that this preserves Maty's strong metatheory. We implement Maty in Scala using an API generation approach, and demonstrate the expressiveness of our model by implementing a representative sample of the widely-used Savina actor benchmark suite; an industry-supplied factory scenario; and a chat server.

Speak Now: Safe Actor Programming with Multiparty Session Types

TL;DR

This paper introduces Maty, the first actor language design supporting both static multiparty session typing and the full power of actors taking part in multiple sessions, and extends it to support Erlang-style supervision and cascading failure, and shows that this preserves Maty's strong metatheory.

Abstract

Actor languages such as Erlang and Elixir are widely used for implementing scalable and reliable distributed applications, but the informally-specified nature of actor communication patterns leaves systems vulnerable to costly errors such as communication mismatches and deadlocks. Multiparty session types (MPSTs) rule out communication errors early in the development process, but until now, the many-sender, single-receiver nature of actor communication has made it difficult for actor languages to benefit from session types. This paper introduces Maty, the first actor language design supporting both static multiparty session typing and the full power of actors taking part in multiple sessions. Maty therefore combines the error prevention mechanism of session types with the scalability and fault tolerance of actor languages. Our main insight is to enforce session typing through a flow-sensitive effect system, combined with an event-driven programming style and first-class message handlers. Using MPSTs allows us to guarantee communication safety: a process will never send or receive an unexpected message, nor will a session get stuck because an actor is waiting for a message that will never be sent. We extend Maty to support Erlang-style supervision and cascading failure, and show that this preserves Maty's strong metatheory. We implement Maty in Scala using an API generation approach, and demonstrate the expressiveness of our model by implementing a representative sample of the widely-used Savina actor benchmark suite; an industry-supplied factory scenario; and a chat server.
Paper Structure (30 sections, 9 theorems, 47 equations, 16 figures)

This paper contains 30 sections, 9 theorems, 47 equations, 16 figures.

Key Result

theorem 1

Typability is preserved by structural congruence and reduction.

Figures (16)

  • Figure 1: ID Server
  • Figure 2: ID Server extended with locking
  • Figure 3: Channel- and actor-based languages FowlerLW17
  • Figure 4: Session types for the ID server example.
  • Figure 5: Maty implementation of ID Server
  • ...and 11 more figures

Theorems & Definitions (18)

  • definition 1: Compliance
  • theorem 1: Preservation
  • Remark 2: Session Fidelity
  • definition 2: Canonical form
  • theorem 3: Progress
  • definition 3: Ongoing environment / session
  • definition 4: Thread Reduction
  • definition 5: Thread-Terminating
  • lemma 1: Independence of Thread Reductions
  • definition 6: Idle Configuration
  • ...and 8 more