Skip to content

Commit

Permalink
Merge 'Make io-tester jobs share sched classes' from Pavel Emelyanov
Browse files Browse the repository at this point in the history
The jobs from io-tester's config all live in their own sched groups and io classes. This is not very flexible, add the ability to share sched classes as it was done for the RPC tester in 4d0ddc4 (rpc_tester: Allow sharing sched groups)

refs: #1083

Closes #1481

* github.com:scylladb/seastar:
  io_tester: Add option to share classes between jobs
  io_tester: Post-assign sched classes
  io_tester: Register io-class early
  • Loading branch information
avikivity committed Feb 28, 2023
2 parents 33f5e21 + 6af831f commit 9cbc1fe
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
33 changes: 29 additions & 4 deletions apps/io_tester/io_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,14 @@ struct shard_info {
unsigned rps = 0;
unsigned limit = std::numeric_limits<unsigned>::max();
unsigned shares = 10;
std::string sched_class = "";
uint64_t request_size = 4 << 10;
uint64_t bandwidth = 0;
std::chrono::duration<float> think_time = 0ms;
std::chrono::duration<float> think_after = 0ms;
std::chrono::duration<float> execution_time = 1ms;
seastar::scheduling_group scheduling_group = seastar::default_scheduling_group();
seastar::io_priority_class io_class = seastar::default_priority_class();
};

struct options {
Expand Down Expand Up @@ -230,7 +232,7 @@ class class_data {
class_data(job_config cfg)
: _config(std::move(cfg))
, _alignment(_config.shard_info.request_size >= 4096 ? 4096 : 512)
, _iop(io_priority_class::register_one(name(), _config.shard_info.shares))
, _iop(cfg.shard_info.io_class)
, _sg(cfg.shard_info.scheduling_group)
, _latencies(extended_p_square_probabilities = quantiles)
, _pos_distribution(0, _config.file_size / _config.shard_info.request_size)
Expand Down Expand Up @@ -777,6 +779,8 @@ struct convert<shard_info> {

if (node["shares"]) {
sl.shares = node["shares"].as<unsigned>();
} else if (node["class"]) {
sl.sched_class = node["class"].as<std::string>();
}
if (node["bandwidth"]) {
sl.bandwidth = node["bandwidth"].as<byte_size>().size;
Expand Down Expand Up @@ -963,12 +967,33 @@ int main(int ac, char** av) {
YAML::Node doc = YAML::LoadFile(yaml);
auto reqs = doc.as<std::vector<job_config>>();

parallel_for_each(reqs, [] (auto& r) {
return seastar::create_scheduling_group(r.name, r.shard_info.shares).then([&r] (seastar::scheduling_group sg) {
r.shard_info.scheduling_group = sg;
struct sched_class {
seastar::scheduling_group sg;
seastar::io_priority_class iop;
};
std::unordered_map<std::string, sched_class> sched_classes;

parallel_for_each(reqs, [&sched_classes] (auto& r) {
if (r.shard_info.sched_class != "") {
return make_ready_future<>();
}

return seastar::create_scheduling_group(r.name, r.shard_info.shares).then([&r, &sched_classes] (seastar::scheduling_group sg) {
sched_classes.insert(std::make_pair(r.name, sched_class {
.sg = sg,
.iop = io_priority_class::register_one(r.name, r.shard_info.shares),
}));
});
}).get();

for (job_config& r : reqs) {
auto cname = r.shard_info.sched_class != "" ? r.shard_info.sched_class : r.name;
fmt::print("Job {} -> sched class {}\n", r.name, cname);
auto& sc = sched_classes.at(cname);
r.shard_info.scheduling_group = sc.sg;
r.shard_info.io_class = sc.iop;
}

if (*st_type == directory_entry_type::block_device) {
uint64_t off = 0;
for (job_config& r : reqs) {
Expand Down
1 change: 1 addition & 0 deletions doc/io-tester.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ be replicated to each shard. All properties under `shard_info` are optional, and
* `rps`: the requests-per-second rate to apply to sending fibers. If unset, each fiber sends new request as soon as previous one completes
* `reqsize` : (I/O loads only) the size of requests generated by this job
* `shares` : how many shares requests in this job will have in the scheduler
* `class`: name of the job to share the sched class with (used if `shares` is not set)
* `think_time`: how long to wait before submitting another request in this job once one finishes.
* `execution_time`: (cpu loads only) for how long to execute a CPU loop

Expand Down

0 comments on commit 9cbc1fe

Please sign in to comment.