Skip to content

Commit 9ca59d4

Browse files
committed
storage: add cluster setting for delete pacer
Add a (private) cluster setting that controls the baseline delete pacing rate. Informs: cockroachdb/pebble#5424 Release note: None
1 parent 7dfc455 commit 9ca59d4

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

pkg/storage/pebble.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,17 @@ var (
461461
)
462462
)
463463

464+
// This setting controls deletion pacing. This helps prevent disk slowness
465+
// events on some SSDs, that kick off an expensive GC if a lot of files are
466+
// deleted at once.
467+
var baselineDeletionRate = settings.RegisterIntSetting(
468+
settings.ApplicationLevel,
469+
"storage.baseline_deletion_rate",
470+
"the baseline allowed rate of bytes deleted per second by each store",
471+
128*1024*1024, // 128 MB/s
472+
settings.NonNegativeInt,
473+
)
474+
464475
// EngineComparer is a pebble.Comparer object that implements MVCC-specific
465476
// comparator settings for use with Pebble.
466477
var EngineComparer = func() pebble.Comparer {
@@ -545,10 +556,6 @@ func DefaultPebbleOptions() *pebble.Options {
545556
// This ensures that range keys are quickly flushed, allowing use of lazy
546557
// combined iteration within Pebble.
547558
opts.FlushDelayRangeKey = 10 * time.Second
548-
// Enable deletion pacing. This helps prevent disk slowness events on some
549-
// SSDs, that kick off an expensive GC if a lot of files are deleted at
550-
// once.
551-
opts.TargetByteDeletionRate = 128 << 20 // 128 MB
552559
opts.Experimental.ShortAttributeExtractor = shortAttributeExtractorForValues
553560

554561
lockTableStartKey := EncodeMVCCKey(MVCCKey{Key: keys.LocalRangeLockTablePrefix})
@@ -878,6 +885,9 @@ func newPebble(ctx context.Context, cfg engineConfig) (p *Pebble, err error) {
878885
return int(concurrentDownloadCompactions.Get(&cfg.settings.SV))
879886
}
880887
}
888+
cfg.opts.TargetByteDeletionRate = func() int {
889+
return int(baselineDeletionRate.Get(&cfg.settings.SV))
890+
}
881891

882892
cfg.opts.EnsureDefaults()
883893

0 commit comments

Comments
 (0)