Skip to content

Commit 23da05e

Browse files
committed
manifest: add blob file rewrite heuristic
Adapt CurrentBlobFileSet to maintain state in support of picking blob files for rewrite. Specifically, the CurrentBlobFileSet is extended with two heaps. One heap holds a set of files that are not fully referenced but are considered 'recently created,' ordered within the heap by the blob file creation time. The other heap holds files that are not fully referenced, ordered within the heap by the fraction of the file's data that is referenced. These heaps will be used during compaction picking to pick blob files to rewrite when value separation space amplification becomes intolerably high. Informs #112. Informs #4807.
1 parent 18051c5 commit 23da05e

File tree

17 files changed

+617
-56
lines changed

17 files changed

+617
-56
lines changed

cmd/pebble/db.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package main
66

77
import (
88
"log"
9+
"time"
910

1011
"github.com/cockroachdb/pebble"
1112
"github.com/cockroachdb/pebble/bloom"
@@ -86,6 +87,7 @@ func newPebbleDB(dir string) DB {
8687
Enabled: true,
8788
MinimumSize: 512,
8889
MaxBlobReferenceDepth: 10,
90+
RewriteMinimumAge: 5 * time.Minute,
8991
}
9092
}
9193

compaction_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ func newVersionWithLatest(
6464
l0Organizer: l0Organizer,
6565
virtualBackings: manifest.MakeVirtualBackings(),
6666
}
67-
latest.blobFiles.Init(nil)
67+
latest.blobFiles.Init(nil, manifest.BlobRewriteHeuristic{
68+
CurrentTime: time.Now,
69+
})
6870
return v, latest
6971
}
7072

db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2168,7 +2168,7 @@ func (d *DB) Metrics() *Metrics {
21682168
backingCount, backingTotalSize := d.mu.versions.latest.virtualBackings.Stats()
21692169
metrics.Table.BackingTableCount = uint64(backingCount)
21702170
metrics.Table.BackingTableSize = backingTotalSize
2171-
blobStats := d.mu.versions.latest.blobFiles.Stats()
2171+
blobStats, _ := d.mu.versions.latest.blobFiles.Stats()
21722172
d.mu.versions.logUnlock()
21732173
metrics.BlobFiles.LiveCount = blobStats.Count
21742174
metrics.BlobFiles.LiveSize = blobStats.PhysicalSize

external_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ func buildSeparatedValuesDB(
199199
Enabled: true,
200200
MinimumSize: 50,
201201
MaxBlobReferenceDepth: 10,
202+
RewriteMinimumAge: 15 * time.Minute,
202203
}
203204
}
204205
o.Levels[0].BlockSize = 32 << 10 // 32 KB

0 commit comments

Comments
 (0)