SlideShare a Scribd company logo
Ponylang
2018/02/17 Hacker Tackle 2018
@matsu_chara
- @matsu_chara
- FOLIO Scala
- Pony 2
1.
2. Concurrency
3. Ponylang
4. Ponylang
Pony
-
-
- 2015 v0.1
- pre v1.0
1
- Pony
-
-
-
- =>
Concurrency
2
Concurrency
-
-
※
Concurrency
data-race, deadlock, …
/
Ponylangとこれからの並行プログラミング
- Shared Memory & Synchronization
- Actor Model
-
1. Shared Memory & Synchronization
-
-
-
-
Synchronization
- lock
deadlock
- lock
- lock
2. Actor model
- Actor
- Actor Message Passing
- Actor
- Actor
- 1 Actor 1
Actor
Actor ActorActor
Actor model
-
-
-
-
※
Actor
Actor ActorActor
Actor
Actor model
-
- Message
Shared-Memory
class Counter extends Actor {
val set = mutable.Set[Int]()
def receive = { case data: Int =>
set.add(data)
resetter ! set
}
}
class Resetter extends Actor {
def receive = { case set: mutable.Set[_] =>
if(set.size > 10) set.clear()
}
}
mutable
※ code Pony
※ scala var + immutable copy
https://doc.akka.io/docs/akka/2.5.6/scala/general/jmm.html#actors-and-shared-mutable-state
race-condition
( )
( )
- data-race dead-lock Actor
( )
- data-race dead-lock Actor
-
( )
- data-race dead-lock Actor
-
-
Pony
- data-race dead-lock
Actor
-
-
-
Ponylang
3
Actor model Shared Memory
- Pony Deny Capabilities
for Safe, Fast Actors
-
-
- Transfer Isolated State
- Share Immutable
-
※ https://github.com/jemc/slides-pony
a. Transfer Isolated State
-
-
-
a. Transfer Isolated State
Pros
- zero-copy mutable
Cons
-
b. Share Immutable State
- Immutable
Share Immutable State
- mutable immutable
- mutable
- Immutable
-
write
- write-unique
immutable? mutable?write-unique?
Pony Reference Capability
※ val
Reference Capability
iso - Isolated
- read/write unique
-
-
- Transfer Isolated State
iso
isoな参照
iso
write-uniqueなので
writeできる
iso
isoな参照を増やそうとすると
read/write�uniqueで
なくなるのでコンパイルエラー
iso
consumeで参照を破棄
他アクターに渡す
iso
consume後に参照すると
コンパイルエラー
val - Immutable -
-
- read
- Share Immutable State
trn - Transition -
- Write Unique
- val
capability
- box: Read Only
- ref: mutable
- tag: read/write
6
Ponylang
4
- Pony GC
read/write barrier [1][2]
-
-
- Pony
Wallaroo
- Pony Stream
- Python/Go binding
-
- Why we used Pony to write Wallaroo
reddit Pony Rust
https://www.wallaroolabs.com/
Distributed Pony
- Pony
- work-steeling
-
- GC
- Pony
-
runtime Pony
- Concurrency Pony
-
(pony )

More Related Content

Ponylangとこれからの並行プログラミング