actors without borders
play

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


  1. Actors without Borders: Amnesty for Imprisoned State Elias Castegren , Tobias Wrigstad PLACES’17, Uppsala sa Structured Aliasing

  2. The Actor Model 2

  3. Actor Isolation allows Sequential Reasoning 3

  4. Passing Data Between Actors (by copy) 4

  5. Passing Data Between Actors (by copy) 4

  6. Passing Data Between Actors (by transfer)

  7. Passing Data Between Actors (by transfer)

  8. Passing Data Between Actors (by transfer) Strong Encapsulation

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

  10. Solution? Breaking Actor Isolation val iter = l!iter() while iter.hasNext() val x = iter.getNext() transmogrify(x) iter end Linear complexity Subject to data-races! 7

  11. Solution? Keeping Complexity Isolated l!iter() while l!hasNext() val x = l!getNext() transmogrify(x) l!iter() end while l!hasNext() val x = l!getNext() transmogrify(x) iter end Forces complexity on the actor 8

  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

  13. Relax Actor Isolation by Bestowing Activity 10

  14. Relax Actor Isolation by Bestowing Activity

  15. Relax Actor Isolation by Bestowing Activity val iter = l!iter() while iter!hasNext() val x = iter!getNext() transmogrify(x) end

  16. Relax Actor Isolation by Bestowing Activity val iter = l!iter() while iter!hasNext() val x = iter!getNext() transmogrify(x) hasNext end

  17. Relax Actor Isolation by Bestowing Activity val iter = l!iter() while iter!hasNext() λ _ . iter.hasNext() val x = iter!getNext() transmogrify(x) end

  18. Relax Actor Isolation by Bestowing Activity val iter = l!iter() while iter!hasNext() λ _ . iter.hasNext() val x = iter!getNext() transmogrify(x) end Linear complexity All accesses synchronised

  19. Relax Actor Isolation by Bestowing Activity val iter = l!iter() while iter!hasNext() val x = iter!getNext() transmogrify(x) iter end Linear complexity All accesses synchronised

  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

  21. Relax Actor Isolation by Bestowing Activity val iter = l!iter() while iter!hasNext() val x = iter!getNext() I bestow thee transmogrify(x) with activity! end Linear complexity All accesses synchronised

  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

  23. Delegating Parts of an Actor’s Interface actor A var c : C def foo() : unit … end class C def bar() : unit def beep() : unit … … end end def getC : bestowed [C] def boop() : unit bestow this.c … end end end end 14

  24. Delegating Parts of an Actor’s Interface actor A var c : C def foo() : unit … end class C def bar() : unit def beep() : unit … … end end def getC : bestowed [C] def boop() : unit bestow this.c … end end end end 14

  25. Formalising Bestowed References • Syntax 15

  26. Formalising Bestowed References Passive type • Syntax Message send Bestowing Bestowed type • Static semantics Actor type Bestowed value 15

  27. Formalising Bestowed References Passive type • Syntax Message send Bestowing Bestowed type • Static semantics Actor type Bestowed value 15

  28. Formalising Bestowed References • Dynamic semantics 16

  29. Formalising Bestowed References • Dynamic semantics 16

  30. Properties of the Formalism • Progress: • Preservation: • Data-race freedom: Two actors will never mutate the same passive object 17

  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

  32. Generalizing Bestowed References • Bestowed references provide a thread-safe way to break encapsulation ! 19

  33. Generalizing Bestowed References • Bestowed references provide a thread-safe way to break encapsulation ! 19

  34. Future Work • Implementation in Encore • Enriched formalism with copying and ownership transfer 20

  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

  36. Tack! Fr å gor?

  37. Incompatible Interleaving l!apply(f, 2) l!apply(f, 3) 23

  38. Incompatible Interleaving l!apply(f, 2) l!apply(f, 3) 23

  39. Incompatible Interleaving l!apply(f, 2) l!apply(f, 3) 23

  40. Incompatible Interleaving l!apply(f, 2) l!apply(f, 3) ? 23

  41. Grouping Messages atomic l l!apply(f, 2) l!apply(f, 3) end 24

  42. Grouping Messages atomic l l!apply(f, 2) l!apply(f, 3) end 24

  43. Grouping Messages atomic l l!apply(f, 2) l!apply(f, 3) end 24

  44. Grouping Messages atomic l l!apply(f, 2) l!apply(f, 3) end 24

  45. Grouping Locked operations atomic l l.apply(f, 2) l.apply(f, 3) end ! 25

  46. Polymorphic Concurrency Control def foo(l : safe List) : unit val iter = l.iter() atomic iter iter.apply(f) iter.apply(f) end ?

  47. Polymorphic Concurrency Control Bestowed def foo(l : safe List) : unit val iter = l.iter() atomic iter iter.apply(f) iter.apply(f) end ?

  48. Tack! Fr å gor?

  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

Recommend


More recommend