streaming/stream_transfer_task: avoid pointless iterations in has_relevant_range_on_this_shard()
When has_relevant_range_on_this_shard() found a relevant range, it will unnecessarily iterate through the end. Verified manually that this could be thousands of pointless iterations when streaming data to a node just added. The relevant code could be simplified by de-futurizing it but I think it remains so to allow task scheduler to preempt it if necessary. Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com> Message-Id: <20200220224048.28804-2-raphaelsc@scylladb.com>
This commit is contained in:
committed by
Pekka Enberg
parent
8a986bc23b
commit
40e75fb109
@@ -99,8 +99,10 @@ struct send_info {
|
||||
, reader(cf.make_streaming_reader(cf.schema(), prs)) {
|
||||
}
|
||||
future<bool> has_relevant_range_on_this_shard() {
|
||||
return do_with(false, [this] (bool& found_relevant_range) {
|
||||
return do_for_each(ranges, [this, &found_relevant_range] (dht::token_range range) {
|
||||
return do_with(false, ranges.begin(), [this] (bool& found_relevant_range, dht::token_range_vector::iterator& ranges_it) {
|
||||
auto stop_cond = [this, &found_relevant_range, &ranges_it] { return ranges_it == ranges.end() || found_relevant_range; };
|
||||
return do_until(std::move(stop_cond), [this, &found_relevant_range, &ranges_it] {
|
||||
dht::token_range range = *ranges_it++;
|
||||
if (!found_relevant_range) {
|
||||
auto sharder = dht::selective_token_range_sharder(cf.schema()->get_partitioner(), std::move(range), engine().cpu_id());
|
||||
auto range_shard = sharder.next();
|
||||
@@ -108,6 +110,7 @@ struct send_info {
|
||||
found_relevant_range = true;
|
||||
}
|
||||
}
|
||||
return make_ready_future<>();
|
||||
}).then([&found_relevant_range] {
|
||||
return found_relevant_range;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user