Actors without Borders: Amnesty for Imprisoned State Elias Castegren - - PowerPoint PPT Presentation

actors without borders
SMART_READER_LITE
LIVE PREVIEW

Actors without Borders: Amnesty for Imprisoned State Elias Castegren - - PowerPoint PPT Presentation

Actors without Borders: Amnesty for Imprisoned State Elias Castegren , Tobias Wrigstad PLACES17, Uppsala sa Structured Aliasing The Actor Model 2 Actor Isolation allows Sequential Reasoning 3 Passing Data Between Actors (by copy) 4


slide-1
SLIDE 1

Actors without Borders:

Amnesty for Imprisoned State

Elias Castegren, Tobias Wrigstad PLACES’17, Uppsala

sa Structured Aliasing
slide-2
SLIDE 2

The Actor Model

2

slide-3
SLIDE 3

Actor Isolation allows Sequential Reasoning

3

slide-4
SLIDE 4

Passing Data Between Actors (by copy)

4

slide-5
SLIDE 5

Passing Data Between Actors (by copy)

4

slide-6
SLIDE 6

Passing Data Between Actors (by transfer)

slide-7
SLIDE 7

Passing Data Between Actors (by transfer)

slide-8
SLIDE 8

Passing Data Between Actors (by transfer) Strong Encapsulation

slide-9
SLIDE 9

(Too) Strong Encapsulation

for i in [0..len-1] val x = l!get(i) transmogrify(x) end Quadratic complexity

6

slide-10
SLIDE 10

Solution? Breaking Actor Isolation

val iter = l!iter() while iter.hasNext() val x = iter.getNext() transmogrify(x) end Linear complexity Subject to data-races! iter

7

slide-11
SLIDE 11

l!iter() while l!hasNext() val x = l!getNext() transmogrify(x) end

Solution? Keeping Complexity Isolated

Forces complexity on the actor l!iter() while l!hasNext() val x = l!getNext() transmogrify(x) end

8

iter

slide-12
SLIDE 12

Problem Overview

  • Actors rely on isolation for sequential reasoning
  • Too strong for certain patterns
  • Breaking actor isolation prevents sequential reasoning
  • Extending actors to handle these patterns make them complex
  • Observation: 


Holding a reference to an isolated object is OK as long as only the owner accesses it

9

slide-13
SLIDE 13

Relax Actor Isolation by Bestowing Activity

10

slide-14
SLIDE 14

Relax Actor Isolation by Bestowing Activity

slide-15
SLIDE 15

Relax Actor Isolation by Bestowing Activity

val iter = l!iter() while iter!hasNext() val x = iter!getNext() transmogrify(x) end

slide-16
SLIDE 16

Relax Actor Isolation by Bestowing Activity

val iter = l!iter() while iter!hasNext() val x = iter!getNext() transmogrify(x) end hasNext

slide-17
SLIDE 17

Relax Actor Isolation by Bestowing Activity

val iter = l!iter() while iter!hasNext() val x = iter!getNext() transmogrify(x) end λ _ . iter.hasNext()

slide-18
SLIDE 18

Relax Actor Isolation by Bestowing Activity

val iter = l!iter() while iter!hasNext() val x = iter!getNext() transmogrify(x) end λ _ . iter.hasNext() Linear complexity All accesses synchronised

slide-19
SLIDE 19

Relax Actor Isolation by Bestowing Activity

val iter = l!iter() while iter!hasNext() val x = iter!getNext() transmogrify(x) end Linear complexity All accesses synchronised iter

slide-20
SLIDE 20

Relax Actor Isolation by Bestowing Activity

val iter = l!iter() while iter!hasNext() val x = iter!getNext() transmogrify(x) end Linear complexity All accesses synchronised

slide-21
SLIDE 21

Relax Actor Isolation by Bestowing Activity

val iter = l!iter() while iter!hasNext() val x = iter!getNext() transmogrify(x) end Linear complexity All accesses synchronised I bestow thee with activity!

slide-22
SLIDE 22

Relax Actor Isolation by Bestowing Activity

val iter = l!iter() while iter!hasNext() val x = iter!getNext() transmogrify(x) end Linear complexity All accesses synchronised Actor kept simple

slide-23
SLIDE 23

Delegating Parts of an Actor’s Interface

actor A var c : C def foo() : unit … end def bar() : unit … end def getC : bestowed[C] bestow this.c end end class C def beep() : unit … end def boop() : unit … end end

14

slide-24
SLIDE 24

Delegating Parts of an Actor’s Interface

actor A var c : C def foo() : unit … end def bar() : unit … end def getC : bestowed[C] bestow this.c end end class C def beep() : unit … end def boop() : unit … end end

14

slide-25
SLIDE 25

Formalising Bestowed References

  • Syntax

15

slide-26
SLIDE 26

Formalising Bestowed References

  • Syntax
  • Static semantics

Passive type Bestowed type Actor type Message send Bestowing Bestowed value

15

slide-27
SLIDE 27

Formalising Bestowed References

  • Syntax
  • Static semantics

Passive type Bestowed type Actor type Message send Bestowing Bestowed value

15

slide-28
SLIDE 28

Formalising Bestowed References

  • Dynamic semantics

16

slide-29
SLIDE 29

Formalising Bestowed References

  • Dynamic semantics

16

slide-30
SLIDE 30

Properties of the Formalism

  • Progress:
  • Preservation:
  • Data-race freedom: Two actors will never mutate the same passive object

17

slide-31
SLIDE 31

The Big Picture

  • Kappa is a capability based type-system for concurrent OO-programming [ECOOP’16]
  • Tracks the boundaries of objects to achieve strong encapsulation

!

18

slide-32
SLIDE 32

Generalizing Bestowed References

  • Bestowed references provide a thread-safe way to break encapsulation

!

19

slide-33
SLIDE 33

Generalizing Bestowed References

  • Bestowed references provide a thread-safe way to break encapsulation

!

19

slide-34
SLIDE 34

Future Work

  • Implementation in Encore
  • Enriched formalism with copying and ownership transfer

20

slide-35
SLIDE 35

Summary

  • Actor isolation can be relaxed by bestowing encapsulated objects with activity
  • All accesses will be synchronised via the message queue of the owning actor
  • Actors do not need to know the implementation of their bestowed objects
  • A bestowed object does not need to know that it is bestowed
  • The same kind of relaxed encapsulation works for locks
  • All accesses will be synchronised via the lock of the owning object
  • Also in the paper:

Atomic blocks to group operations
 Implementation sketches
 Polymorphic concurrency control

21

slide-36
SLIDE 36

Tack! Frågor?

slide-37
SLIDE 37

Incompatible Interleaving

l!apply(f, 2) l!apply(f, 3)

23

slide-38
SLIDE 38

Incompatible Interleaving

l!apply(f, 2) l!apply(f, 3)

23

slide-39
SLIDE 39

Incompatible Interleaving

l!apply(f, 2) l!apply(f, 3)

23

slide-40
SLIDE 40

Incompatible Interleaving

l!apply(f, 2) l!apply(f, 3)

?

23

slide-41
SLIDE 41

Grouping Messages

atomic l l!apply(f, 2) l!apply(f, 3) end

24

slide-42
SLIDE 42

Grouping Messages

atomic l l!apply(f, 2) l!apply(f, 3) end

24

slide-43
SLIDE 43

Grouping Messages

atomic l l!apply(f, 2) l!apply(f, 3) end

24

slide-44
SLIDE 44

Grouping Messages

atomic l l!apply(f, 2) l!apply(f, 3) end

24

slide-45
SLIDE 45

Grouping Locked operations

atomic l l.apply(f, 2) l.apply(f, 3) end

!

25

slide-46
SLIDE 46

Polymorphic Concurrency Control

def foo(l : safe List) : unit val iter = l.iter() atomic iter iter.apply(f) iter.apply(f) end

?

slide-47
SLIDE 47

Polymorphic Concurrency Control

def foo(l : safe List) : unit val iter = l.iter() atomic iter iter.apply(f) iter.apply(f) end

?

Bestowed

slide-48
SLIDE 48

Tack! Frågor?

slide-49
SLIDE 49

Summary

  • Actor isolation can be relaxed by bestowing encapsulated objects with activity
  • All accesses will be synchronised via the message queue of the owning actor
  • Actors do not need to know the implementation of their bestowed objects
  • A bestowed object does not need to know that it is bestowed
  • The same kind of relaxed encapsulation works for locks
  • All accesses will be synchronised via the lock of the owning object
  • Also in the paper:

Atomic blocks to group operations
 Implementation sketches
 Polymorphic concurrency control

28