From: Mark Nelson Date: Thu, 21 Jul 2022 21:31:07 +0000 (+0000) Subject: kv/RocksDBStore: Add CompactOnDeletion support X-Git-Tag: v18.1.0~811^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fba5488728e89d9b0a1c1ab94b7024fcc81b3b15;p=ceph.git kv/RocksDBStore: Add CompactOnDeletion support This commit adds support to compact column families when a certain number of tombstone entries have been observed within a certain sliding window during iteration. It only helps when itereating over entries already in SST files and not when iterating over ranges in memtables. Likely we will still need to provide a mechanism to flush memtables and compact column families once a certain number of rmkey or rm_range_key calls are made. Signed-off-by: Mark Nelson --- diff --git a/src/common/options/global.yaml.in b/src/common/options/global.yaml.in index d5d898ea3b70d..f09408086c049 100644 --- a/src/common/options/global.yaml.in +++ b/src/common/options/global.yaml.in @@ -3548,6 +3548,36 @@ options: # osd_*_priority determines the ratio of available io between client and # recovery. Each option may be set between # 1..63. +- name: rocksdb_cf_compact_on_deletion + type: bool + level: dev + desc: Compact the column family when a certain number of tombstones are observed within a given window. + long_desc: 'This setting instructs RocksDB to compact a column family when a certain + number of tombstones are observed during iteration within a certain sliding window. + For instance if rocksdb_cf_compact_on_deletion_sliding_window is 8192 and + rocksdb_cf_compact_on_deletion_trigger is 4096, then once 4096 tombstones are + observed after iteration over 8192 entries, the column family will be compacted.' + default: true + with_legacy: true + see_also: + - rocksdb_cf_compact_on_deletion_sliding_window + - rocksdb_cf_compact_on_deletion_trigger +- name: rocksdb_cf_compact_on_deletion_sliding_window + type: int + level: dev + desc: The sliding window to use when rocksdb_cf_compact_on_deletion is enabled. + default: 32768 + with_legacy: true + see_also: + - rocksdb_cf_compact_on_deletion +- name: rocksdb_cf_compact_on_deletion_trigger + type: int + level: dev + desc: The trigger to use when rocksdb_cf_compact_on_deletion is enabled. + default: 16384 + with_legacy: true + see_also: + - rocksdb_cf_compact_on_deletion - name: osd_client_op_priority type: uint level: advanced diff --git a/src/kv/RocksDBStore.cc b/src/kv/RocksDBStore.cc index 070f79a609be8..2a2e0c69adab7 100644 --- a/src/kv/RocksDBStore.cc +++ b/src/kv/RocksDBStore.cc @@ -18,6 +18,7 @@ #include "rocksdb/cache.h" #include "rocksdb/filter_policy.h" #include "rocksdb/utilities/convenience.h" +#include "rocksdb/utilities/table_properties_collectors.h" #include "rocksdb/merge_operator.h" #include "common/perf_counters.h" @@ -934,6 +935,14 @@ int RocksDBStore::update_column_family_options(const std::string& base_name, return r; } } + + // Set Compact on Deletion Factory + if (cct->_conf->rocksdb_cf_compact_on_deletion) { + size_t sliding_window = cct->_conf->rocksdb_cf_compact_on_deletion_sliding_window; + size_t trigger = cct->_conf->rocksdb_cf_compact_on_deletion_trigger; + cf_opt->table_properties_collector_factories.emplace_back( + rocksdb::NewCompactOnDeletionCollectorFactory(sliding_window, trigger)); + } return 0; }