carlos damásiotapd 2000, vigo1 a distributed tabling system carlos viegas damásio...
Post on 22-Dec-2015
215 views
TRANSCRIPT
Carlos Damásio TAPD 2000, Vigo 1
A Distributed Tabling System
Carlos Viegas Damásio ([email protected])
Dept. Informática, Univ. Nova de Lisboa
Portugal
Carlos Damásio TAPD 2000, Vigo 2
Overview
• Objectives of this work
• The Distributed Tabling Architecture
• Architecture Components
• A running example
• Completion and Termination
• Conclusions
Carlos Damásio TAPD 2000, Vigo 3
Objectives
• Define a general and “open” architecture for distributed tabled query-evaluation of definite logic programs.
• Address the issue of table completion resorting to known distributed algorithms.
Carlos Damásio TAPD 2000, Vigo 4
Architecture Components
• 1 Goal Manager
• 1 Table Manager
• N Table Storage Clients
• N Prover Clients
Carlos Damásio TAPD 2000, Vigo 5
Goal Manager
• Interfaces the distributed tabling system with the “outside” world.
• It accepts queries and provides answers to the queries.
• Detects termination of the computation
Carlos Damásio TAPD 2000, Vigo 6
Table Manager
• Decides the location of the tables among the several table storage clients, guaranteeing uniqueness of the tables.
• If all prover clients know where a goal should be tabled, then the Table Manager can be removed from the architecture
Carlos Damásio TAPD 2000, Vigo 7
Table Storage Clients
• Keep the answers for given goal calls, avoiding redundant answers.
• They manage the delivery of solutions to the appropriate invoking goals
Carlos Damásio TAPD 2000, Vigo 8
Prover Clients
• Perform the logical expansion operations on the set of active goals.
Carlos Damásio TAPD 2000, Vigo 9
Message Protocol
Goal Manager Table Manager
query(Vars, Body, N)
answer(Lit,Gid)
call(Lit,Gid)
Table Storage Prover
call(Lit,Gid)call(Lit,Gid)
table(Lit,TS)
call(Lit,Tid)
answer(Lit,Gid)
answer(Lit,Tid)
call(Lit,Gid)
answer(Vars, N)
Carlos Damásio TAPD 2000, Vigo 10
Message Complexity
• Goal call:– at least 1 message and at most 4 messages.– If the table manager is not involved, at least 1
message and at most 2 messages.
• Answer return:– 1 plus the number of consumers of the table.
So, at least 2 messages.
Carlos Damásio TAPD 2000, Vigo 12
Goal Manager Table Manager
1. query([X], b(X), 5)
2. assert(q0(X) b(X) )
table[q0(_)] := ts1
3. call(q0(X), 0)
Prover 1
T. Storage 1
Prover 2
T. Storage 2
4. assert(q0(X) b(X) )
5. assert(q0(X) b(X) )
6. table(q0(_), ts1)
7. call(q0(X),0)
tabling[q0(_)] := t0
consumer[t0] := {(gm,0)}
8. call(q0(X1),t0)
[t0] 0: q0(X1) b(X1)
9. call(b(X1),0)
tabling[b(_)] := t0
consumer[t0] := {(p1,0)}
10. call(b(X2),t0)
[t0] 0: b(X3) a(X3)
[t0] b(0).
Carlos Damásio TAPD 2000, Vigo 13
Prover 2T. Storage 2
tabling[b(_)] := t0
consumer[t0] := (p1,0)
11. call(a(X3),0)
[t0] 0: b(X3) a(X3)
[t0] b(0).
tabling[a(_)] := t1
consumer[t1] := {(p2,0)}
12. call(a(X4),t1)
[t1] 1: a(X4) b(X4), c(X4).
[t1] a(1).
13. answer(b(0),t0)
solution[t0] := b(0)
14. call(b(X4),1)
15. answer(a(1),t1)
, (p2,1)
solution[t1] := a(1)
16. answer(b(0),1)
17. answer(a(1),0)
[t0] b(1).
[t1] 2: a(0) c(0).
18. answer(b(1),t0)
, b(1)
19. answer(b(1),1)
[t1] 3: a(1) c(1).
Carlos Damásio TAPD 2000, Vigo 14
Goal Manager
Prover 1
T. Storage 1
T. Storage 2
tabling[b(_)] := t0
consumer[t0] := (p1,0)
solution[t0] := b(0)
, (p2,1)
20. answer(b(0),0)
, b(1)
[t0] 0: q0(X1) b(X1)
[t0] q0(0).
21. answer(q0(0),t0)
tabling[q0(_)] := t0
consumer[t0] := {(gm,0)}
solution[t0] := q0(0)
22. answer(q0(0),0)
23. answer(0,5)
24. answer(b(1),0)
25. answer(q0(1),t0)
[t0] q0(1).
, q0(1)
26. answer(q0(1),0)
27. answer(1,5)
Carlos Damásio TAPD 2000, Vigo 15
T. Storage 2
T. Storage 1
Prover 1
Prover 2
29. call(c(0),t1)
tabling[c(0)] := t1
consumer[t1] := {(p2,2)}
solution[t1] := c(0)33. answer(c(0),2)
28. call(c(0),2)
tabling[b(_)] := t0
consumer[t0] := (p1,0)
tabling[a(_)] := t1
consumer[t1] := {(p2,0)}
solution[t0] := b(0), b(1)
solution[t1] := a(1)
[t0] 0: q0(X1) b(X1)
[t0] q0(0).
[t0] q0(1).
tabling[c(1)] := t2
consumer[t2] := {(p2,3)}
[t0] 0: b(X3) a(X3)
[t0] b(0).
[t1] 1: a(X4) b(X4), c(X4).
[t1] a(1).
[t0] b(1).
[t1] 2: a(0) c(0).
[t1] 3: a(1) c(1).
30. call(c(1),3)
[t1] c(0).
31. call( c(1), t2) 32. answer(c(0),t1)
[t1] a(0).
35. answer(a(0),0)
34. answer(a(0),t1)
, a(0)
[t0] b(0).
36. answer(b(0),t0)
Carlos Damásio TAPD 2000, Vigo 16
Termination Detection
• The computation stops when activity ceases in the system (no messages and all processes are idle).
• A classical distributed termination detection algorithm suffices to detect global termination (it doubles in the worst case the number of messages)
Carlos Damásio TAPD 2000, Vigo 17
Completion Detection
• Completion is important for– Reclaiming of space and global evaluation
structures.– Evaluation of default negation (not...)
• Algorithm for distributed completion of tables without goal dependency propagation
Carlos Damásio TAPD 2000, Vigo 18
Credit Recovery AlgorithmAction Effect
Sendp {statep = active}send <M,Wp/2> to q; Wp = Wp/2
Receivep {A basic message has arrived}receive message <M,W>; statep = active;Wp := Wp + W
Quiescencep {statep = active}statep := passivesend <dec Wp> to C; Wp := 0
RecoverC receive <dec W> ; RC := RC - Wif RC = 0 then broadcast <term>
Carlos Damásio TAPD 2000, Vigo 19
Completion by Credit Change
• Construct a static goal dependency graph
• To each strongly connected component of this graph we associate a zone.
• Each zone has table storage controller running an instance of the credit recovery algorithm
• We exchange credits from different zones
Carlos Damásio TAPD 2000, Vigo 20
Returning to the Example
• We have three zones:– Zone 0 for queries, controller goal manager– Zone 1 for a/1 and b/1, controller T. Storage 2– Zone 2 for c/1, controller T. Storage 1
Carlos Damásio TAPD 2000, Vigo 21
Goal Manager Table Manager
[0] query([X], b(X), 5)
2. assert(q0(X) b(X) ) [1]
3. call(q0(X), 0) [2]
Prover 1
T. Storage 1
Prover 2
T. Storage 2
4. assert(q0(X) b(X) ) [3]
5. assert(q0(X) b(X) ) [4]
6. table(q0(_), ts1) [5]
7. call(q0(X),0) [6]
10. call(b(X2),t0) [9]
W := [2,5] W := [1,6]
W := [3] W := [4]
W := [6]
RC0=1,2,3,4,5,6
W := [6]
W := [7]
9. call(b(X1),0) [8]
W := [8]
W := [8]W := [8]W := [9]
W := [9]
8. call(q0(X1),t0) [7]
W := [7]
To exchange: [8]
,7,8
Carlos Damásio TAPD 2000, Vigo 22
Prover 2T. Storage 2
call(a(X3),0) 10
call(a(X4),t1) 11
answer(b(0),t0) 12
call(b(X4),1) 13
answer(a(1),t1) 14
answer(b(0),1) 15
answer(a(1),0) 16
answer(b(1),t0) 17
answer(b(1),1) 18
W := 9,11,12,13,16,18 W := 10,14,15,17,18
Carlos Damásio TAPD 2000, Vigo 23
Goal Manager
Prover 1
T. Storage 1
T. Storage 2
20. answer(b(0),0) [9]
21. answer(q0(0),t0) [10]
22. answer(q0(0),0) [11]
23. answer(0,5)
24. answer(b(1),0) [10]
25. answer(q0(1),t0) [11]
26. answer(q0(1),0) [12]
27. answer(1,5)
W := [9,11,12,13,16,18]
To exchange: [8]
RC0=1,2,3,4,5,6,7,8
[9]
,10
[10]
,9
RC1= 9,11,12,13,16,18
Carlos Damásio TAPD 2000, Vigo 24
RC1= 9,11,12,13,16,18
T. Storage 1
Prover 1
Prover 2
29. call(c(0),t1) [20]
33. answer(c(0),2) [21]
28. call(c(0),2) [19]
30. call(c(1),3) [20]
31. call( c(1), t2) [20]
32. answer(c(0),t1) [20]
35. answer(a(0),0)
[23]
34. answer(a(0),t1) [22]
36. answer(b(0),t0) [24]
W := 10,14,15,17,18W := 10,14,15,17,19W:=10,14,15,17,20
To exchange: 19 ,20
RC2= 19, 20
To exchange: [10]
Goal Manager
RC0=1,2,3,4,5,6,7,8,9,10RC0=0RC1= 9,10,11,12,13,14,15,16,17,18,20
T. Storage 2
,21
RC1= 8
W := 22,24
W := 23,24
RC1= 9,10,11,12,13,14,15,16,17,18,19,20,21
Carlos Damásio TAPD 2000, Vigo 25
Practical Results
• Too bad to be told:
– The current implementation has been done entirely as a Prolog Interpreter over PVM-Prolog.
– The main cause of inefficiency is the (ab)use of asserts/retracts to keep the global state.
Carlos Damásio TAPD 2000, Vigo 26
Conclusions
• A general and open distributed tabling system was presented.
• Polynomial complexity.
• An extension for completion detection without goal dependency has been introduced.
• Relatively low message overhead.
Carlos Damásio TAPD 2000, Vigo 27
Goal Manager
Prover 1
T. Storage 1
T. Storage 2
tabling[b(_)] := t0
consumer[t0] := (p1,0)
solution[t0] := b(0)
, (p2,1)
20. answer(b(0),0)
, b(1)
[t0] 0: q0(X1) b(X1)
[t0] q0(0).
21. answer(q0(0),t0)
tabling[q0(_)] := t0
consumer[t0] := {(gm,0)}
solution[t0] := q0(0)
22. answer(q0(0),0)
23. answer(0,5)
24. answer(b(1),0)
25. answer(q0(1),t0)
[t0] q0(1).
, q0(1)
26. answer(q0(1),0)
27. answer(1,5)