compaction: Switch to strategy_control::candidates() for regular compaction
Now everything is prepared for the switch, let's do it. Now let's wait for ICS to enjoy the set of changes. Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
This commit is contained in:
@@ -1175,7 +1175,7 @@ protected:
|
||||
|
||||
table_state& t = *_compacting_table;
|
||||
sstables::compaction_strategy cs = t.get_compaction_strategy();
|
||||
sstables::compaction_descriptor descriptor = cs.get_sstables_for_compaction(t, _cm.get_strategy_control(), _cm.get_candidates(t));
|
||||
sstables::compaction_descriptor descriptor = cs.get_sstables_for_compaction(t, _cm.get_strategy_control());
|
||||
int weight = calculate_weight(descriptor);
|
||||
|
||||
if (descriptor.sstables.empty() || !can_proceed() || t.is_auto_compaction_disabled_by_user()) {
|
||||
@@ -1263,7 +1263,7 @@ future<> compaction_manager::maybe_wait_for_sstable_count_reduction(table_state&
|
||||
}
|
||||
auto num_runs_for_compaction = [&, this] {
|
||||
auto& cs = t.get_compaction_strategy();
|
||||
auto desc = cs.get_sstables_for_compaction(t, get_strategy_control(), get_candidates(t));
|
||||
auto desc = cs.get_sstables_for_compaction(t, get_strategy_control());
|
||||
return boost::copy_range<std::unordered_set<sstables::run_id>>(
|
||||
desc.sstables
|
||||
| boost::adaptors::transformed(std::mem_fn(&sstables::sstable::run_identifier))).size();
|
||||
|
||||
@@ -548,7 +548,7 @@ struct null_backlog_tracker final : public compaction_backlog_tracker::impl {
|
||||
//
|
||||
class null_compaction_strategy : public compaction_strategy_impl {
|
||||
public:
|
||||
virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector<sstables::shared_sstable> candidates) override {
|
||||
virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control) override {
|
||||
return sstables::compaction_descriptor();
|
||||
}
|
||||
|
||||
@@ -667,8 +667,8 @@ compaction_strategy_type compaction_strategy::type() const {
|
||||
return _compaction_strategy_impl->type();
|
||||
}
|
||||
|
||||
compaction_descriptor compaction_strategy::get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector<sstables::shared_sstable> candidates) {
|
||||
return _compaction_strategy_impl->get_sstables_for_compaction(table_s, control, std::move(candidates));
|
||||
compaction_descriptor compaction_strategy::get_sstables_for_compaction(table_state& table_s, strategy_control& control) {
|
||||
return _compaction_strategy_impl->get_sstables_for_compaction(table_s, control);
|
||||
}
|
||||
|
||||
compaction_descriptor compaction_strategy::get_major_compaction_job(table_state& table_s, std::vector<sstables::shared_sstable> candidates) {
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
compaction_strategy& operator=(compaction_strategy&&);
|
||||
|
||||
// Return a list of sstables to be compacted after applying the strategy.
|
||||
compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector<shared_sstable> candidates);
|
||||
compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control);
|
||||
|
||||
compaction_descriptor get_major_compaction_job(table_state& table_s, std::vector<shared_sstable> candidates);
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ protected:
|
||||
uint64_t max_sstable_bytes = compaction_descriptor::default_max_sstable_bytes);
|
||||
public:
|
||||
virtual ~compaction_strategy_impl() {}
|
||||
virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector<sstables::shared_sstable> candidates) = 0;
|
||||
virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control) = 0;
|
||||
virtual compaction_descriptor get_major_compaction_job(table_state& table_s, std::vector<sstables::shared_sstable> candidates) {
|
||||
return make_major_compaction_job(std::move(candidates));
|
||||
}
|
||||
|
||||
@@ -19,8 +19,9 @@ leveled_compaction_strategy_state& leveled_compaction_strategy::get_state(table_
|
||||
return table_s.get_compaction_strategy_state().get<leveled_compaction_strategy_state>();
|
||||
}
|
||||
|
||||
compaction_descriptor leveled_compaction_strategy::get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector<sstables::shared_sstable> candidates) {
|
||||
compaction_descriptor leveled_compaction_strategy::get_sstables_for_compaction(table_state& table_s, strategy_control& control) {
|
||||
auto& state = get_state(table_s);
|
||||
auto candidates = control.candidates(table_s);
|
||||
// NOTE: leveled_manifest creation may be slightly expensive, so later on,
|
||||
// we may want to store it in the strategy itself. However, the sstable
|
||||
// lists managed by the manifest may become outdated. For example, one
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
static void validate_options(const std::map<sstring, sstring>& options, std::map<sstring, sstring>& unchecked_options);
|
||||
|
||||
leveled_compaction_strategy(const std::map<sstring, sstring>& options);
|
||||
virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector<sstables::shared_sstable> candidates) override;
|
||||
virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control) override;
|
||||
|
||||
virtual std::vector<compaction_descriptor> get_cleanup_compaction_jobs(table_state& table_s, std::vector<shared_sstable> candidates) const override;
|
||||
|
||||
|
||||
@@ -210,11 +210,12 @@ size_tiered_compaction_strategy::most_interesting_bucket(std::vector<std::vector
|
||||
}
|
||||
|
||||
compaction_descriptor
|
||||
size_tiered_compaction_strategy::get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector<sstables::shared_sstable> candidates) {
|
||||
size_tiered_compaction_strategy::get_sstables_for_compaction(table_state& table_s, strategy_control& control) {
|
||||
// make local copies so they can't be changed out from under us mid-method
|
||||
int min_threshold = table_s.min_compaction_threshold();
|
||||
int max_threshold = table_s.schema()->max_compaction_threshold();
|
||||
auto compaction_time = gc_clock::now();
|
||||
auto candidates = control.candidates(table_s);
|
||||
|
||||
// TODO: Add support to filter cold sstables (for reference: SizeTieredCompactionStrategy::filterColdSSTables).
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
explicit size_tiered_compaction_strategy(const size_tiered_compaction_strategy_options& options);
|
||||
static void validate_options(const std::map<sstring, sstring>& options, std::map<sstring, sstring>& unchecked_options);
|
||||
|
||||
virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector<sstables::shared_sstable> candidates) override;
|
||||
virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control) override;
|
||||
|
||||
virtual std::vector<compaction_descriptor> get_cleanup_compaction_jobs(table_state& table_s, std::vector<shared_sstable> candidates) const override;
|
||||
|
||||
|
||||
@@ -301,9 +301,10 @@ time_window_compaction_strategy::get_reshaping_job(std::vector<shared_sstable> i
|
||||
}
|
||||
|
||||
compaction_descriptor
|
||||
time_window_compaction_strategy::get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector<shared_sstable> candidates) {
|
||||
time_window_compaction_strategy::get_sstables_for_compaction(table_state& table_s, strategy_control& control) {
|
||||
auto& state = get_state(table_s);
|
||||
auto compaction_time = gc_clock::now();
|
||||
auto candidates = control.candidates(table_s);
|
||||
|
||||
if (candidates.empty()) {
|
||||
state.estimated_remaining_tasks = 0;
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
enum class bucket_compaction_mode { none, size_tiered, major };
|
||||
public:
|
||||
time_window_compaction_strategy(const std::map<sstring, sstring>& options);
|
||||
virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector<shared_sstable> candidates) override;
|
||||
virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control) override;
|
||||
|
||||
virtual std::vector<compaction_descriptor> get_cleanup_compaction_jobs(table_state& table_s, std::vector<shared_sstable> candidates) const override;
|
||||
|
||||
|
||||
@@ -144,11 +144,11 @@ static std::unique_ptr<strategy_control> make_strategy_control_for_test(bool has
|
||||
|
||||
template <typename CompactionStrategy>
|
||||
requires requires(CompactionStrategy cs, table_state& t, strategy_control& c) {
|
||||
{ cs.get_sstables_for_compaction(t, c, std::vector<shared_sstable>()) } -> std::same_as<sstables::compaction_descriptor>;
|
||||
{ cs.get_sstables_for_compaction(t, c) } -> std::same_as<sstables::compaction_descriptor>;
|
||||
}
|
||||
static compaction_descriptor get_sstables_for_compaction(CompactionStrategy& cs, table_state& t, std::vector<shared_sstable> candidates) {
|
||||
auto control = make_strategy_control_for_test(false, std::move(candidates));
|
||||
return cs.get_sstables_for_compaction(t, *control, control->candidates(t));
|
||||
return cs.get_sstables_for_compaction(t, *control);
|
||||
}
|
||||
|
||||
static void assert_table_sstable_count(table_for_tests& t, size_t expected_count) {
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace sstables {
|
||||
|
||||
sstable_run_based_compaction_strategy_for_tests::sstable_run_based_compaction_strategy_for_tests() = default;
|
||||
|
||||
compaction_descriptor sstable_run_based_compaction_strategy_for_tests::get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector<sstables::shared_sstable> uncompacting_sstables) {
|
||||
compaction_descriptor sstable_run_based_compaction_strategy_for_tests::get_sstables_for_compaction(table_state& table_s, strategy_control& control) {
|
||||
// Get unique runs from all uncompacting sstables
|
||||
std::vector<frozen_sstable_run> runs = table_s.main_sstable_set().all_sstable_runs();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class sstable_run_based_compaction_strategy_for_tests : public compaction_strate
|
||||
public:
|
||||
sstable_run_based_compaction_strategy_for_tests();
|
||||
|
||||
virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control, std::vector<sstables::shared_sstable> uncompacting_sstables) override;
|
||||
virtual compaction_descriptor get_sstables_for_compaction(table_state& table_s, strategy_control& control) override;
|
||||
|
||||
virtual int64_t estimated_pending_compactions(table_state& table_s) const override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user