@@ -11,6 +11,7 @@ import (
11
11
"fmt"
12
12
"sync"
13
13
14
+ "github.com/cockroachdb/crlib/crhumanize"
14
15
"github.com/cockroachdb/errors"
15
16
"github.com/cockroachdb/pebble/internal/base"
16
17
"github.com/cockroachdb/pebble/internal/crc"
@@ -125,13 +126,14 @@ type FileWriterStats struct {
125
126
UncompressedValueBytes uint64
126
127
FileLen uint64
127
128
Properties FileProperties
129
+ MVCCGarbageBytes uint64
128
130
}
129
131
130
132
// String implements the fmt.Stringer interface.
131
133
func (s FileWriterStats ) String () string {
132
134
var buf bytes.Buffer
133
- fmt .Fprintf (& buf , "{BlockCount: %d, ValueCount: %d, UncompressedValueBytes: %d, FileLen: %d}" ,
134
- s .BlockCount , s .ValueCount , s .UncompressedValueBytes , s .FileLen )
135
+ fmt .Fprintf (& buf , "{BlockCount: %d, ValueCount: %d, UncompressedValueBytes: %d (%s MVCCGarbage) , FileLen: %d}" ,
136
+ s .BlockCount , s .ValueCount , s .UncompressedValueBytes , crhumanize . Percent ( s . MVCCGarbageBytes , s . UncompressedValueBytes ), s .FileLen )
135
137
return buf .String ()
136
138
}
137
139
@@ -187,14 +189,17 @@ var writerPool = sync.Pool{
187
189
188
190
// AddValue adds the provided value to the blob file, returning a Handle
189
191
// identifying the location of the value.
190
- func (w * FileWriter ) AddValue (v []byte ) Handle {
192
+ func (w * FileWriter ) AddValue (v []byte , isLikelyMVCCGarbage bool ) Handle {
191
193
// Determine if we should first flush the block.
192
194
if sz := w .valuesEncoder .size (); w .flushGov .ShouldFlush (sz , sz + len (v )) {
193
195
w .flush ()
194
196
}
195
197
valuesInBlock := w .valuesEncoder .Count ()
196
198
w .stats .ValueCount ++
197
199
w .stats .UncompressedValueBytes += uint64 (len (v ))
200
+ if isLikelyMVCCGarbage {
201
+ w .stats .MVCCGarbageBytes += uint64 (len (v ))
202
+ }
198
203
w .valuesEncoder .AddValue (v )
199
204
return Handle {
200
205
BlobFileID : base .BlobFileID (w .fileNum ),
0 commit comments