Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

table: Fix quadratic behavior when inserting sstables into tracker on schema change #12593

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions replica/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1249,10 +1249,13 @@ void table::set_compaction_strategy(sstables::compaction_strategy_type strategy)
cg.get_backlog_tracker().copy_ongoing_charges(new_bt, move_read_charges);

new_sstables = make_lw_shared<sstables::sstable_set>(new_cs.make_sstable_set(t._schema));
cg.main_sstables()->for_each_sstable([this] (const sstables::shared_sstable& s) {
add_sstable_to_backlog_tracker(new_bt, s);
std::vector<sstables::shared_sstable> new_sstables_for_backlog_tracker;
new_sstables_for_backlog_tracker.reserve(cg.main_sstables()->all()->size());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't all build a sstable_list?
If so, we can just keep it and use it here?

Copy link
Member Author

@raphaelsc raphaelsc Jan 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not always. It builds a new list if the set is compound (maintenance + main or sets of all groups). Here we're working on main set only of a single group.

For partititioned_sstable_set, for example, we just return its local copy of all.

I think the interface is fragile as user can modify local copy if it doesn't copy on write.

lw_shared_ptr<sstable_list> all() const;

should be changed to

lw_shared_ptr<const sstable_list> all() const;

cg.main_sstables()->for_each_sstable([this, &new_sstables_for_backlog_tracker] (const sstables::shared_sstable& s) {
new_sstables->insert(s);
new_sstables_for_backlog_tracker.push_back(s);
});
new_bt.replace_sstables({}, std::move(new_sstables_for_backlog_tracker));
}

void execute() noexcept {
Expand Down