Skip to content

Commit

Permalink
compaction: avoid excessive reallocation and during input list format…
Browse files Browse the repository at this point in the history
…ting

with off-strategy, input list size can be close to 1k, which will
lead to unneeded reallocations when formatting the list for
logging.

in the past, we faced stalls in this area, and excessive reallocation
(log2 ~1k = ~10) may have contributed to that.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>

Closes #13907

(cherry picked from commit 5544d12)

Fixes #14071
  • Loading branch information
raphaelsc authored and avikivity committed Jul 9, 2023
1 parent 9f79c9f commit 55edbde
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions compaction/compaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,12 @@ struct compaction_read_monitor_generator final : public read_monitor_generator {

class formatted_sstables_list {
bool _include_origin = true;
std::vector<sstring> _ssts;
std::vector<std::string> _ssts;
public:
formatted_sstables_list() = default;
void reserve(size_t n) {
_ssts.reserve(n);
}
explicit formatted_sstables_list(const std::vector<shared_sstable>& ssts, bool include_origin) : _include_origin(include_origin) {
_ssts.reserve(ssts.size());
for (const auto& sst : ssts) {
Expand All @@ -435,9 +438,7 @@ class formatted_sstables_list {
};

std::ostream& operator<<(std::ostream& os, const formatted_sstables_list& lst) {
os << "[";
os << boost::algorithm::join(lst._ssts, ",");
os << "]";
fmt::print(os, "[{}]", fmt::join(lst._ssts, ","));
return os;
}

Expand Down Expand Up @@ -641,6 +642,7 @@ class compaction {
future<> setup() {
auto ssts = make_lw_shared<sstables::sstable_set>(make_sstable_set_for_input());
formatted_sstables_list formatted_msg;
formatted_msg.reserve(_sstables.size());
auto fully_expired = _table_s.fully_expired_sstables(_sstables, gc_clock::now());
min_max_tracker<api::timestamp_type> timestamp_tracker;

Expand Down

0 comments on commit 55edbde

Please sign in to comment.