treewide: use coroutine::maybe_yield() instead of co_await make_ready_future()
The dedicated API shows the intent, and may be a tiny bit faster. Closes #9382
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include <seastar/core/shared_ptr.hh>
|
||||
#include <seastar/core/coroutine.hh>
|
||||
#include <seastar/core/future-util.hh>
|
||||
#include <seastar/coroutine/maybe_yield.hh>
|
||||
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
|
||||
@@ -480,7 +481,7 @@ static future<utils::chunked_vector<mutation>> get_cdc_generation_mutations(
|
||||
res.back().set_cell(ckey, to_bytes("streams"), make_set_value(cdc_streams_set_type, std::move(streams)), ts);
|
||||
res.back().set_cell(ckey, to_bytes("ignore_msb"), int8_t(e.sharding_ignore_msb), ts);
|
||||
|
||||
co_await make_ready_future<>(); // maybe yield
|
||||
co_await coroutine::maybe_yield();
|
||||
}
|
||||
|
||||
co_return res;
|
||||
@@ -577,7 +578,7 @@ static future<std::vector<mutation>> get_cdc_streams_descriptions_v2_mutation(
|
||||
res.back().set_cell(clustering_key::from_singular(*s, dht::token::to_int64(e.token_range_end)),
|
||||
to_bytes("streams"), make_set_value(cdc_streams_set_type, std::move(streams)), ts);
|
||||
|
||||
co_await make_ready_future<>(); // maybe yield
|
||||
co_await coroutine::maybe_yield();
|
||||
}
|
||||
|
||||
co_return res;
|
||||
@@ -694,7 +695,7 @@ system_distributed_keyspace::cdc_get_versioned_streams(db_clock::time_point not_
|
||||
utils::chunked_vector<cdc::stream_id> ids;
|
||||
for (auto& row : *streams_cql) {
|
||||
row.get_list_data<bytes>("streams", std::back_inserter(ids));
|
||||
co_await make_ready_future<>(); // maybe yield
|
||||
co_await coroutine::maybe_yield();
|
||||
}
|
||||
|
||||
result.emplace(ts, cdc::streams_version{std::move(ids), ts});
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
|
||||
#include <seastar/core/future-util.hh>
|
||||
#include <seastar/core/coroutine.hh>
|
||||
#include <seastar/coroutine/maybe_yield.hh>
|
||||
|
||||
#include "database.hh"
|
||||
#include "clustering_bounds_comparator.hh"
|
||||
@@ -1138,7 +1139,7 @@ future<query::clustering_row_ranges> calculate_affected_clustering_ranges(const
|
||||
}
|
||||
for (auto&& r : v.view->view_info()->partition_slice().default_row_ranges()) {
|
||||
view_row_ranges.push_back(r.transform(std::mem_fn(&clustering_key_prefix::view)));
|
||||
co_await make_ready_future<>(); // yield if needed
|
||||
co_await coroutine::maybe_yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1155,7 +1156,7 @@ future<query::clustering_row_ranges> calculate_affected_clustering_ranges(const
|
||||
if (overlap) {
|
||||
row_ranges.push_back(std::move(overlap).value());
|
||||
}
|
||||
co_await make_ready_future<>(); // yield if needed
|
||||
co_await coroutine::maybe_yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1164,7 +1165,7 @@ future<query::clustering_row_ranges> calculate_affected_clustering_ranges(const
|
||||
if (update_requires_read_before_write(base, views, key, row)) {
|
||||
row_ranges.emplace_back(row.key());
|
||||
}
|
||||
co_await make_ready_future<>(); // yield if needed
|
||||
co_await coroutine::maybe_yield();
|
||||
}
|
||||
|
||||
// Note that the views could have restrictions on regular columns,
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <boost/icl/interval.hpp>
|
||||
#include <boost/icl/interval_map.hpp>
|
||||
#include <seastar/core/coroutine.hh>
|
||||
#include <seastar/coroutine/maybe_yield.hh>
|
||||
#include <boost/range/adaptors.hpp>
|
||||
#include "utils/stall_free.hh"
|
||||
|
||||
@@ -481,7 +482,7 @@ future<> token_metadata_impl::update_normal_tokens(const std::unordered_map<inet
|
||||
}
|
||||
|
||||
for(auto it = _token_to_endpoint_map.begin(), ite = _token_to_endpoint_map.end(); it != ite;) {
|
||||
co_await make_ready_future<>(); // maybe yield
|
||||
co_await coroutine::maybe_yield();
|
||||
if(it->second == endpoint) {
|
||||
it = _token_to_endpoint_map.erase(it);
|
||||
} else {
|
||||
@@ -495,7 +496,7 @@ future<> token_metadata_impl::update_normal_tokens(const std::unordered_map<inet
|
||||
invalidate_cached_rings();
|
||||
for (const token& t : tokens)
|
||||
{
|
||||
co_await make_ready_future<>(); // maybe yield
|
||||
co_await coroutine::maybe_yield();
|
||||
auto prev = _token_to_endpoint_map.insert(std::pair<token, inet_address>(t, endpoint));
|
||||
should_sort_tokens |= prev.second; // new token inserted -> sort
|
||||
if (prev.first->second != endpoint) {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <seastar/util/lazy.hh>
|
||||
#include <seastar/util/log.hh>
|
||||
#include <seastar/core/coroutine.hh>
|
||||
#include <seastar/coroutine/maybe_yield.hh>
|
||||
|
||||
#include "reader_concurrency_semaphore.hh"
|
||||
#include "utils/exceptions.hh"
|
||||
@@ -618,7 +619,7 @@ future<> reader_concurrency_semaphore::execution_loop() noexcept {
|
||||
}
|
||||
|
||||
if (need_preempt()) {
|
||||
co_await make_ready_future<>();
|
||||
co_await coroutine::maybe_yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#include <seastar/core/loop.hh>
|
||||
#include <seastar/core/coroutine.hh>
|
||||
#include <seastar/coroutine/maybe_yield.hh>
|
||||
|
||||
namespace service {
|
||||
|
||||
@@ -97,7 +98,7 @@ future<raft::log_entries> raft_sys_table_storage::load_log() {
|
||||
log.emplace_back(make_lw_shared<const raft::log_entry>(
|
||||
raft::log_entry{.term = term, .idx = idx, .data = std::move(data)}));
|
||||
|
||||
co_await make_ready_future<>();
|
||||
co_await coroutine::maybe_yield();
|
||||
}
|
||||
co_return log;
|
||||
}
|
||||
@@ -227,7 +228,7 @@ future<> raft_sys_table_storage::do_store_log_entries(const std::vector<raft::lo
|
||||
fragmented_temporary_buffer::view(stmt_data_views.back())));
|
||||
stmt_value_views.emplace_back(std::move(value_views));
|
||||
|
||||
co_await make_ready_future<>();
|
||||
co_await coroutine::maybe_yield();
|
||||
}
|
||||
|
||||
auto batch_options = cql3::query_options::make_batch_options(
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <seastar/core/future.hh>
|
||||
#include <seastar/core/loop.hh>
|
||||
#include <seastar/core/coroutine.hh>
|
||||
#include <seastar/coroutine/maybe_yield.hh>
|
||||
#include "utils/loading_shared_values.hh"
|
||||
#include "utils/chunked_vector.hh"
|
||||
#include "utils/bptree.hh"
|
||||
@@ -274,7 +275,7 @@ public:
|
||||
});
|
||||
if (need_preempt() && i != _cache.end()) {
|
||||
auto key = i->key();
|
||||
co_await make_ready_future<>();
|
||||
co_await coroutine::maybe_yield();
|
||||
i = _cache.lower_bound(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <seastar/util/closeable.hh>
|
||||
#include <iterator>
|
||||
#include <seastar/core/coroutine.hh>
|
||||
#include <seastar/coroutine/maybe_yield.hh>
|
||||
|
||||
#include "dht/sharder.hh"
|
||||
#include "types.hh"
|
||||
@@ -521,7 +522,7 @@ future<> parse(const schema& schema, sstable_version_types v, random_access_read
|
||||
while (s.positions.size() != s.header.size) {
|
||||
s.positions.push_back(seastar::read_le<pos_type>(b));
|
||||
b += sizeof(pos_type);
|
||||
co_await make_ready_future<>(); // yield
|
||||
co_await coroutine::maybe_yield();
|
||||
}
|
||||
// Since the keys in the index are not sized, we need to calculate
|
||||
// the start position of the index i+1 to determine the boundaries
|
||||
@@ -682,7 +683,7 @@ future<> parse(const schema& s, sstable_version_types v, random_access_reader& i
|
||||
eh.bucket_offsets.push_back(offset);
|
||||
}
|
||||
eh.buckets.push_back(bucket);
|
||||
co_await make_ready_future<>(); // yield
|
||||
co_await coroutine::maybe_yield();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
3
table.cc
3
table.cc
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <seastar/core/seastar.hh>
|
||||
#include <seastar/core/coroutine.hh>
|
||||
#include <seastar/coroutine/maybe_yield.hh>
|
||||
#include <seastar/util/closeable.hh>
|
||||
|
||||
#include "database.hh"
|
||||
@@ -762,7 +763,7 @@ table::sstable_list_builder::build_new_list(const sstables::sstable_set& current
|
||||
if (!s.contains(tab)) {
|
||||
new_sstable_list.insert(tab);
|
||||
}
|
||||
co_await make_ready_future<>(); // yield if needed.
|
||||
co_await coroutine::maybe_yield();
|
||||
}
|
||||
co_return make_lw_shared<sstables::sstable_set>(std::move(new_sstable_list));
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <seastar/testing/test_case.hh>
|
||||
#include <seastar/core/timed_out_error.hh>
|
||||
#include <seastar/core/coroutine.hh>
|
||||
#include <seastar/coroutine/maybe_yield.hh>
|
||||
#include <seastar/core/gate.hh>
|
||||
#include <seastar/core/queue.hh>
|
||||
#include <seastar/core/future-util.hh>
|
||||
@@ -146,7 +147,7 @@ public:
|
||||
// In any case we simply drop the output.
|
||||
}
|
||||
|
||||
co_await make_ready_future<>(); // maybe yield
|
||||
co_await coroutine::maybe_yield();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <seastar/core/file.hh>
|
||||
#include <seastar/core/coroutine.hh>
|
||||
#include <seastar/coroutine/maybe_yield.hh>
|
||||
|
||||
#include <map>
|
||||
|
||||
@@ -460,7 +461,7 @@ public:
|
||||
}
|
||||
if (need_preempt() && i != _cache.end()) {
|
||||
auto key = i->idx;
|
||||
co_await make_ready_future<>();
|
||||
co_await coroutine::maybe_yield();
|
||||
i = _cache.lower_bound(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <seastar/core/metrics.hh>
|
||||
#include <seastar/core/reactor.hh>
|
||||
#include <seastar/core/coroutine.hh>
|
||||
#include <seastar/coroutine/maybe_yield.hh>
|
||||
#include <seastar/core/with_scheduling_group.hh>
|
||||
#include <seastar/util/alloc_failure_injector.hh>
|
||||
#include <seastar/util/backtrace.hh>
|
||||
@@ -413,7 +414,7 @@ private:
|
||||
break;
|
||||
}
|
||||
_reclaim(free_memory_threshold - memory::stats().free_memory());
|
||||
co_await make_ready_future<>();
|
||||
co_await coroutine::maybe_yield();
|
||||
}
|
||||
llogger.debug("background_reclaimer::main_loop: exit");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user