We ¡Have ¡a ¡DREAM: ¡Distributed ¡ Reac5ve ¡Programming ¡with ¡ Consistency ¡Guarantees ¡
Alessandro ¡Margara, ¡Guido ¡Salvaneschi ¡
¡
We Have a DREAM: Distributed Reac5ve Programming with - - PowerPoint PPT Presentation
We Have a DREAM: Distributed Reac5ve Programming with Consistency Guarantees Alessandro Margara, Guido Salvaneschi Presented by Wilfried Daniels Introduc5on
¡
1 var a: int = 10 2 var b: int = a + 2 3 println(b) // 12 4 a = 11 5 println(b) // 12 1 var a: int = 10 2 var b: int := a + 2 3 println(b) // 12 4 a = 11 5 println(b) // 13
V1 V2 V3
1 var marketIndex = InputModule.getMarketIndex() 2 var stockOpts = InputModule.getStockOpts() 3 var news = InputModule.getNews() 4 5 // Forecasts according to different models 6 var f1 := Model1.compute(marketIndex,stockOpts) 7 var f2 := Model2.compute(marketIndex,stockOpts) 8 var f3 := Model3.compute(marketIndex,news) 9 10 var gui := Display.show(f1,f2,f3) 11 12 var financialAlert := ((f1+f2+f3)/3) < MAX 13 if (financialAlert) decrease(stockOpts) 14 15 var financialAlert_n := computeAlert_n(f1,f2,f3) 16 if (financialAlert_n) adjust_n(stockOpts)
Observable ¡ 5me-‑varying ¡variables ¡ Dependent ¡ Reac5ve ¡expressions ¡ Reac5ve ¡expressions ¡ resul5ng ¡in ¡3 ¡ alterna5ve ¡outputs, ¡ each ¡requiring ¡ different ¡consistency ¡ guarantees ¡
9 10 var gui := Display.show(f1,f2,f3) 11
11 12 var financialAlert := ((f1+f2+f3)/3) < MAX 13 if (financialAlert) decrease(stockOpts) 14
V2
11 12 var financialAlert := ((f1+f2+f3)/3) < MAX 13 if (financialAlert) decrease(stockOpts) 14
V3
14 15 var financialAlert_n := computeAlert_n(f1,f2,f3) 16 if (financialAlert_n) adjust_n(stockOpts)
Communication Channel
c c c c c c c c c c c c
vi1 vi2 vin
Reac5ve ¡(+ ¡observable) ¡variable ¡ Observable ¡variables ¡
ph D = {V, E}, re V
f1 f2 f3 marketIndex stockOpts gui financialAlert news
t u(S, wx(v)), S = {wy1(v1) . . . wyn(vn)}
¡
¡
∀vi, vj t vj n u( n vi, i ) ∈ S
, if wx1(vi) re wx2(vi) (v ) ∈ S n u(S1), wx1(vi) ∈ S1 re u(S2),
x2 i
We ¡define ¡a ¡happened ¡before ¡( ¡ ¡ ¡ ¡ ¡) ¡par5al ¡order ¡rela5on: ¡
(a ¡write ¡happens ¡before ¡an ¡update ¡depending ¡on ¡it) ¡
ts e1, e2
n e1 → e2
if e1 re e2
if e1 = wx(vi) and e2 = u(Si, wy(vj)), wx(vi) ∈ Si,
n e1 → e2 n e1 → e2
e2 → e3, n e1 → e3
¡
s Vd. ariable v tha ll Vd1 ⊆ Vd
v u(S, wx(v))
nd S ⊂ Vd1
ble v1
¡
s u(Si, wy(vi)) by wx(v)
1 public class ObservableInteger extends Observable { 2
private int val;
3 4
// Constructors ...
5 6
@ImpactsOn(methods = { "get" })
7
public final void set(int val) {
8
this.val = val;
9
}
10 11
public final int get() {
12
return val;
13
}
14 }
1 // Component c1 2 ObservableInteger obInt = 3
new ObservableInteger("obInt1", 1, LOCAL);
4 ObservableString obStr1 = 5
new ObservableString("obStr1", "a", GLOBAL);
6 ObservableString obStr2 = ... 7 8 // Component c2 9 ReactiveInteger rInt = ReactiveFactory. 10
getInteger("obInt.get()*2");
11 ReactiveString rStr = ReactiveFactory. 12
getString("obStr1.get()+obStr2.get()");
13 while(true){ 14
System.out.println(rStr.get())
15
Thread.sleep(500)
16 } 17 18 // Component c3 19 ReactiveInteger strLen = 20
ReactiveFactory.getObservableInteger
21
("c1.obString1.get().length()", "obString1Len");
Watcher B B B B B B R
c c c c c c c c c c c c
CommunicationManager Reactive Object Observable Object
Subscribe Notify Advertise/Notify
through ¡notify(c,obj,obm,val) ¡
CommunicationManager ¡
Watcher B B B B B B R
c c c c c c c c c c c c
CommunicationManager Reactive Object Observable Object
Subscribe Notify Advertise/Notify
Number of brokers 10 Number of components 50 Topology of broker network Scale-free Percentage of pure forwarders 50% Distribution of components Uniform Link latency 1 ms–5 ms Number of reactive graphs 10 Size of dependency graphs 5 Size of reactive expressions 2 Degree of locality in expressions 0.8 Frequency of change for observable objects 1 change/s
Delay (ms) Traffic (KB/s) Centr. Distr. Centr. Distr. Causal 4.77 4.76 68.3 69.8 Glitch free 29.53 17.18 205.4 130.9 Atomic 53.41 26.75 265.5 161.3
10 20 30 40 50 60 0.2 0.4 0.6 0.8 1 Average Delay (ms) Degree of Locality Causal Glitch Free Atomic
(a) Delay
100 200 300 400 500 0.2 0.4 0.6 0.8 1 Overall Traffic (KB/s) Degree of Locality Causal Glitch Free Atomic
(b) Traffic Completely ¡local ¡+ ¡causal ¡= ¡0 ¡costs ¡ Completely ¡remote ¡+ ¡causal ¡= ¡glitches! ¡
Degree of Locality 10 20 30 40 50 60 2 4 6 8 10 12 14 16 Average Delay (ms) Number of Objects per Graph Causal Glitch Free Atomic
(a) Delay
200 400 600 800 1000 2 4 6 8 10 12 14 16 Overall Traffic (KB/s) Number of Objects per Graph Causal Glitch Free Atomic
(b) Traffic
Long ¡chains ¡of ¡reac5ve ¡vars ¡+ ¡causal ¡= ¡glitches! ¡
20 40 60 80 100 1 2 3 4 5 6 7 8 Average Delay (ms) Number of Objects per Expression Causal Glitch Free Atomic
(a) Delay
200 400 600 800 1000 1200 1400 1600 1 2 3 4 5 6 7 8 Overall Traffic (KB/s) Number of Objects per Expression Causal Glitch Free Atomic
(b) Traffic
More ¡vars/expression ¡+ ¡causal ¡= ¡glitches! ¡
0.5 1 1.5 2 2.5 3 3.5 4 1 10 100 1000 Propagation Delay (ms) Number of Operators Causal Glitch Free Atomic