Skip to content

Commit 2366f63

Browse files
mszeszko-metameta-codesync[bot]
authored andcommitted
Remove compression support (facebook#14266)
Summary: Pull Request resolved: facebook#14266 Compression is unused in production, making this dead code that adds unnecessary complexity. Core changes: - Remove `compression` field from `BlobDBOptions` - Remove compression/decompression methods (`GetCompressedSlice`, `DecompressSlice`, `BlobDecompressor`) - Simplify `ReadBlobFromOldFile` and `GetBlobValue` to handle only uncompressed blobs - Update compaction filter to skip compression/decompression CLI tool cleanup: - Remove `--blob_db_compression_type` flag from db_bench (Stacked BlobDB) - Remove `--show_uncompressed_blob` from blob_dump tool - Remove `--dump_uncompressed_blobs` from ldb dump/file_dump commands - blob_dump_tool now fails fast with NotSupported for compressed files Tests: - Remove compression-related tests (`Compression`, `DecompressAfterReopen`, `EnableDisableCompressionGC`, `ChangeCompressionGC`) Reviewed By: xingbowang Differential Revision: D91088957 fbshipit-source-id: 496ee41dcbd0023b794aa8a6d7dcc9c2451b7470
1 parent acfea34 commit 2366f63

17 files changed

Lines changed: 54 additions & 520 deletions

include/rocksdb/utilities/ldb_cmd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ class LDBCommand {
7171
static const std::string ARG_BLOB_FILE_STARTING_LEVEL;
7272
static const std::string ARG_PREPOPULATE_BLOB_CACHE;
7373
static const std::string ARG_DECODE_BLOB_INDEX;
74-
static const std::string ARG_DUMP_UNCOMPRESSED_BLOBS;
7574
static const std::string ARG_READ_TIMESTAMP;
7675
static const std::string ARG_GET_WRITE_UNIX_TIME;
7776

tools/blob_dump.cc

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ int main(int argc, char** argv) {
2727
{"file", required_argument, nullptr, 'f'},
2828
{"show_key", optional_argument, nullptr, 'k'},
2929
{"show_blob", optional_argument, nullptr, 'b'},
30-
{"show_uncompressed_blob", optional_argument, nullptr, 'r'},
3130
{"show_summary", optional_argument, nullptr, 's'},
3231
};
3332
DisplayType show_key = DisplayType::kRaw;
3433
DisplayType show_blob = DisplayType::kNone;
35-
DisplayType show_uncompressed_blob = DisplayType::kNone;
3634
bool show_summary = false;
3735
std::string file;
3836
while (true) {
@@ -47,7 +45,6 @@ int main(int argc, char** argv) {
4745
"Usage: blob_dump --file=filename "
4846
"[--show_key[=none|raw|hex|detail]] "
4947
"[--show_blob[=none|raw|hex|detail]] "
50-
"[--show_uncompressed_blob[=none|raw|hex|detail]] "
5148
"[--show_summary]\n");
5249
return 0;
5350
case 'f':
@@ -73,17 +70,6 @@ int main(int argc, char** argv) {
7370
show_blob = DisplayType::kHex;
7471
}
7572
break;
76-
case 'r':
77-
if (optarg) {
78-
if (display_types.count(arg_str) == 0) {
79-
fprintf(stderr, "Unrecognized blob display type.\n");
80-
return -1;
81-
}
82-
show_uncompressed_blob = display_types.at(arg_str);
83-
} else {
84-
show_uncompressed_blob = DisplayType::kHex;
85-
}
86-
break;
8773
case 's':
8874
show_summary = true;
8975
break;
@@ -93,8 +79,7 @@ int main(int argc, char** argv) {
9379
}
9480
}
9581
BlobDumpTool tool;
96-
Status s =
97-
tool.Run(file, show_key, show_blob, show_uncompressed_blob, show_summary);
82+
Status s = tool.Run(file, show_key, show_blob, show_summary);
9883
if (!s.ok()) {
9984
fprintf(stderr, "Failed: %s\n", s.ToString().c_str());
10085
return -1;

tools/db_bench_tool.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,12 +1087,6 @@ DEFINE_uint64(blob_db_file_size,
10871087
ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().blob_file_size,
10881088
"[Stacked BlobDB] Target size of each blob file.");
10891089

1090-
DEFINE_string(
1091-
blob_db_compression_type, "snappy",
1092-
"[Stacked BlobDB] Algorithm to use to compress blobs in blob files.");
1093-
static enum ROCKSDB_NAMESPACE::CompressionType
1094-
FLAGS_blob_db_compression_type_e = ROCKSDB_NAMESPACE::kSnappyCompression;
1095-
10961090
// Integrated BlobDB options
10971091
DEFINE_bool(
10981092
enable_blob_files,
@@ -5204,7 +5198,6 @@ class Benchmark {
52045198
blob_db_options.min_blob_size = FLAGS_blob_db_min_blob_size;
52055199
blob_db_options.bytes_per_sync = FLAGS_blob_db_bytes_per_sync;
52065200
blob_db_options.blob_file_size = FLAGS_blob_db_file_size;
5207-
blob_db_options.compression = FLAGS_blob_db_compression_type_e;
52085201
blob_db::BlobDB* ptr = nullptr;
52095202
s = hooks.Open(options, blob_db_options, db_name, &ptr);
52105203
if (s.ok()) {
@@ -9191,10 +9184,6 @@ int db_bench_tool(int argc, char** argv, ToolHooks& hooks) {
91919184
FLAGS_compressed_secondary_cache_compression_type_e = StringToCompressionType(
91929185
FLAGS_compressed_secondary_cache_compression_type.c_str());
91939186

9194-
// Stacked BlobDB
9195-
FLAGS_blob_db_compression_type_e =
9196-
StringToCompressionType(FLAGS_blob_db_compression_type.c_str());
9197-
91989187
int env_opts = !FLAGS_env_uri.empty() + !FLAGS_fs_uri.empty();
91999188
if (env_opts > 1) {
92009189
fprintf(stderr, "Error: --env_uri and --fs_uri are mutually exclusive\n");

tools/ldb_cmd.cc

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ const std::string LDBCommand::ARG_BLOB_FILE_STARTING_LEVEL =
110110
const std::string LDBCommand::ARG_PREPOPULATE_BLOB_CACHE =
111111
"prepopulate_blob_cache";
112112
const std::string LDBCommand::ARG_DECODE_BLOB_INDEX = "decode_blob_index";
113-
const std::string LDBCommand::ARG_DUMP_UNCOMPRESSED_BLOBS =
114-
"dump_uncompressed_blobs";
115113
const std::string LDBCommand::ARG_READ_TIMESTAMP = "read_timestamp";
116114
const std::string LDBCommand::ARG_GET_WRITE_UNIX_TIME = "get_write_unix_time";
117115

@@ -201,7 +199,7 @@ void DumpSstFile(Options options, std::string filename, bool output_hex,
201199
std::string from_key = "", std::string to_key = "");
202200

203201
void DumpBlobFile(const std::string& filename, bool is_key_hex,
204-
bool is_value_hex, bool dump_uncompressed_blobs);
202+
bool is_value_hex);
205203

206204
Status EncodeUserProvidedTimestamp(const std::string& user_timestamp,
207205
std::string* ts_buf);
@@ -2288,13 +2286,12 @@ DBDumperCommand::DBDumperCommand(
22882286
const std::vector<std::string>& /*params*/,
22892287
const std::map<std::string, std::string>& options,
22902288
const std::vector<std::string>& flags)
2291-
: LDBCommand(
2292-
options, flags, true /* is_read_only */,
2293-
BuildCmdLineOptions(
2294-
{ARG_TTL, ARG_HEX, ARG_KEY_HEX, ARG_VALUE_HEX, ARG_FROM, ARG_TO,
2295-
ARG_MAX_KEYS, ARG_COUNT_ONLY, ARG_COUNT_DELIM, ARG_STATS,
2296-
ARG_TTL_START, ARG_TTL_END, ARG_TTL_BUCKET, ARG_TIMESTAMP,
2297-
ARG_PATH, ARG_DECODE_BLOB_INDEX, ARG_DUMP_UNCOMPRESSED_BLOBS})),
2289+
: LDBCommand(options, flags, true /* is_read_only */,
2290+
BuildCmdLineOptions(
2291+
{ARG_TTL, ARG_HEX, ARG_KEY_HEX, ARG_VALUE_HEX, ARG_FROM,
2292+
ARG_TO, ARG_MAX_KEYS, ARG_COUNT_ONLY, ARG_COUNT_DELIM,
2293+
ARG_STATS, ARG_TTL_START, ARG_TTL_END, ARG_TTL_BUCKET,
2294+
ARG_TIMESTAMP, ARG_PATH, ARG_DECODE_BLOB_INDEX})),
22982295
null_from_(true),
22992296
null_to_(true),
23002297
max_keys_(-1),
@@ -2342,7 +2339,6 @@ DBDumperCommand::DBDumperCommand(
23422339
print_stats_ = IsFlagPresent(flags, ARG_STATS);
23432340
count_only_ = IsFlagPresent(flags, ARG_COUNT_ONLY);
23442341
decode_blob_index_ = IsFlagPresent(flags, ARG_DECODE_BLOB_INDEX);
2345-
dump_uncompressed_blobs_ = IsFlagPresent(flags, ARG_DUMP_UNCOMPRESSED_BLOBS);
23462342

23472343
if (is_key_hex_) {
23482344
if (!null_from_) {
@@ -2377,7 +2373,6 @@ void DBDumperCommand::Help(std::string& ret) {
23772373
ret.append(" [--" + ARG_TTL_END + "=<N>:- is exclusive]");
23782374
ret.append(" [--" + ARG_PATH + "=<path_to_a_file>]");
23792375
ret.append(" [--" + ARG_DECODE_BLOB_INDEX + "]");
2380-
ret.append(" [--" + ARG_DUMP_UNCOMPRESSED_BLOBS + "]");
23812376
ret.append("\n");
23822377
}
23832378

@@ -2424,8 +2419,7 @@ void DBDumperCommand::DoCommand() {
24242419
/* json_ */ false, column_families_);
24252420
break;
24262421
case kBlobFile:
2427-
DumpBlobFile(path_, is_key_hex_, is_value_hex_,
2428-
dump_uncompressed_blobs_);
2422+
DumpBlobFile(path_, is_key_hex_, is_value_hex_);
24292423
break;
24302424
default:
24312425
exec_state_ = LDBCommandExecuteResult::Failed(
@@ -4718,22 +4712,16 @@ void DumpSstFile(Options options, std::string filename, bool output_hex,
47184712
}
47194713

47204714
void DumpBlobFile(const std::string& filename, bool is_key_hex,
4721-
bool is_value_hex, bool dump_uncompressed_blobs) {
4715+
bool is_value_hex) {
47224716
using ROCKSDB_NAMESPACE::blob_db::BlobDumpTool;
47234717
BlobDumpTool tool;
4724-
BlobDumpTool::DisplayType blob_type = is_value_hex
4718+
BlobDumpTool::DisplayType show_blob = is_value_hex
47254719
? BlobDumpTool::DisplayType::kHex
47264720
: BlobDumpTool::DisplayType::kRaw;
4727-
BlobDumpTool::DisplayType show_uncompressed_blob =
4728-
dump_uncompressed_blobs ? blob_type : BlobDumpTool::DisplayType::kNone;
4729-
BlobDumpTool::DisplayType show_blob =
4730-
dump_uncompressed_blobs ? BlobDumpTool::DisplayType::kNone : blob_type;
4731-
47324721
BlobDumpTool::DisplayType show_key = is_key_hex
47334722
? BlobDumpTool::DisplayType::kHex
47344723
: BlobDumpTool::DisplayType::kRaw;
4735-
Status s = tool.Run(filename, show_key, show_blob, show_uncompressed_blob,
4736-
/* show_summary */ true);
4724+
Status s = tool.Run(filename, show_key, show_blob, /* show_summary */ true);
47374725
if (!s.ok()) {
47384726
fprintf(stderr, "Failed: %s\n", s.ToString().c_str());
47394727
}
@@ -4757,17 +4745,13 @@ DBFileDumperCommand::DBFileDumperCommand(
47574745
const std::map<std::string, std::string>& options,
47584746
const std::vector<std::string>& flags)
47594747
: LDBCommand(options, flags, true /* is_read_only */,
4760-
BuildCmdLineOptions(
4761-
{ARG_DECODE_BLOB_INDEX, ARG_DUMP_UNCOMPRESSED_BLOBS})),
4762-
decode_blob_index_(IsFlagPresent(flags, ARG_DECODE_BLOB_INDEX)),
4763-
dump_uncompressed_blobs_(
4764-
IsFlagPresent(flags, ARG_DUMP_UNCOMPRESSED_BLOBS)) {}
4748+
BuildCmdLineOptions({ARG_DECODE_BLOB_INDEX})),
4749+
decode_blob_index_(IsFlagPresent(flags, ARG_DECODE_BLOB_INDEX)) {}
47654750

47664751
void DBFileDumperCommand::Help(std::string& ret) {
47674752
ret.append(" ");
47684753
ret.append(DBFileDumperCommand::Name());
4769-
ret.append(" [--" + ARG_DECODE_BLOB_INDEX + "] ");
4770-
ret.append(" [--" + ARG_DUMP_UNCOMPRESSED_BLOBS + "] ");
4754+
ret.append(" [--" + ARG_DECODE_BLOB_INDEX + "]");
47714755
ret.append("\n");
47724756
}
47734757

@@ -4835,8 +4819,7 @@ void DBFileDumperCommand::DoCommand() {
48354819
filename = NormalizePath(filename);
48364820
std::cout << filename << std::endl;
48374821
std::cout << "------------------------------" << std::endl;
4838-
DumpBlobFile(filename, /* is_key_hex */ false, /* is_value_hex */ false,
4839-
dump_uncompressed_blobs_);
4822+
DumpBlobFile(filename, /* is_key_hex */ false, /* is_value_hex */ false);
48404823
std::cout << std::endl;
48414824
}
48424825
}

tools/ldb_cmd_impl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class DBFileDumperCommand : public LDBCommand {
4747

4848
private:
4949
bool decode_blob_index_;
50-
bool dump_uncompressed_blobs_;
5150
};
5251

5352
class DBLiveFilesMetadataDumperCommand : public LDBCommand {
@@ -109,7 +108,6 @@ class DBDumperCommand : public LDBCommand {
109108
bool print_stats_;
110109
std::string path_;
111110
bool decode_blob_index_;
112-
bool dump_uncompressed_blobs_;
113111

114112
static const std::string ARG_COUNT_ONLY;
115113
static const std::string ARG_COUNT_DELIM;

tools/ldb_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ def testDumpLiveFiles(self):
613613
# Call the dump_live_files function with the edited dbPath name.
614614
self.assertTrue(
615615
self.dumpLiveFiles(
616-
"--db=%s --decode_blob_index --dump_uncompressed_blobs" % dbPath,
616+
"--db=%s --decode_blob_index" % dbPath,
617617
dumpFilePath,
618618
)
619619
)
@@ -881,7 +881,7 @@ def testBlobDump(self):
881881
expected_pattern = re.compile(regex)
882882
blob_files = self.getBlobFiles(dbPath)
883883
self.assertTrue(len(blob_files) >= 1)
884-
cmd = "dump --path=%s --dump_uncompressed_blobs"
884+
cmd = "dump --path=%s"
885885
self.assertRunOKFull(
886886
(cmd) % (blob_files[0]), expected_pattern, unexpected=False, isPattern=True
887887
)

utilities/blob_db/blob_compaction_filter.cc

Lines changed: 8 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@ CompactionFilter::Decision BlobIndexCompactionFilterBase::FilterV2(
9494
}
9595
// Read value from blob file.
9696
PinnableSlice blob;
97-
CompressionType compression_type = kNoCompression;
98-
constexpr bool need_decompress = true;
99-
if (!ReadBlobFromOldFile(ikey.user_key, blob_index, &blob, need_decompress,
100-
&compression_type)) {
97+
if (!ReadBlobFromOldFile(ikey.user_key, blob_index, &blob)) {
10198
return Decision::kIOError;
10299
}
103100
CompactionFilter::Decision decision = ucf->FilterV2(
@@ -123,15 +120,6 @@ CompactionFilter::Decision BlobIndexCompactionFilterBase::HandleValueChange(
123120
return Decision::kIOError;
124121
}
125122
Slice new_blob_value(*new_value);
126-
GrowableBuffer compressed_output;
127-
if (blob_db_impl->bdb_options_.compression != kNoCompression) {
128-
Status s = blob_db_impl->CompressBlob(new_blob_value, &compressed_output);
129-
if (!s.ok()) {
130-
// Best approximation
131-
return Decision::kIOError;
132-
}
133-
new_blob_value = compressed_output.AsSlice();
134-
}
135123
uint64_t new_blob_file_number = 0;
136124
uint64_t new_blob_offset = 0;
137125
if (!WriteBlobToNewFile(key, new_blob_value, &new_blob_file_number,
@@ -142,8 +130,7 @@ CompactionFilter::Decision BlobIndexCompactionFilterBase::HandleValueChange(
142130
return Decision::kIOError;
143131
}
144132
BlobIndex::EncodeBlob(new_value, new_blob_file_number, new_blob_offset,
145-
new_blob_value.size(),
146-
blob_db_impl->bdb_options_.compression);
133+
new_blob_value.size(), kNoCompression);
147134
return Decision::kChangeBlobIndex;
148135
}
149136

@@ -205,14 +192,13 @@ bool BlobIndexCompactionFilterBase::OpenNewBlobFileIfNeeded() const {
205192
}
206193

207194
bool BlobIndexCompactionFilterBase::ReadBlobFromOldFile(
208-
const Slice& key, const BlobIndex& blob_index, PinnableSlice* blob,
209-
bool need_decompress, CompressionType* compression_type) const {
195+
const Slice& key, const BlobIndex& blob_index, PinnableSlice* blob) const {
210196
BlobDBImpl* const blob_db_impl = context_.blob_db_impl;
211197
assert(blob_db_impl);
212198

213-
Status s = blob_db_impl->GetRawBlobFromFile(
214-
key, blob_index.file_number(), blob_index.offset(), blob_index.size(),
215-
blob, compression_type);
199+
Status s = blob_db_impl->GetRawBlobFromFile(key, blob_index.file_number(),
200+
blob_index.offset(),
201+
blob_index.size(), blob);
216202

217203
if (!s.ok()) {
218204
ROCKS_LOG_ERROR(
@@ -225,21 +211,6 @@ bool BlobIndexCompactionFilterBase::ReadBlobFromOldFile(
225211
return false;
226212
}
227213

228-
if (need_decompress && *compression_type != kNoCompression) {
229-
s = blob_db_impl->DecompressSlice(*blob, *compression_type, blob);
230-
if (!s.ok()) {
231-
ROCKS_LOG_ERROR(
232-
blob_db_impl->db_options_.info_log,
233-
"Uncompression error during blob read from file: %" PRIu64
234-
" blob_offset: %" PRIu64 " blob_size: %" PRIu64
235-
" key: %s status: '%s'",
236-
blob_index.file_number(), blob_index.offset(), blob_index.size(),
237-
key.ToString(/* output_hex */ true).c_str(), s.ToString().c_str());
238-
239-
return false;
240-
}
241-
}
242-
243214
return true;
244215
}
245216

@@ -372,33 +343,11 @@ CompactionFilter::BlobDecision BlobIndexCompactionFilterGC::PrepareBlobOutput(
372343
}
373344

374345
PinnableSlice blob;
375-
CompressionType compression_type = kNoCompression;
376-
GrowableBuffer compressed_output;
377-
if (!ReadBlobFromOldFile(key, blob_index, &blob, false, &compression_type)) {
346+
if (!ReadBlobFromOldFile(key, blob_index, &blob)) {
378347
gc_stats_.SetError();
379348
return BlobDecision::kIOError;
380349
}
381350

382-
// If the compression_type is changed, re-compress it with the new compression
383-
// type.
384-
if (compression_type != blob_db_impl->bdb_options_.compression) {
385-
if (compression_type != kNoCompression) {
386-
const Status status =
387-
blob_db_impl->DecompressSlice(blob, compression_type, &blob);
388-
if (!status.ok()) {
389-
gc_stats_.SetError();
390-
return BlobDecision::kCorruption;
391-
}
392-
}
393-
if (blob_db_impl->bdb_options_.compression != kNoCompression) {
394-
s = blob_db_impl->CompressBlob(blob, &compressed_output);
395-
if (!s.ok()) {
396-
return BlobDecision::kCorruption;
397-
}
398-
blob.PinSelf(compressed_output.AsSlice());
399-
}
400-
}
401-
402351
uint64_t new_blob_file_number = 0;
403352
uint64_t new_blob_offset = 0;
404353
if (!WriteBlobToNewFile(key, blob, &new_blob_file_number, &new_blob_offset)) {
@@ -412,7 +361,7 @@ CompactionFilter::BlobDecision BlobIndexCompactionFilterGC::PrepareBlobOutput(
412361
}
413362

414363
BlobIndex::EncodeBlob(new_value, new_blob_file_number, new_blob_offset,
415-
blob.size(), compression_type);
364+
blob.size(), kNoCompression);
416365

417366
gc_stats_.AddRelocatedBlob(blob_index.size());
418367

utilities/blob_db/blob_compaction_filter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ class BlobIndexCompactionFilterBase : public LayeredCompactionFilterBase {
5959
bool IsBlobFileOpened() const;
6060
virtual bool OpenNewBlobFileIfNeeded() const;
6161
bool ReadBlobFromOldFile(const Slice& key, const BlobIndex& blob_index,
62-
PinnableSlice* blob, bool need_decompress,
63-
CompressionType* compression_type) const;
62+
PinnableSlice* blob) const;
6463
bool WriteBlobToNewFile(const Slice& key, const Slice& blob,
6564
uint64_t* new_blob_file_number,
6665
uint64_t* new_blob_offset) const;

utilities/blob_db/blob_db.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ void BlobDBOptions::Dump(Logger* log) const {
9292
ROCKS_LOG_HEADER(
9393
log, " BlobDBOptions.blob_file_size: %" PRIu64,
9494
blob_file_size);
95-
ROCKS_LOG_HEADER(
96-
log, " BlobDBOptions.compression: %d",
97-
static_cast<int>(compression));
9895
ROCKS_LOG_HEADER(
9996
log, " BlobDBOptions.enable_garbage_collection: %d",
10097
enable_garbage_collection);

utilities/blob_db/blob_db.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ struct BlobDBOptions {
6666
// after it exceeds that size
6767
uint64_t blob_file_size = 256 * 1024 * 1024;
6868

69-
// what compression to use for Blob's
70-
CompressionType compression = kNoCompression;
71-
7269
// If enabled, BlobDB cleans up stale blobs in non-TTL files during compaction
7370
// by rewriting the remaining live blobs to new files.
7471
bool enable_garbage_collection = false;

0 commit comments

Comments
 (0)