25#include <boost/container/static_vector.hpp>
31#include <seastar/core/sstring.hh>
32#include <seastar/core/fair_queue.hh>
34#include <seastar/core/future.hh>
35#include <seastar/core/internal/io_request.hh>
36#include <seastar/core/lowres_clock.hh>
37#include <seastar/util/spinlock.hh>
38#include <seastar/util/modules.hh>
40struct io_queue_for_tests;
46const fair_group& get_fair_group(
const io_queue& ioq,
unsigned stream);
56using shard_id = unsigned;
57using stream_id = unsigned;
59class io_desc_read_write;
60class queued_io_request;
63using io_group_ptr = std::shared_ptr<io_group>;
64using iovec_keeper = std::vector<::iovec>;
67struct maybe_priority_class_ref;
71 explicit priority_class(
const scheduling_group& sg)
noexcept;
72 explicit priority_class(internal::maybe_priority_class_ref pc)
noexcept;
73 unsigned id() const noexcept {
return _id; }
79 class priority_class_data;
82 std::vector<std::unique_ptr<priority_class_data>> _priority_classes;
84 boost::container::static_vector<fair_queue, 2> _streams;
85 internal::io_sink& _sink;
87 friend struct ::io_queue_for_tests;
90 priority_class_data& find_or_create_class(internal::priority_class pc);
91 future<size_t> queue_request(internal::priority_class pc, internal::io_direction_and_length dnl, internal::io_request req,
io_intent* intent, iovec_keeper iovs)
noexcept;
92 future<size_t> queue_one_request(internal::priority_class pc, internal::io_direction_and_length dnl, internal::io_request req,
io_intent* intent, iovec_keeper iovs)
noexcept;
98 size_t _queued_requests = 0;
99 size_t _requests_executing = 0;
100 uint64_t _requests_dispatched = 0;
101 uint64_t _requests_completed = 0;
104 uint64_t _prev_dispatched = 0;
105 uint64_t _prev_completed = 0;
106 double _flow_ratio = 1.0;
110 const std::chrono::milliseconds _stall_threshold_min;
111 std::chrono::milliseconds _stall_threshold;
113 void update_flow_ratio()
noexcept;
114 void lower_stall_threshold()
noexcept;
119 using clock_type = std::chrono::steady_clock;
129 static constexpr unsigned read_request_base_count = 128;
130 static constexpr unsigned block_size_shift = 9;
134 unsigned long req_count_rate = std::numeric_limits<int>::max();
135 unsigned long blocks_count_rate = std::numeric_limits<int>::max();
136 unsigned disk_req_write_to_read_multiplier = read_request_base_count;
137 unsigned disk_blocks_write_to_read_multiplier = read_request_base_count;
138 size_t disk_read_saturation_length = std::numeric_limits<size_t>::max();
139 size_t disk_write_saturation_length = std::numeric_limits<size_t>::max();
140 sstring mountpoint =
"undefined";
142 std::chrono::duration<double> rate_limit_duration = std::chrono::milliseconds(1);
143 size_t block_count_limit_min = 1;
144 unsigned averaging_decay_ticks = 100;
145 double flow_ratio_ema_factor = 0.95;
146 double flow_ratio_backpressure_threshold = 1.1;
147 std::chrono::milliseconds stall_threshold = std::chrono::milliseconds(100);
150 io_queue(io_group_ptr group, internal::io_sink& sink);
153 stream_id request_stream(internal::io_direction_and_length dnl)
const noexcept;
155 future<size_t> submit_io_read(internal::priority_class priority_class,
156 size_t len, internal::io_request req,
io_intent* intent, iovec_keeper iovs = {})
noexcept;
157 future<size_t> submit_io_write(internal::priority_class priority_class,
158 size_t len, internal::io_request req,
io_intent* intent, iovec_keeper iovs = {})
noexcept;
160 void submit_request(io_desc_read_write* desc, internal::io_request req)
noexcept;
161 void cancel_request(queued_io_request& req)
noexcept;
162 void complete_cancelled_request(queued_io_request& req)
noexcept;
163 void complete_request(io_desc_read_write& desc, std::chrono::duration<double> delay)
noexcept;
165 [[deprecated(
"I/O queue users should not track individual requests, but resources (weight, size) passing through the queue")]]
166 size_t queued_requests()
const {
167 return _queued_requests;
171 [[deprecated(
"I/O queue users should not track individual requests, but resources (weight, size) passing through the queue")]]
172 size_t requests_currently_executing()
const {
173 return _requests_executing;
177 void poll_io_queue();
179 clock_type::time_point next_pending_aio() const noexcept;
180 fair_queue_entry::capacity_t request_capacity(internal::io_direction_and_length dnl) const noexcept;
182 sstring mountpoint() const;
183 dev_t dev_id() const noexcept;
185 void update_shares_for_class(internal::priority_class pc,
size_t new_shares);
186 future<> update_bandwidth_for_class(internal::priority_class pc, uint64_t new_bandwidth);
187 void rename_priority_class(internal::priority_class pc, sstring new_name);
188 void throttle_priority_class(const priority_class_data& pc) noexcept;
189 void unthrottle_priority_class(const priority_class_data& pc) noexcept;
197 const
config& get_config() const noexcept;
201 void register_stats(sstring name, priority_class_data& pc);
208 struct priority_class_data;
210 std::chrono::duration<double> io_latency_goal()
const noexcept;
214 friend struct ::io_queue_for_tests;
218 size_t _max_request_length[2];
219 boost::container::static_vector<fair_group, 2> _fgs;
220 std::vector<std::unique_ptr<priority_class_data>> _priority_classes;
222 const shard_id _allocated_on;
225 priority_class_data& find_or_create_class(internal::priority_class pc);
229 return _group->_config;
232inline sstring io_queue::mountpoint()
const {
233 return get_config().mountpoint;
236inline dev_t io_queue::dev_id() const noexcept {
237 return get_config().devid;
241double request_tokens(io_direction_and_length dnl,
const io_queue::config& cfg)
noexcept;
Group of queues class.
Definition: fair_queue.hh:138
Definition: fair_queue.hh:236
Fair queuing class.
Definition: fair_queue.hh:289
A representation of a possibly not-yet-computed value.
Definition: future.hh:1240
Definition: io_queue.hh:204
Definition: io_intent.hh:44
Definition: io_queue.hh:77
Definition: io_queue.hh:132
Definition: io_queue.hh:191
holds the metric definition.
Definition: metrics_registration.hh:94
Definition: spinlock.hh:88
holds the metric_groups definition needed by class that reports metrics
Seastar API namespace.
Definition: abort_on_ebadf.hh:26