@@ -25,7 +25,6 @@ import (
25
25
"math"
26
26
"sort"
27
27
"sync/atomic"
28
- "unsafe"
29
28
30
29
"github.com/dgryski/go-farm"
31
30
"github.com/golang/glog"
@@ -68,27 +67,15 @@ const (
68
67
69
68
type List struct {
70
69
x.SafeMutex
71
- key []byte
72
- plist * pb.PostingList
73
- mutationMap map [uint64 ]* pb.PostingList
74
- minTs uint64 // commit timestamp of immutable layer, reject reads before this ts.
75
- estimatedSize int32
70
+ key []byte
71
+ plist * pb.PostingList
72
+ mutationMap map [uint64 ]* pb.PostingList
73
+ minTs uint64 // commit timestamp of immutable layer, reject reads before this ts.
76
74
77
75
pendingTxns int32 // Using atomic for this, to avoid locking in SetForDeletion operation.
78
76
deleteMe int32 // Using atomic for this, to avoid expensive SetForDeletion operation.
79
77
}
80
78
81
- // calculateSize would give you the size estimate. This is expensive, so run it carefully.
82
- func (l * List ) calculateSize () int32 {
83
- sz := int (unsafe .Sizeof (l ))
84
- sz += l .plist .Size ()
85
- sz += cap (l .key )
86
- for _ , pl := range l .mutationMap {
87
- sz += 8 + pl .Size ()
88
- }
89
- return int32 (sz )
90
- }
91
-
92
79
type PIterator struct {
93
80
pl * pb.PostingList
94
81
uidPosting * pb.Posting
@@ -184,14 +171,6 @@ func NewPosting(t *pb.DirectedEdge) *pb.Posting {
184
171
}
185
172
}
186
173
187
- func (l * List ) EstimatedSize () int32 {
188
- size := atomic .LoadInt32 (& l .estimatedSize )
189
- if size < 0 {
190
- return 0
191
- }
192
- return size
193
- }
194
-
195
174
// SetForDeletion will mark this List to be deleted, so no more mutations can be applied to this.
196
175
// Ensure that we don't acquire any locks during a call to this function, so the LRU cache can
197
176
// proceed smoothly.
@@ -328,7 +307,6 @@ func (l *List) addMutation(ctx context.Context, txn *Txn, t *pb.DirectedEdge) er
328
307
}
329
308
330
309
l .updateMutationLayer (mpost )
331
- atomic .AddInt32 (& l .estimatedSize , int32 (mpost .Size ()+ 16 /* various overhead */ ))
332
310
atomic .AddInt32 (& l .pendingTxns , 1 )
333
311
txn .AddKeys (string (l .key ), conflictKey )
334
312
return nil
@@ -375,7 +353,6 @@ func (l *List) commitMutation(startTs, commitTs uint64) error {
375
353
}
376
354
if commitTs == 0 {
377
355
// Abort mutation.
378
- atomic .AddInt32 (& l .estimatedSize , - 1 * int32 (plist .Size ()))
379
356
delete (l .mutationMap , startTs )
380
357
return nil
381
358
}
@@ -688,7 +665,6 @@ func (l *List) rollup(readTs uint64) error {
688
665
689
666
l .minTs = maxCommitTs
690
667
l .plist = final
691
- atomic .StoreInt32 (& l .estimatedSize , l .calculateSize ())
692
668
return nil
693
669
}
694
670
0 commit comments