From 8b689546b6e85a47a1018c5203d76c8d1ed2f145 Mon Sep 17 00:00:00 2001 From: Ari Ekmekji Date: Mon, 31 Aug 2015 12:59:02 -0700 Subject: [PATCH] Add Subcompactions to Universal Compaction Unit Tests Summary: Now that the approach to parallelizing L0-L1 level-based compactions by breaking the compaction job into subcompactions is being extended to apply to universal compactions as well, the unit tests need to account for this and run the universal compaction tests with subcompactions both enabled and disabled. Test Plan: make all && make check Reviewers: sdong, igor, noetzli, anthony, yhchiang Reviewed By: yhchiang Subscribers: dhruba Differential Revision: https://reviews.facebook.net/D45657 --- db/db_compaction_filter_test.cc | 6 ++++-- db/db_test.cc | 3 ++- util/db_test_util.cc | 19 ++++++++++++++++--- util/db_test_util.h | 1 + 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/db/db_compaction_filter_test.cc b/db/db_compaction_filter_test.cc index d40dd2abb..34e2a85b6 100644 --- a/db/db_compaction_filter_test.cc +++ b/db/db_compaction_filter_test.cc @@ -374,7 +374,8 @@ TEST_F(DBTestCompactionFilter, CompactionFilterWithValueChange) { // push all files to lower levels ASSERT_OK(Flush(1)); - if (option_config_ != kUniversalCompactionMultiLevel) { + if (option_config_ != kUniversalCompactionMultiLevel && + option_config_ != kUniversalSubcompactions) { dbfull()->TEST_CompactRange(0, nullptr, nullptr, handles_[1]); dbfull()->TEST_CompactRange(1, nullptr, nullptr, handles_[1]); } else { @@ -392,7 +393,8 @@ TEST_F(DBTestCompactionFilter, CompactionFilterWithValueChange) { // push all files to lower levels. This should // invoke the compaction filter for all 100000 keys. ASSERT_OK(Flush(1)); - if (option_config_ != kUniversalCompactionMultiLevel) { + if (option_config_ != kUniversalCompactionMultiLevel && + option_config_ != kUniversalSubcompactions) { dbfull()->TEST_CompactRange(0, nullptr, nullptr, handles_[1]); dbfull()->TEST_CompactRange(1, nullptr, nullptr, handles_[1]); } else { diff --git a/db/db_test.cc b/db/db_test.cc index 155ab9bfd..f5958cb82 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -3832,7 +3832,8 @@ TEST_F(DBTest, DropWrites) { env_->sleep_counter_.Reset(); env_->no_sleep_ = true; for (int i = 0; i < 5; i++) { - if (option_config_ != kUniversalCompactionMultiLevel) { + if (option_config_ != kUniversalCompactionMultiLevel && + option_config_ != kUniversalSubcompactions) { for (int level = 0; level < dbfull()->NumberLevels(); level++) { if (level > 0 && level == dbfull()->NumberLevels() - 1) { break; diff --git a/util/db_test_util.cc b/util/db_test_util.cc index 44a16a6f6..9af097d02 100644 --- a/util/db_test_util.cc +++ b/util/db_test_util.cc @@ -132,7 +132,7 @@ bool DBTestBase::ChangeOptions(int skip_mask) { } } -// Switch between different compaction styles (we have only 2 now). +// Switch between different compaction styles. bool DBTestBase::ChangeCompactOptions() { if (option_config_ == kDefault) { option_config_ = kUniversalCompaction; @@ -152,7 +152,14 @@ bool DBTestBase::ChangeCompactOptions() { option_config_ = kLevelSubcompactions; Destroy(last_options_); auto options = CurrentOptions(); - options.max_subcompactions = 4; + assert(options.max_subcompactions > 1); + TryReopen(options); + return true; + } else if (option_config_ == kLevelSubcompactions) { + option_config_ = kUniversalSubcompactions; + Destroy(last_options_); + auto options = CurrentOptions(); + assert(options.max_subcompactions > 1); TryReopen(options); return true; } else { @@ -314,7 +321,13 @@ Options DBTestBase::CurrentOptions( break; } case kLevelSubcompactions: { - options.max_subcompactions = 2; + options.max_subcompactions = 4; + break; + } + case kUniversalSubcompactions: { + options.compaction_style = kCompactionStyleUniversal; + options.num_levels = 8; + options.max_subcompactions = 4; break; } diff --git a/util/db_test_util.h b/util/db_test_util.h index 846a19404..bb1bfa7cb 100644 --- a/util/db_test_util.h +++ b/util/db_test_util.h @@ -437,6 +437,7 @@ class DBTestBase : public testing::Test { kOptimizeFiltersForHits = 26, kRowCache = 27, kLevelSubcompactions = 28, + kUniversalSubcompactions = 29, kEnd = 28 }; int option_config_;