Skip to content

Commit 5f329ce

Browse files
mpvlmvdan
authored andcommitted
internal/core/adt: add stats for new closedness algo
Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I0af85c9b78ee95558d5273eae7a8a2bb72ddb044 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1213605 Reviewed-by: Matthew Sackman <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 96e0ebc commit 5f329ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+788
-204
lines changed

Diff for: cmd/cue/cmd/testdata/script/stats.txtar

+8
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ contents overwritten
4949
"Unifications": 4,
5050
"Disjuncts": 2,
5151
"Conjuncts": 8,
52+
"CloseIDElems": 0,
53+
"NumCloseIDs": 2,
5254
"Freed": 0,
5355
"Reused": 0,
5456
"Allocs": 6,
@@ -65,6 +67,8 @@ CUE: {
6567
Unifications: 4
6668
Disjuncts: 2
6769
Conjuncts: 8
70+
CloseIDElems: 0
71+
NumCloseIDs: 2
6872
Freed: 0
6973
Reused: 0
7074
Allocs: 6
@@ -80,6 +84,8 @@ CUE:
8084
Unifications: 4
8185
Disjuncts: 2
8286
Conjuncts: 8
87+
CloseIDElems: 0
88+
NumCloseIDs: 2
8389
Freed: 0
8490
Reused: 0
8591
Allocs: 6
@@ -94,6 +100,8 @@ Go:
94100
"Unifications": 4,
95101
"Disjuncts": 2,
96102
"Conjuncts": 8,
103+
"CloseIDElems": 0,
104+
"NumCloseIDs": 2,
97105
"Freed": 0,
98106
"Reused": 0,
99107
"Allocs": 6,

Diff for: cue/stats/stats.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ type Counts struct {
6363
// algorithmic behavior.
6464
Conjuncts int64
6565

66+
CloseIDElems int64
67+
NumCloseIDs int64
68+
6669
// Buffer counters
6770
//
6871
// Each unification and disjunct operation is associated with an object
@@ -100,6 +103,9 @@ func (c *Counts) Add(other Counts) {
100103
c.Conjuncts += other.Conjuncts
101104
c.Disjuncts += other.Disjuncts
102105

106+
c.CloseIDElems += other.CloseIDElems
107+
c.NumCloseIDs += other.NumCloseIDs
108+
103109
c.Freed += other.Freed
104110
c.Retained += other.Retained
105111
c.Reused += other.Reused
@@ -110,6 +116,8 @@ func (c Counts) Since(start Counts) Counts {
110116
c.Unifications -= start.Unifications
111117
c.Conjuncts -= start.Conjuncts
112118
c.Disjuncts -= start.Disjuncts
119+
c.CloseIDElems -= start.CloseIDElems
120+
c.NumCloseIDs -= start.NumCloseIDs
113121

114122
c.Freed -= start.Freed
115123
c.Retained -= start.Retained
@@ -139,7 +147,10 @@ Retain: {{.Retained}}
139147
140148
Unifications: {{.Unifications}}
141149
Conjuncts: {{.Conjuncts}}
142-
Disjuncts: {{.Disjuncts}}`))
150+
Disjuncts: {{.Disjuncts}}{{if .NumCloseIDs}}
151+
152+
CloseIDElems: {{.CloseIDElems}}
153+
NumCloseIDs: {{.NumCloseIDs}}{{end}}`))
143154
})
144155

145156
func (s Counts) String() string {

Diff for: cue/testdata/basicrewrite/018_self-reference_cycles.txtar

+12-5
Original file line numberDiff line numberDiff line change
@@ -146,28 +146,35 @@ Retain: 0
146146
Unifications: 47
147147
Conjuncts: 91
148148
Disjuncts: 10
149+
150+
CloseIDElems: 16
151+
NumCloseIDs: 10
149152
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
150153
diff old new
151154
--- old
152155
+++ new
153-
@@ -1,9 +1,9 @@
156+
@@ -1,9 +1,12 @@
154157
-Leaks: 1
155158
-Freed: 57
156159
-Reused: 46
157160
-Allocs: 12
158161
-Retain: 166
162+
-
163+
-Unifications: 48
164+
-Conjuncts: 285
165+
-Disjuncts: 88
159166
+Leaks: 59
160167
+Freed: 0
161168
+Reused: 0
162169
+Allocs: 59
163170
+Retain: 0
164-
165-
-Unifications: 48
166-
-Conjuncts: 285
167-
-Disjuncts: 88
171+
+
168172
+Unifications: 47
169173
+Conjuncts: 91
170174
+Disjuncts: 10
175+
+
176+
+CloseIDElems: 16
177+
+NumCloseIDs: 10
171178
-- out/eval/stats --
172179
Leaks: 1
173180
Freed: 57

Diff for: cue/testdata/benchmarks/cycleshare.txtar

+12-5
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,35 @@ Retain: 0
3535
Unifications: 43
3636
Conjuncts: 70
3737
Disjuncts: 21
38+
39+
CloseIDElems: 6
40+
NumCloseIDs: 1
3841
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
3942
diff old new
4043
--- old
4144
+++ new
42-
@@ -1,9 +1,9 @@
45+
@@ -1,9 +1,12 @@
4346
-Leaks: 8
4447
-Freed: 965
4548
-Reused: 951
4649
-Allocs: 22
4750
-Retain: 17
51+
-
52+
-Unifications: 559
53+
-Conjuncts: 1046
54+
-Disjuncts: 976
4855
+Leaks: 64
4956
+Freed: 0
5057
+Reused: 0
5158
+Allocs: 64
5259
+Retain: 0
53-
54-
-Unifications: 559
55-
-Conjuncts: 1046
56-
-Disjuncts: 976
60+
+
5761
+Unifications: 43
5862
+Conjuncts: 70
5963
+Disjuncts: 21
64+
+
65+
+CloseIDElems: 6
66+
+NumCloseIDs: 1
6067
-- out/eval/stats --
6168
Leaks: 8
6269
Freed: 965

Diff for: cue/testdata/benchmarks/disjunctelim.txtar

+7-1
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,14 @@ Retain: 0
4949
Unifications: 22
5050
Conjuncts: 843
5151
Disjuncts: 618
52+
53+
CloseIDElems: 49
54+
NumCloseIDs: 4
5255
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
5356
diff old new
5457
--- old
5558
+++ new
56-
@@ -1,9 +1,9 @@
59+
@@ -1,9 +1,12 @@
5760
-Leaks: 0
5861
-Freed: 367
5962
-Reused: 356
@@ -70,6 +73,9 @@ diff old new
7073
+Unifications: 22
7174
+Conjuncts: 843
7275
+Disjuncts: 618
76+
+
77+
+CloseIDElems: 49
78+
+NumCloseIDs: 4
7379
-- out/eval/stats --
7480
Leaks: 0
7581
Freed: 367

Diff for: cue/testdata/benchmarks/inlinedisjunction.txtar

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Retain: 0
2323
Unifications: 16
2424
Conjuncts: 113
2525
Disjuncts: 58
26+
27+
CloseIDElems: 10
28+
NumCloseIDs: 3
2629
-- out/eval --
2730
(struct){
2831
#def: (#struct){ |((#struct){
@@ -45,7 +48,7 @@ Disjuncts: 58
4548
diff old new
4649
--- old
4750
+++ new
48-
@@ -1,9 +1,9 @@
51+
@@ -1,9 +1,12 @@
4952
-Leaks: 0
5053
-Freed: 4674
5154
-Reused: 3903
@@ -62,6 +65,9 @@ diff old new
6265
+Unifications: 16
6366
+Conjuncts: 113
6467
+Disjuncts: 58
68+
+
69+
+CloseIDElems: 10
70+
+NumCloseIDs: 3
6571
-- out/eval/stats --
6672
Leaks: 0
6773
Freed: 4674

Diff for: cue/testdata/benchmarks/issue1684.txtar

+7-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ Retain: 0
7171
Unifications: 5541
7272
Conjuncts: 25871
7373
Disjuncts: 6534
74+
75+
CloseIDElems: 123173
76+
NumCloseIDs: 4115
7477
-- out/evalalpha --
7578
(struct){
7679
#Secret: (#struct){
@@ -138,7 +141,7 @@ Disjuncts: 6534
138141
diff old new
139142
--- old
140143
+++ new
141-
@@ -1,9 +1,9 @@
144+
@@ -1,9 +1,12 @@
142145
-Leaks: 0
143146
-Freed: 1064333
144147
-Reused: 1064282
@@ -155,6 +158,9 @@ diff old new
155158
+Unifications: 5541
156159
+Conjuncts: 25871
157160
+Disjuncts: 6534
161+
+
162+
+CloseIDElems: 123173
163+
+NumCloseIDs: 4115
158164
-- diff/-out/evalalpha<==>+out/eval --
159165
diff old new
160166
--- old

Diff for: cue/testdata/benchmarks/issue2176.txtar

+12-5
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,35 @@ Retain: 0
6868
Unifications: 377
6969
Conjuncts: 1527
7070
Disjuncts: 8
71+
72+
CloseIDElems: 137
73+
NumCloseIDs: 731
7174
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
7275
diff old new
7376
--- old
7477
+++ new
75-
@@ -1,9 +1,9 @@
78+
@@ -1,9 +1,12 @@
7679
-Leaks: 90
7780
-Freed: 746
7881
-Reused: 742
7982
-Allocs: 94
8083
-Retain: 1363
84+
-
85+
-Unifications: 828
86+
-Conjuncts: 3306
87+
-Disjuncts: 1475
8188
+Leaks: 449
8289
+Freed: 0
8390
+Reused: 0
8491
+Allocs: 449
8592
+Retain: 0
86-
87-
-Unifications: 828
88-
-Conjuncts: 3306
89-
-Disjuncts: 1475
93+
+
9094
+Unifications: 377
9195
+Conjuncts: 1527
9296
+Disjuncts: 8
97+
+
98+
+CloseIDElems: 137
99+
+NumCloseIDs: 731
93100
-- out/eval/stats --
94101
Leaks: 90
95102
Freed: 746

Diff for: cue/testdata/benchmarks/issue3514.txtar

+12-5
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,35 @@ Retain: 0
4545
Unifications: 69
4646
Conjuncts: 7053
4747
Disjuncts: 2386
48+
49+
CloseIDElems: 6
50+
NumCloseIDs: 6876
4851
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
4952
diff old new
5053
--- old
5154
+++ new
52-
@@ -1,9 +1,9 @@
55+
@@ -1,9 +1,12 @@
5356
-Leaks: 27
5457
-Freed: 31092
5558
-Reused: 30511
5659
-Allocs: 608
5760
-Retain: 47
61+
-
62+
-Unifications: 189
63+
-Conjuncts: 92950
64+
-Disjuncts: 31139
5865
+Leaks: 3645
5966
+Freed: 0
6067
+Reused: 0
6168
+Allocs: 3645
6269
+Retain: 0
63-
64-
-Unifications: 189
65-
-Conjuncts: 92950
66-
-Disjuncts: 31139
70+
+
6771
+Unifications: 69
6872
+Conjuncts: 7053
6973
+Disjuncts: 2386
74+
+
75+
+CloseIDElems: 6
76+
+NumCloseIDs: 6876
7077
-- out/eval/stats --
7178
Leaks: 27
7279
Freed: 31092

Diff for: cue/testdata/benchmarks/issue3517.txtar

+12-5
Original file line numberDiff line numberDiff line change
@@ -63,28 +63,35 @@ Retain: 0
6363
Unifications: 49
6464
Conjuncts: 123
6565
Disjuncts: 0
66+
67+
CloseIDElems: 34
68+
NumCloseIDs: 13
6669
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
6770
diff old new
6871
--- old
6972
+++ new
70-
@@ -1,9 +1,9 @@
73+
@@ -1,9 +1,12 @@
7174
-Leaks: 2
7275
-Freed: 49
7376
-Reused: 39
7477
-Allocs: 12
7578
-Retain: 608
79+
-
80+
-Unifications: 51
81+
-Conjuncts: 801
82+
-Disjuncts: 73
7683
+Leaks: 49
7784
+Freed: 0
7885
+Reused: 0
7986
+Allocs: 49
8087
+Retain: 0
81-
82-
-Unifications: 51
83-
-Conjuncts: 801
84-
-Disjuncts: 73
88+
+
8589
+Unifications: 49
8690
+Conjuncts: 123
8791
+Disjuncts: 0
92+
+
93+
+CloseIDElems: 34
94+
+NumCloseIDs: 13
8895
-- out/eval/stats --
8996
Leaks: 2
9097
Freed: 49

0 commit comments

Comments
 (0)