Skip to content

Instantly share code, notes, and snippets.

@itsbilal
Created August 21, 2020 16:39
Show Gist options
  • Save itsbilal/bb5344c74a0f469ce204c7bc758d3513 to your computer and use it in GitHub Desktop.
Save itsbilal/bb5344c74a0f469ce204c7bc758d3513 to your computer and use it in GitHub Desktop.
CockroachDB diff to enable deletion pacing in RocksDB
diff --git a/c-deps/libroach/options.cc b/c-deps/libroach/options.cc
index 366c141e73..0692601b33 100644
--- a/c-deps/libroach/options.cc
+++ b/c-deps/libroach/options.cc
@@ -12,6 +12,7 @@
#include <rocksdb/env.h>
#include <rocksdb/filter_policy.h>
#include <rocksdb/slice_transform.h>
+#include <rocksdb/sst_file_manager.h>
#include <rocksdb/table.h>
#include "cache.h"
#include "comparator.h"
@@ -178,6 +179,10 @@ rocksdb::Options DBMakeOptions(DBOptions db_opts) {
// `FlushWAL(true)` on non-temp stores. On the temp store we do not intend to
// sync WAL ever, so setting it to zero is fine there too.
options.wal_bytes_per_sync = 0;
+ // Create an SST File manager to pace file deletions. Not pacing deletions
+ // could, in some hardware, lead to short term disk stalls.
+ options.sst_file_manager.reset(rocksdb::NewSstFileManager(options.env, options.info_log,
+ "", 2 << 20 /* rate_bytes_per_sec = 2MB */));
// On ext4 and xfs, at least, `fallocate()`ing a large empty WAL is not enough
// to avoid inode writeback on every `fdatasync()`. Although `fallocate()` can
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment