compaction: make size_tiered_most_interesting_bucket static method of stcs class

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
This commit is contained in:
Raphael S. Carvalho
2017-11-13 18:18:03 -02:00
parent b69dbf8b99
commit cb6d060d8e
6 changed files with 20 additions and 21 deletions

View File

@@ -125,10 +125,6 @@ namespace sstables {
uint64_t max_sstable_size, uint32_t sstable_level,
seastar::thread_scheduling_group* tsg = nullptr);
// Return the most interesting bucket applying the size-tiered strategy.
std::vector<sstables::shared_sstable>
size_tiered_most_interesting_bucket(const std::vector<sstables::shared_sstable>& candidates);
// Return list of expired sstables for column family cf.
// A sstable is fully expired *iff* its max_local_deletion_time precedes gc_before and its
// max timestamp is lower than any other relevant sstable.

View File

@@ -391,18 +391,6 @@ public:
}
};
std::vector<sstables::shared_sstable>
size_tiered_most_interesting_bucket(const std::vector<sstables::shared_sstable>& candidates) {
size_tiered_compaction_strategy cs;
auto buckets = cs.get_buckets(candidates);
std::vector<sstables::shared_sstable> most_interesting = cs.most_interesting_bucket(std::move(buckets),
DEFAULT_MIN_COMPACTION_THRESHOLD, DEFAULT_MAX_COMPACTION_THRESHOLD);
return most_interesting;
}
compaction_strategy::compaction_strategy(::shared_ptr<compaction_strategy_impl> impl)
: _compaction_strategy_impl(std::move(impl)) {}
compaction_strategy::compaction_strategy() = default;

View File

@@ -43,6 +43,7 @@
#include "sstables.hh"
#include "compaction.hh"
#include "size_tiered_compaction_strategy.hh"
#include "range.hh"
#include "log.hh"
#include <boost/range/algorithm/partial_sort.hpp>
@@ -225,7 +226,7 @@ public:
// before proceeding with a higher level, let's see if L0 is far enough behind to warrant STCS
// TODO: we shouldn't proceed with size tiered strategy if cassandra.disable_stcs_in_l0 is true.
if (get_level_size(0) > MAX_COMPACTING_L0) {
auto most_interesting = size_tiered_most_interesting_bucket(get_level(0));
auto most_interesting = sstables::size_tiered_compaction_strategy::most_interesting_bucket(get_level(0));
if (!most_interesting.empty()) {
logger.debug("L0 is too far behind, performing size-tiering there first");
return sstables::compaction_descriptor(std::move(most_interesting));
@@ -419,7 +420,7 @@ private:
} else {
// do STCS in L0 when max_sstable_size is high compared to size of new sstables, so we'll
// avoid quadratic behavior until L0 is worth promoting.
candidates = size_tiered_most_interesting_bucket(get_level(0));
candidates = sstables::size_tiered_compaction_strategy::most_interesting_bucket(get_level(0));
}
return { std::move(candidates), can_promote };
}

View File

@@ -162,7 +162,9 @@ public:
return compaction_strategy_type::size_tiered;
}
friend std::vector<sstables::shared_sstable> size_tiered_most_interesting_bucket(const std::vector<sstables::shared_sstable>&);
// Return the most interesting bucket for a set of sstables
static std::vector<sstables::shared_sstable>
most_interesting_bucket(const std::vector<sstables::shared_sstable>& candidates);
};
inline std::vector<std::pair<sstables::shared_sstable, uint64_t>>
@@ -328,4 +330,16 @@ inline int64_t size_tiered_compaction_strategy::estimated_pending_compactions(co
return n;
}
inline std::vector<sstables::shared_sstable>
size_tiered_compaction_strategy::most_interesting_bucket(const std::vector<sstables::shared_sstable>& candidates) {
size_tiered_compaction_strategy cs;
auto buckets = cs.get_buckets(candidates);
std::vector<sstables::shared_sstable> most_interesting = cs.most_interesting_bucket(std::move(buckets),
DEFAULT_MIN_COMPACTION_THRESHOLD, DEFAULT_MAX_COMPACTION_THRESHOLD);
return most_interesting;
}
}

View File

@@ -245,7 +245,7 @@ public:
if (bucket.size() >= size_t(min_threshold) && key >= now) {
// If we're in the newest bucket, we'll use STCS to prioritize sstables
auto stcs_interesting_bucket = size_tiered_most_interesting_bucket(bucket);
auto stcs_interesting_bucket = size_tiered_compaction_strategy::most_interesting_bucket(bucket);
// If the tables in the current bucket aren't eligible in the STCS strategy, we'll skip it and look for other buckets
if (!stcs_interesting_bucket.empty()) {

View File

@@ -1259,7 +1259,7 @@ static future<std::vector<unsigned long>> compact_sstables(std::vector<unsigned
if (strategy == compaction_strategy_type::size_tiered) {
// Calling function that will return a list of sstables to compact based on size-tiered strategy.
auto sstables_to_compact = size_tiered_most_interesting_bucket(*sstables);
auto sstables_to_compact = sstables::size_tiered_compaction_strategy::most_interesting_bucket(*sstables);
// We do expect that all candidates were selected for compaction (in this case).
BOOST_REQUIRE(sstables_to_compact.size() == sstables->size());
return sstables::compact_sstables(std::move(sstables_to_compact), *cf, new_sstable,