Share
Embed
Reactive Async: Expressive Deterministic Concurrency
Philipp Haller
October 31, 2016
Transcript
136 slides
-
Reactive Async: Expressive Deterministic Concurrency Philipp Haller1, Simon Geries1, Michael
Eichberg2, Guido Salvaneschi2 1 KTH Royal Institute of Technology, Sweden 2 TU Darmstadt, Germany -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Have we
solved concurrent programming, yet? 2 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Have we
solved concurrent programming, yet? The problem with concurrency: 2 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Have we
solved concurrent programming, yet? The problem with concurrency: – It’s difficult! 2 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Have we
solved concurrent programming, yet? The problem with concurrency: – It’s difficult! – Multiple hazards: 2 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Have we
solved concurrent programming, yet? The problem with concurrency: – It’s difficult! – Multiple hazards: • Race conditions 2 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Have we
solved concurrent programming, yet? The problem with concurrency: – It’s difficult! – Multiple hazards: • Race conditions • Deadlocks 2 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Have we
solved concurrent programming, yet? The problem with concurrency: – It’s difficult! – Multiple hazards: • Race conditions • Deadlocks • Livelocks 2 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Have we
solved concurrent programming, yet? The problem with concurrency: – It’s difficult! – Multiple hazards: • Race conditions • Deadlocks • Livelocks • Violation of fairness 2 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Non-Determinism •
At the root of several hazards 3 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Non-Determinism •
At the root of several hazards • Example 1: 3 @volatile var x = 0 def m(): Unit = { Future { x = 1 } Future { x = 2 } .. // does not access x } -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Non-Determinism •
At the root of several hazards • Example 1: 3 @volatile var x = 0 def m(): Unit = { Future { x = 1 } Future { x = 2 } .. // does not access x } What’s the value of x when an invocation of m returns? -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Reordering not
always a problem! • Example 2: 4 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Reordering not
always a problem! • Example 2: 4 import scala.collection.concurrent.TrieMap val set = new TrieMap[Int, Int] Future { set.put(1, 0) } set.put(2, 0) -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Reordering not
always a problem! • Example 2: 4 import scala.collection.concurrent.TrieMap val set = new TrieMap[Int, Int] Future { set.put(1, 0) } set.put(2, 0) Eventually, set contains both 1 and 2, always -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Reordering not
always a problem! • Example 2: 4 import scala.collection.concurrent.TrieMap val set = new TrieMap[Int, Int] Future { set.put(1, 0) } set.put(2, 0) Eventually, set contains both 1 and 2, always Bottom line: it depends on the datatype -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller … and
its operations! • Example 3: 5 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller … and
its operations! • Example 3: 5 val set = new TrieMap[Int, Int] Future { set.put(1, 0) } Future { if (set.contains(1)) { .. } } set.put(2, 0) -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller … and
its operations! • Example 3: 5 val set = new TrieMap[Int, Int] Future { set.put(1, 0) } Future { if (set.contains(1)) { .. } } set.put(2, 0) Result depends on schedule! -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Important Questions
Q1: How do we know we have written a deterministic concurrent program? 6 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Important Questions
Q1: How do we know we have written a deterministic concurrent program? – What about Heisenbugs? 6 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Important Questions
Q1: How do we know we have written a deterministic concurrent program? – What about Heisenbugs? • No race in 1’000’000 runs, race in run 1’000’001 6 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Important Questions
Q1: How do we know we have written a deterministic concurrent program? – What about Heisenbugs? • No race in 1’000’000 runs, race in run 1’000’001 6 Goal: simple criteria that guarantee determinism -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Important Questions
Q2: How do we ensure expressivity while providing determinism? 7 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Important Questions
Q2: How do we ensure expressivity while providing determinism? – Draconian restrictions undesired! 7 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Important Questions
Q2: How do we ensure expressivity while providing determinism? – Draconian restrictions undesired! 7 Goal: reconcile determinism and expressivity -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Approach •
Extend a future-style programming model with: 8 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Approach •
Extend a future-style programming model with: – Lattice-based datatypes 8 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Approach •
Extend a future-style programming model with: – Lattice-based datatypes – Quiescence 8 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Approach •
Extend a future-style programming model with: – Lattice-based datatypes – Quiescence 8 Crucial for determinism! -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Approach •
Extend a future-style programming model with: – Lattice-based datatypes – Quiescence – Resolution of cyclic dependencies 8 Crucial for determinism! -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Approach •
Extend a future-style programming model with: – Lattice-based datatypes – Quiescence – Resolution of cyclic dependencies 8 Crucial for determinism! Increases expressivity! -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Approach •
Extend a future-style programming model with: – Lattice-based datatypes – Quiescence – Resolution of cyclic dependencies • Evaluation of expressivity and performance – Case study: static analysis of JVM bytecode 8 Crucial for determinism! Increases expressivity! -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Programming Model
Programming model based on two core abstractions: cells and cell completers 9 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Programming Model
Programming model based on two core abstractions: cells and cell completers – Cell = shared “variable” 9 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Programming Model
Programming model based on two core abstractions: cells and cell completers – Cell = shared “variable” 9 Concurrently read and written -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Programming Model
Programming model based on two core abstractions: cells and cell completers – Cell = shared “variable” – Cell[K,V]: read-only interface; read values of type V (akin to Future[V]) 9 Concurrently read and written -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Programming Model
Programming model based on two core abstractions: cells and cell completers – Cell = shared “variable” – Cell[K,V]: read-only interface; read values of type V (akin to Future[V]) – CellCompleter[K,V] : write values of type V to its associated cell (akin to Promise[V]) 9 Concurrently read and written -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Programming Model
Programming model based on two core abstractions: cells and cell completers – Cell = shared “variable” – Cell[K,V]: read-only interface; read values of type V (akin to Future[V]) – CellCompleter[K,V] : write values of type V to its associated cell (akin to Promise[V]) – V must have an instance of a lattice type class 9 Concurrently read and written -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Programming Model
Programming model based on two core abstractions: cells and cell completers – Cell = shared “variable” – Cell[K,V]: read-only interface; read values of type V (akin to Future[V]) – CellCompleter[K,V] : write values of type V to its associated cell (akin to Promise[V]) – V must have an instance of a lattice type class 9 Monotonic updates Concurrently read and written -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Example •
Given a social graph 10 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Example •
Given a social graph – vertex = user 10 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Example •
Given a social graph – vertex = user • Traverse graph and collect IDs of “interesting” users 10 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Example •
Given a social graph – vertex = user • Traverse graph and collect IDs of “interesting” users • Graph large => concurrent traversal 10 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Solution •
Collect IDs of interesting users in a cell 11 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Solution •
Collect IDs of interesting users in a cell • Cell contains set of integers 11 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Solution •
Collect IDs of interesting users in a cell • Cell contains set of integers 11 OK: subsets of the set of all integers form a lattice -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Cell with
User IDs (code simplified) 12 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Cell with
User IDs (code simplified) 12 val userIDs = CellCompleter[Set[Int]] -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Cell with
User IDs (code simplified) 12 implicit object IntSetLattice extends Lattice[Set[Int]] { val empty = Set() def join(left: Set[Int], right: Set[Int]) = left ++ right } val userIDs = CellCompleter[Set[Int]] -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Cell with
User IDs (code simplified) 12 implicit object IntSetLattice extends Lattice[Set[Int]] { val empty = Set() def join(left: Set[Int], right: Set[Int]) = left ++ right } val userIDs = CellCompleter[Set[Int]] Bounded join-semilattice -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Cell with
User IDs (code simplified) 12 implicit object IntSetLattice extends Lattice[Set[Int]] { val empty = Set() def join(left: Set[Int], right: Set[Int]) = left ++ right } // add a user ID userIDs.putNext(Set(theUserID)) val userIDs = CellCompleter[Set[Int]] Bounded join-semilattice -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Reading Results
• Problem: when reading a cell’s value, how do we know this value is not going to change any more? 13 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Reading Results
• Problem: when reading a cell’s value, how do we know this value is not going to change any more? – There may still be ongoing concurrent activities 13 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Reading Results
• Problem: when reading a cell’s value, how do we know this value is not going to change any more? – There may still be ongoing concurrent activities – Manual synchronization (e.g., latches) error-prone 13 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Reading Results
• Problem: when reading a cell’s value, how do we know this value is not going to change any more? – There may still be ongoing concurrent activities – Manual synchronization (e.g., latches) error-prone • Solution: 13 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Reading Results
• Problem: when reading a cell’s value, how do we know this value is not going to change any more? – There may still be ongoing concurrent activities – Manual synchronization (e.g., latches) error-prone • Solution: 13 Koyaanisqatsi -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Reading Results
• Problem: when reading a cell’s value, how do we know this value is not going to change any more? – There may still be ongoing concurrent activities – Manual synchronization (e.g., latches) error-prone • Solution: 13 Koyaanisqatsi -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Reading Results
• Problem: when reading a cell’s value, how do we know this value is not going to change any more? – There may still be ongoing concurrent activities – Manual synchronization (e.g., latches) error-prone • Solution: 13 Quiescence -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Quiescence •
Intuitively: situation when values of cells are guaranteed not to change any more 14 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Quiescence •
Intuitively: situation when values of cells are guaranteed not to change any more • Technically: 14 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Quiescence •
Intuitively: situation when values of cells are guaranteed not to change any more • Technically: – No concurrent activities ongoing or scheduled which could change values of cells 14 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Quiescence •
Intuitively: situation when values of cells are guaranteed not to change any more • Technically: – No concurrent activities ongoing or scheduled which could change values of cells – Detected by the underlying thread pool 14 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Revisiting the
Example 15 val pool = new HandlerPool val userIDs = CellCompleter[Set[Int]](pool) -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Revisiting the
Example 15 // add a user ID userIDs.putNext(Set(theUserID)) .. val pool = new HandlerPool val userIDs = CellCompleter[Set[Int]](pool) -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Revisiting the
Example 15 // add a user ID userIDs.putNext(Set(theUserID)) .. val pool = new HandlerPool val userIDs = CellCompleter[Set[Int]](pool) // register handler // upon quiescence: read result value of cell pool.onQuiescent(userIDs.cell) { collectedIDs => .. } -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Revisiting the
Example 15 // add a user ID userIDs.putNext(Set(theUserID)) .. val pool = new HandlerPool val userIDs = CellCompleter[Set[Int]](pool) // register handler // upon quiescence: read result value of cell pool.onQuiescent(userIDs.cell) { collectedIDs => .. } Safe to read from cell when pool quiescent! -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Handler Pools
Execution context with extensions: 16 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Handler Pools
Execution context with extensions: – Event-driven quiescence API 16 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Handler Pools
Execution context with extensions: – Event-driven quiescence API – Resolution of dependencies between cells 16 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Handler Pools
Execution context with extensions: – Event-driven quiescence API – Resolution of dependencies between cells 16 Dependency resolution? -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Expressing Concurrent
Dataflow • Cells provide non-blocking interface 17 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Expressing Concurrent
Dataflow • Cells provide non-blocking interface – Low level: callbacks 17 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Expressing Concurrent
Dataflow • Cells provide non-blocking interface – Low level: callbacks – High level: combinators 17 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Expressing Concurrent
Dataflow • Cells provide non-blocking interface – Low level: callbacks – High level: combinators 17 Like futures -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Expressing Concurrent
Dataflow • Cells provide non-blocking interface – Low level: callbacks – High level: combinators • Important purpose: express concurrent dataflow 17 Like futures -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Expressing Concurrent
Dataflow • Cells provide non-blocking interface – Low level: callbacks – High level: combinators • Important purpose: express concurrent dataflow 17 Like futures fut.map(fun).filter(pred) -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Expressing Concurrent
Dataflow • Cells provide non-blocking interface – Low level: callbacks – High level: combinators • Important purpose: express concurrent dataflow 17 Like futures fut.map(fun).filter(pred) Futures -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Expressing Concurrent
Dataflow • Cells provide non-blocking interface – Low level: callbacks – High level: combinators • Important purpose: express concurrent dataflow 17 Like futures fut fun fut’ pred fut’’ fut.map(fun).filter(pred) Futures -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Expressing Concurrent
Dataflow • Cells provide non-blocking interface – Low level: callbacks – High level: combinators • Important purpose: express concurrent dataflow • Problem: 17 Like futures fut fun fut’ pred fut’’ fut.map(fun).filter(pred) Futures -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Expressing Concurrent
Dataflow • Cells provide non-blocking interface – Low level: callbacks – High level: combinators • Important purpose: express concurrent dataflow • Problem: 17 What if the dataflow graph is cyclic? Like futures fut fun fut’ pred fut’’ fut.map(fun).filter(pred) Futures -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Dataflow Graphs
Example: • Static analysis of JVM bytecode 18 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Dataflow Graphs
Example: • Static analysis of JVM bytecode • Task: Determine purity of methods 18 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Dataflow Graphs
Example: • Static analysis of JVM bytecode • Task: Determine purity of methods • Rules: 18 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Dataflow Graphs
Example: • Static analysis of JVM bytecode • Task: Determine purity of methods • Rules: – A method is impure if it accesses a non-final field 18 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Dataflow Graphs
Example: • Static analysis of JVM bytecode • Task: Determine purity of methods • Rules: – A method is impure if it accesses a non-final field – A method is impure if it calls an impure method 18 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Dataflow Graphs
Example: • Static analysis of JVM bytecode • Task: Determine purity of methods • Rules: – A method is impure if it accesses a non-final field – A method is impure if it calls an impure method – … 18 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Dataflow Graphs
Example: • Static analysis of JVM bytecode • Task: Determine purity of methods • Rules: – A method is impure if it accesses a non-final field – A method is impure if it calls an impure method – … 18 A -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Dataflow Graphs
Example: • Static analysis of JVM bytecode • Task: Determine purity of methods • Rules: – A method is impure if it accesses a non-final field – A method is impure if it calls an impure method – … 18 A B -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Dataflow Graphs
Example: • Static analysis of JVM bytecode • Task: Determine purity of methods • Rules: – A method is impure if it accesses a non-final field – A method is impure if it calls an impure method – … 18 A B “calls” -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Dataflow Graphs
Example: • Static analysis of JVM bytecode • Task: Determine purity of methods • Rules: – A method is impure if it accesses a non-final field – A method is impure if it calls an impure method – … 18 A B C “calls” -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Dataflow Graphs
Example: • Static analysis of JVM bytecode • Task: Determine purity of methods • Rules: – A method is impure if it accesses a non-final field – A method is impure if it calls an impure method – … 18 A B C “calls” -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Cycle Resolution
• What if upon quiescence cells are empty and there is a dependency cycle? 19 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Cycle Resolution
• What if upon quiescence cells are empty and there is a dependency cycle? 19 A B C -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Cycle Resolution
• What if upon quiescence cells are empty and there is a dependency cycle? • Idea: Pluggable resolution policies 19 A B C -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Cycle Resolution
• What if upon quiescence cells are empty and there is a dependency cycle? • Idea: Pluggable resolution policies • Example: Purity analysis should resolve all cells in cycle to “pure”, since could not show impurity 19 A B C -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Specifying Resolution
Policies • Role of the first type parameter of Cell[K,V] 20 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Specifying Resolution
Policies • Role of the first type parameter of Cell[K,V] • Example: 20 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Specifying Resolution
Policies • Role of the first type parameter of Cell[K,V] • Example: 20 object PurityKey extends Key[Purity] { def resolve[K <: Key[Purity]](cells: Seq[Cell[K, Purity]]) = cells.map(cell => (cell, Pure)) .. } -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Specifying Resolution
Policies • Role of the first type parameter of Cell[K,V] • Example: 20 object PurityKey extends Key[Purity] { def resolve[K <: Key[Purity]](cells: Seq[Cell[K, Purity]]) = cells.map(cell => (cell, Pure)) .. } resolve all cells to Pure -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Specifying Resolution
Policies • Role of the first type parameter of Cell[K,V] • Example: 20 object PurityKey extends Key[Purity] { def resolve[K <: Key[Purity]](cells: Seq[Cell[K, Purity]]) = cells.map(cell => (cell, Pure)) .. } closed strongly- connected component -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Purity Analysis:
Set-up 21 for { classFile <- project.allProjectClassFiles method <- classFile.methods } { val methodCompleter = CellCompleter(pool, PurityKey) pool.execute { analyze(project, methodCompleter, classFile, method) } } val analysisDoneFuture = pool.quiescentResolveCells() -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Evaluation •
Static analysis of JVM bytecode using the OPAL framework (OPen extensible Analysis Library) 22 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Evaluation •
Static analysis of JVM bytecode using the OPAL framework (OPen extensible Analysis Library) – New Scala-based, extensible bytecode toolkit 22 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Evaluation •
Static analysis of JVM bytecode using the OPAL framework (OPen extensible Analysis Library) – New Scala-based, extensible bytecode toolkit – Fully concurrent 22 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Evaluation •
Static analysis of JVM bytecode using the OPAL framework (OPen extensible Analysis Library) – New Scala-based, extensible bytecode toolkit – Fully concurrent 22 http://www.opal-project.de -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Evaluation •
Static analysis of JVM bytecode using the OPAL framework (OPen extensible Analysis Library) – New Scala-based, extensible bytecode toolkit – Fully concurrent • Rewrote purity analysis and immutability analysis 22 http://www.opal-project.de -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Evaluation •
Static analysis of JVM bytecode using the OPAL framework (OPen extensible Analysis Library) – New Scala-based, extensible bytecode toolkit – Fully concurrent • Rewrote purity analysis and immutability analysis • Ran analysis on JDK 8 update 45 (rt.jar) 22 http://www.opal-project.de -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Evaluation •
Static analysis of JVM bytecode using the OPAL framework (OPen extensible Analysis Library) – New Scala-based, extensible bytecode toolkit – Fully concurrent • Rewrote purity analysis and immutability analysis • Ran analysis on JDK 8 update 45 (rt.jar) – 18’591 class files, 163’268 methods, 77’128 fields 22 http://www.opal-project.de -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Results: Immutability
Analysis • RA about 10x faster than FPCF • RA = 294 LOC, FPCF = 424 LOC (1.44x) 23 FPCF (secs.) 1.0 1.5 2.0 2.5 Reactive-Async (secs.) 0.1 0.2 0.3 1 Thread 2 Threads 4 Threads 8 Threads 16 Threads 2.15 2.20 2.25 2.30 2.35 1.15 1.20 1.25 1.30 1.35 0.290 0.295 0.300 0.105 0.110 0.115 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Results: Immutability
Analysis • RA about 10x faster than FPCF • RA = 294 LOC, FPCF = 424 LOC (1.44x) 23 FPCF (secs.) 1.0 1.5 2.0 2.5 Reactive-Async (secs.) 0.1 0.2 0.3 1 Thread 2 Threads 4 Threads 8 Threads 16 Threads 2.15 2.20 2.25 2.30 2.35 1.15 1.20 1.25 1.30 1.35 0.290 0.295 0.300 0.105 0.110 0.115 box plot: whiskers = min/max top/bottom of box = 1st and 3rd quartile band in box: median -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Results: Immutability
Analysis • RA about 10x faster than FPCF • RA = 294 LOC, FPCF = 424 LOC (1.44x) 23 FPCF (secs.) 1.0 1.5 2.0 2.5 Reactive-Async (secs.) 0.1 0.2 0.3 1 Thread 2 Threads 4 Threads 8 Threads 16 Threads 2.15 2.20 2.25 2.30 2.35 1.15 1.20 1.25 1.30 1.35 0.290 0.295 0.300 0.105 0.110 0.115 box plot: whiskers = min/max top/bottom of box = 1st and 3rd quartile band in box: median FPCF = OPAL’s fixed point computation framework -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Results: Purity
Analysis • Best configs. (FPCF: 4 thr, RA: 16 thr): RA 1.75x faster • RA = 113 LOC, FPCF = 166 LOC (1.47x) 24 FPCF (secs.) 0.15 0.20 0.25 0.30 0.35 Reactive-Async (secs.) 0.1 0.2 0.3 0.4 0.5 1 Thread 2 Threads 4 Threads 8 Threads 16 Threads 0.43 0.44 0.45 0.09 0.10 0.11 0.335 0.340 0.345 0.165 0.170 0.175 0.180 0.185 0.18 0.19 0.20 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Benchmarks: Monte
Carlo Simulation • Compute Net Present Value • 14-16 threads: Scala futures 23-36% faster than RA 25 Sequential Reactive Async Scala Futures 2.11.7 Runtime (ms) 0 1000 2000 3000 4000 5000 6000 Number of Threads 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 400 500 600 700 14 15 16 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Benchmarks: Parallel
Sum • Parallel sum of large collection of random ints • Performance competitive with Scala’s futures 26 Sequential Reactive Async Scala Futures 2.11.7 Runtime (ms) 0 50 100 150 200 250 300 Number of Threads 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Related Work
• Deterministic-by-construction programming models – KPNs, concurrent revisions, FlowPools, LVars, etc. • Static vs. dynamic enforcement of determinism • Reactive programming models – Dynamic dependencies, determinism • See paper for discussion 27 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Reactive Async:
Conclusion • New concurrent programming model – Lattices and quiescence for determinism – Resolution of cyclic dependencies • Promising experimental results • Future work: – Optimization – Determinism as a statically-checked effect 28 -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Reactive Async:
Conclusion • New concurrent programming model – Lattices and quiescence for determinism – Resolution of cyclic dependencies • Promising experimental results • Future work: – Optimization – Determinism as a statically-checked effect 28 https://github.com/phaller/reactive-async -
Reactive Async: Expressive Deterministic Concurrency — Philipp Haller Reactive Async:
Conclusion • New concurrent programming model – Lattices and quiescence for determinism – Resolution of cyclic dependencies • Promising experimental results • Future work: – Optimization – Determinism as a statically-checked effect 28 https://github.com/phaller/reactive-async Thank you!