@@ -91,6 +91,9 @@ func MakeVirtualBackings() VirtualBackings {
91
91
type backingWithMetadata struct {
92
92
backing * TableBacking
93
93
94
+ // isLocal is true if the backing's fileNum is local to the file system.
95
+ isLocal bool
96
+
94
97
// protectionCount is used by Protect to temporarily prevent a backing from
95
98
// being reported as unused.
96
99
protectionCount int32
@@ -114,12 +117,13 @@ func (bm *backingWithMetadata) referencedDataPct() float64 {
114
117
//
115
118
// The added backing is unused until it is associated with a table via AddTable
116
119
// or protected via Protect.
117
- func (bv * VirtualBackings ) AddAndRef (backing * TableBacking ) {
120
+ func (bv * VirtualBackings ) AddAndRef (backing * TableBacking , isLocal bool ) {
118
121
// We take a reference on the backing because in case of protected backings
119
122
// (see Protect), we might be the only ones holding on to a backing.
120
123
backing .Ref ()
121
124
bm := & backingWithMetadata {
122
125
backing : backing ,
126
+ isLocal : isLocal ,
123
127
virtualTables : make (map [base.TableNum ]tableAndLevel ),
124
128
heapIndex : - 1 ,
125
129
}
@@ -167,10 +171,12 @@ func (bv *VirtualBackings) AddTable(m *TableMetadata, level int) {
167
171
level : level ,
168
172
}
169
173
// Update candidates heap.
170
- if v .heapIndex == - 1 {
171
- heap .Push (& bv .rewriteCandidates , v )
172
- } else {
173
- heap .Fix (& bv .rewriteCandidates , v .heapIndex )
174
+ if v .isLocal {
175
+ if v .heapIndex == - 1 {
176
+ heap .Push (& bv .rewriteCandidates , v )
177
+ } else {
178
+ heap .Fix (& bv .rewriteCandidates , v .heapIndex )
179
+ }
174
180
}
175
181
}
176
182
@@ -323,6 +329,9 @@ func (bv *VirtualBackings) String() string {
323
329
v := bv .m [n ]
324
330
fmt .Fprintf (& buf , " %s: size=%d refBlobValueSize=%d useCount=%d protectionCount=%d virtualizedSize=%d" ,
325
331
n , v .backing .Size , v .backing .ReferencedBlobValueSizeTotal , len (v .virtualTables ), v .protectionCount , v .virtualizedSize )
332
+ if ! v .isLocal {
333
+ fmt .Fprintf (& buf , " (external)" )
334
+ }
326
335
tableNums := slices .Sorted (maps .Keys (v .virtualTables ))
327
336
fmt .Fprintf (& buf , " tables: %v\n " , tableNums )
328
337
}
0 commit comments