Slide 1

Slide 1 text

Concurrent Revisions Daniel W. H. James @dwhjames

Slide 2

Slide 2 text

This is not the Akka talk you were looking for…

Slide 3

Slide 3 text

What if your program could be concurrent in the same way that you use git?

Slide 4

Slide 4 text

research.microsoft.com/ en-us/projects/revisions Disclosure: not my work!

Slide 5

Slide 5 text

Sebastian Burckhardt, Alexandro Baldassion, and Daan Leijen. Concurrent Programming with Revisions and Isolation Types. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA’10), ACM SIGPLAN, Reno, NV, October 2010 Daan Leijen, Sebastian Burckhardt, and Manuel Fahndrich. Prettier Concurrency: Purely Functional Concurrent Revisions. In Haskell Symposium 2011 (Haskell’11), ACM SIGPLAN, Tokyo, Japan, 7 July 2011 Disclosure: not my work!

Slide 6

Slide 6 text

val v = VersionedValue(0) isolation type ->

Slide 7

Slide 7 text

val v = VersionedValue(0)

Slide 8

Slide 8 text

val v = VersionedValue(0) val r = Revision.fork { assert(v.value === 0) v.value = 1 }

Slide 9

Slide 9 text

val v = VersionedValue(0) val r = Revision.fork { assert(v.value === 0) v.value = 1 } assert(v.value === 0)

Slide 10

Slide 10 text

val v = VersionedValue(0) val r = Revision.fork { assert(v.value === 0) v.value = 1 } assert(v.value === 0) Revision.join(r) assert(v.value === 1)

Slide 11

Slide 11 text

val v = VersionedValue(0) val r = Revision.fork { assert(v.value === 0) v.value = 1 }

Slide 12

Slide 12 text

val v = VersionedValue(0) val r = Revision.fork { assert(v.value === 0) v.value = 1 } v.value = 2

Slide 13

Slide 13 text

val v = VersionedValue(0) val r = Revision.fork { assert(v.value === 0) v.value = 1 } v.value = 2 assert(v.value === 2)

Slide 14

Slide 14 text

val v = VersionedValue(0) val r = Revision.fork { assert(v.value === 0) v.value = 1 } v.value = 2 assert(v.value === 2) Revision.join(r) assert(v.value === 1)

Slide 15

Slide 15 text

git merge -X theirs myRev

Slide 16

Slide 16 text

val v = CumulativeValue(1, addMerge) isolation type -> merge fn ->

Slide 17

Slide 17 text

val v = CumulativeValue(1, addMerge)

Slide 18

Slide 18 text

val v = CumulativeValue(1, addMerge) val r = Revision.fork { assert(v.value === 1) v.value += 2 }

Slide 19

Slide 19 text

val v = CumulativeValue(1, addMerge) val r = Revision.fork { assert(v.value === 1) v.value += 2 } v.value += 3

Slide 20

Slide 20 text

val v = CumulativeValue(1, addMerge) val r = Revision.fork { assert(v.value === 1) v.value += 2 } v.value += 3 assert(v.value === 4)

Slide 21

Slide 21 text

val v = CumulativeValue(1, addMerge) val r = Revision.fork { assert(v.value === 1) v.value += 2 } v.value += 3 assert(v.value === 4) Revision.join(r) assert(v.value === 6)

Slide 22

Slide 22 text

val addMerge = (root: Int, main: Int, join: Int) => main + join - root

Slide 23

Slide 23 text

v = 1 v += 2 v += 3 assert(v === 6)

Slide 24

Slide 24 text

val x = VersionedValue(0) val y = VersionedValue(0) val r = Revision.fork { if (x.value == 0) y.value += 1 } if (y.value == 0) x.value += 1 Revision.join(r) assert(x.value === ???) assert(y.value === ???)

Slide 25

Slide 25 text

x = 0 y = 0 if(y==0) x++ assert(???) if(x==0) y++

Slide 26

Slide 26 text

x = 0 y = 0 if(y==0) x++ assert((x==0 && y==1) || (x==1 && y==0) || (x==1 && y==1)) if(x==0) y++ sequential consistency

Slide 27

Slide 27 text

x = 0 y = 0 lock.synchronized { if(y==0) x++ } assert((x==0 && y==1) || (x==1 && y==0)) lock.synchronized { if(x==0) y++ } mutex lock

Slide 28

Slide 28 text

x = 0 y = 0 atomic { if(y==0) x++ } assert((x==0 && y==1) || (x==1 && y==0)) atomic { if(x==0) y++ } transactional memory

Slide 29

Slide 29 text

x = 0 y = 0 if(y==0) x++ assert(x==1 && y==1) if(x==0) y++ concurrent revisions

Slide 30

Slide 30 text

github.com/dwhjames/ scala-concurrent-revisions

Slide 31

Slide 31 text

Demo!