Skip to content

Commit

Permalink
L0 compression should follow options.compression_per_level if not empty
Browse files Browse the repository at this point in the history
Summary:
Currently, we don't use options.compression_per_level[0] as the compression style for L0 compression type, unless it is None. This behavior
 doesn't look like on purpose. This diff will make sure L0 compress using the style of options.compression_per_level[0].

Reviewed and accepted in: https://reviews.facebook.net/D65607
Closes #1435

Differential Revision: D4099368

Pulled By: siying

fbshipit-source-id: cfbbdcd
  • Loading branch information
siying authored and Facebook Github Bot committed Oct 29, 2016
1 parent 2946cad commit 04751d5
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions db/db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,22 +270,17 @@ CompressionType GetCompressionFlush(
// Compressing memtable flushes might not help unless the sequential load
// optimization is used for leveled compaction. Otherwise the CPU and
// latency overhead is not offset by saving much space.

bool can_compress;

if (ioptions.compaction_style == kCompactionStyleUniversal) {
can_compress =
(ioptions.compaction_options_universal.compression_size_percent < 0);
if (ioptions.compaction_options_universal.compression_size_percent < 0) {
return mutable_cf_options.compression;
} else {
return kNoCompression;
}
} else if (!ioptions.compression_per_level.empty()) {
// For leveled compress when min_level_to_compress != 0.
return ioptions.compression_per_level[0];
} else {
// For leveled compress when min_level_to_compress == 0.
can_compress = ioptions.compression_per_level.empty() ||
ioptions.compression_per_level[0] != kNoCompression;
}

if (can_compress) {
return mutable_cf_options.compression;
} else {
return kNoCompression;
}
}

Expand Down

0 comments on commit 04751d5

Please sign in to comment.