Petri Net-Flavored Places An Advanced Transition System for Distributed Computing in Racket J¨ orgen Brandt 2018-09-29
Software Engineering
Petri Nets ◮ Visually understandable ◮ Defined semantics (properties, invariants, correctness) ◮ Complete (can be executed, tested) Storage cookie_box cookie_box cookie_box a cookie_box cookie_box CoinSlot Compartment coin sig sig Signal b coin CashBox
Petri Net Syntax ◮ Passive component: #Ref<0.4.2.1> Place Down
Petri Net Syntax m Down down_busy ◮ Passive component: ( r , m , p ) p Place ◮ Active component: Transition Busy Idle
Petri Net Syntax ◮ Passive component: Place op x f ( x ) ◮ Active component: Request Reply Transition ◮ Environment “High-level interface nets”
Example
Implementation: Cookie Vending Machine Storage cookie_box cookie_box cookie_box a cookie_box cookie_box CoinSlot Compartment coin sig sig Signal b coin CashBox https://github.com/joergen7/pnet
Implementation: Cookie Vending Machine
Implementation: Cookie Vending Machine
Implementation: Cookie Vending Machine
Implementation: Cookie Vending Machine
Implementation: Cookie Vending Machine
Possible Application: Cuneiform
Cuneiform: Motivation ◮ Cuneiform is . . . ◮ Functional programming language ◮ Distributed language ◮ Integration of other languages ◮ Open: ◮ command line tools ◮ R scripts ◮ Python libraries ◮ . . . ◮ General: ◮ Universal model of computation https://cuneiform-lang.org
Cuneiform Code Example: Iteration def f( txt : File ) -> <y : File> in Perl *{ ... }* let xs : [File] = ['a.txt', 'b.txt' : File]; for x <- xs do f( txt = x )|y end ;
Distrubuted Execution Environment: Sequence Diagram c m w 1 w 2 •••• e
Distributed Execution Environment: Sequence Diagram c m w 1 w 2 •••• e a 1 ,..., a 4
Distributed Execution Environment: Sequence Diagram c m w 1 w 2 •••• e a 1 ,..., a 4 a 1 a 2
Distributed Execution Environment: Sequence Diagram c m w 1 w 2 •••• e a 1 ,..., a 4 a 1 a 2 ( a 1 , r 1 )
Distributed Execution Environment: Sequence Diagram c m w 1 w 2 •••• e a 1 ,..., a 4 a 1 a 2 ( a 1 , r 1 ) • ( a 1 , r 1 )
Distributed Execution Environment: Sequence Diagram c m w 1 w 2 •••• e a 1 ,..., a 4 a 1 a 2 ( a 1 , r 1 ) • a 3 ( a 1 , r 1 ) ( a 2 , r 2 ) • ( a 2 , r 2 ) ( a 3 , r 3 ) • ( a 3 , r 3 ) ( a 4 , r 4 ) • ( a 4 , r 4 )
Distributed Execution Environment: Sequence Diagram c m w 1 w 2 •••• e a 1 ,..., a 4 a 1 a 2 ( a 1 , r 1 ) • a 3 ( a 1 , r 1 ) ( a 2 , r 2 ) • ( a 2 , r 2 ) ( a 3 , r 3 ) • ( a 3 , r 3 ) ( a 4 , r 4 ) • v ( a 4 , r 4 )
Distributed Execution Environment: Sequence Diagram c m w 1 w 2 Three interfaces •••• Between . . . e ◮ User and client a 1 ,..., a 4 a 1 a 2 expressions, values ( a 1 , r 1 ) • a 3 ( a 1 , r 1 ) ( a 2 , r 2 ) • ( a 2 , r 2 ) ( a 3 , r 3 ) • ( a 3 , r 3 ) ( a 4 , r 4 ) • v ( a 4 , r 4 )
Distributed Execution Environment: Sequence Diagram c m w 1 w 2 Three interfaces •••• Between . . . e ◮ User and client a 1 ,..., a 4 a 1 a 2 expressions, values ◮ Client and master ( a 1 , r 1 ) • a 3 ( a 1 , r 1 ) ( a 2 , r 2 ) • demand, applications, results ( a 2 , r 2 ) ( a 3 , r 3 ) • ( a 3 , r 3 ) ( a 4 , r 4 ) • v ( a 4 , r 4 )
Distributed Execution Environment: Sequence Diagram c m w 1 w 2 Three interfaces •••• Between . . . e ◮ User and client a 1 ,..., a 4 a 1 a 2 expressions, values ◮ Client and master ( a 1 , r 1 ) • a 3 ( a 1 , r 1 ) ( a 2 , r 2 ) • demand, applications, results ( a 2 , r 2 ) ( a 3 , r 3 ) ◮ Master and worker • ( a 3 , r 3 ) applications, results ( a 4 , r 4 ) • v ( a 4 , r 4 )
Distributed Execution Environment: Petri Net Model c i m w j ◮ The sequence diagram suggests a coarse structure ◮ Composing nets in a distributed system ◮ m independent clients and n independent workers
Distributed Execution Environment: Master (i) m CRE master features ◮ Cache ◮ Scheduler ◮ Fault tolerance ◮ Language-independence
Distributed Execution Environment: Master (ii) ExitClient AddClient q q BadClient ClientPool link_worker n • p q q q link_client AddWorker q remove_client Demand Guard q q q q [] SentDemand p q q recover_demand send_demand A A +[ a ] q • Introduced Allowed schedule (( q , i ), a ) a a a ∉ A a a ( p , a ) CreRequest WorkerRequest introduce allow p ( p , a ) (( q , i ), a ) a lookup ( a , δ ) BusyDemand Cache WorkerPool BusyWorker DemandPool (a, δ ) (( q , i ), a ) ( a , δ ) • p ( p , a ) ( a , δ ) CreReply WorkerResult (( q , i ), a , δ ) ( a , δ ) ( a , δ ) (( p , a ), δ ) release address Released a ( p , a ) • • p n • • reallow cre_master p ExitWorker remove_demand Surplus n • a , δ∈ Expr n ∈ ℕ ,n>0 p r ∈ Result i ∈ℕ remove_worker e ∈ Error p , q ∈ Pid
Cuneiform Application: Variant Calling with GATK https://cuneiform-lang.org
Wrap up
Related Work ◮ CPNTools : Graphical editor with code generation to Erlang ◮ Haskell-colored Petri nets : Functional embeddings
Conclusion ◮ Petri nets as a programming model ◮ Visual interpretation of code ◮ Composition to form distributed systems ◮ Petri net on the inside ◮ Racket place on the outside https://github.com/joergen7/pnet
Recommend
More recommend