@@ -21,7 +21,7 @@ Init ==
21
21
/\ converge = FALSE
22
22
23
23
\* Experiment with combining the write & garbage collect steps
24
- WriteTx ( n , tx ) ==
24
+ GCWriteTx ( n , tx ) ==
25
25
LET SetMin ( s ) == CHOOSE e \in s : \A o \in s : e <= o IN
26
26
LET MinExecuted == SetMin ( { executed [ o ] : o \in Node } ) IN
27
27
LET NewTxId == Len ( log ) - MinExecuted + 1 IN
@@ -34,31 +34,80 @@ WriteTx(n, tx) ==
34
34
]
35
35
/\ executed ' = [
36
36
o \in Node |->
37
- IF o / = n THEN executed [ o ] - MinExecuted ELSE NewTxId
37
+ IF o = n THEN NewTxId ELSE executed [ o ] - MinExecuted
38
38
]
39
39
/\ UNCHANGED converge
40
40
41
- ExecuteTx ( n ) ==
41
+ \* Experiment with combining the execute & garbage collect steps
42
+ GCExecuteTx ( n ) ==
43
+ LET SetMin ( s ) == CHOOSE e \in s : \A o \in s : e <= o IN
44
+ LET MinExecuted == SetMin ( {
45
+ IF o = n THEN executed [ o ] + 1 ELSE executed [ o ] : o \in Node
46
+ } ) IN
47
+ /\ log ' = [ i \in 1 .. Len ( log ) - MinExecuted |-> log [ i + MinExecuted ] ]
48
+ /\ executed ' = [
49
+ o \in Node |->
50
+ IF o = n
51
+ THEN executed [ o ] - MinExecuted + 1
52
+ ELSE executed [ o ] - MinExecuted
53
+ ]
54
+ /\ UNCHANGED converge
55
+
56
+ SimpleWriteTx ( n , tx ) ==
57
+ /\ ~ converge
58
+ /\ Len ( log ) < Divergence
59
+ /\ S ! WriteTx ( n , tx )
60
+ /\ UNCHANGED converge
61
+
62
+ SimpleExecuteTx ( n ) ==
42
63
/\ S ! ExecuteTx ( n )
43
64
/\ UNCHANGED converge
44
65
66
+ GarbageCollect ==
67
+ LET SetMin ( s ) == CHOOSE e \in s : \A o \in s : e <= o IN
68
+ LET MinExecuted == SetMin ( { executed [ o ] : o \in Node } ) IN
69
+ /\ log ' = [ i \in 1 .. Len ( log ) - MinExecuted |-> log [ i + MinExecuted ] ]
70
+ /\ executed ' = [ n \in Node |-> executed [ n ] - MinExecuted ]
71
+ /\ UNCHANGED converge
72
+
45
73
Converge ==
46
74
/\ converge ' = TRUE
47
75
/\ UNCHANGED << log , executed >>
48
76
49
- Next ==
50
- \/ \E n \in Node : \E tx \in Transaction : WriteTx ( n , tx )
51
- \/ \E n \in Node : ExecuteTx ( n )
77
+ GCWriteNext ==
78
+ \/ \E n \in Node : \E tx \in Transaction : GCWriteTx ( n , tx )
79
+ \/ \E n \in Node : SimpleExecuteTx ( n )
80
+ \/ Converge
81
+
82
+ SimpleFairness == \A n \in Node : WF_ vars ( SimpleExecuteTx ( n ) )
83
+
84
+ GCWriteSpec ==
85
+ /\ Init
86
+ /\ [] [ GCWriteNext ]_ vars
87
+ /\ SimpleFairness
88
+
89
+ GCExecuteNext ==
90
+ \/ \E n \in Node : \E tx \in Transaction : GCWriteTx ( n , tx )
91
+ \/ \E n \in Node : SimpleExecuteTx ( n )
52
92
\/ Converge
53
93
54
- Fairness == \A n \in Node : WF_ vars ( ExecuteTx ( n ) )
94
+ GCFairness == \A n \in Node : WF_ vars ( GCExecuteTx ( n ) )
55
95
56
- Test == Len ( log ) /= Divergence
96
+ GCExecuteSpec ==
97
+ /\ Init
98
+ /\ [] [ GCExecuteNext ]_ vars
99
+ /\ GCFairness
100
+
101
+ SimpleNext ==
102
+ \/ \E n \in Node : \E tx \in Transaction : SimpleWriteTx ( n , tx )
103
+ \/ \E n \in Node : SimpleExecuteTx ( n )
104
+ \/ GarbageCollect
105
+ \/ Converge
57
106
58
- Spec ==
107
+ SimpleSpec ==
59
108
/\ Init
60
- /\ [] [ Next ]_ vars
61
- /\ Fairness
109
+ /\ [] [ SimpleNext ]_ vars
110
+ /\ SimpleFairness
62
111
63
112
=============================================================================
64
113
0 commit comments