Skip to content

Commit

Permalink
reactor, linux-aio: factor out get_smp_count() lambda
Browse files Browse the repository at this point in the history
Inside smp::adjust_max_networking_aio_io_control_blocks(), replace two
hard-to-read calculations with a common lambda.

Signed-off-by: Laszlo Ersek <[email protected]>
  • Loading branch information
lersek committed Nov 28, 2024
1 parent 17e3506 commit 37b4f3a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core/reactor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4185,6 +4185,10 @@ unsigned smp::adjust_max_networking_aio_io_control_blocks(unsigned network_iocbs
seastar_logger.debug("Available AIO control blocks = aio-max-nr - aio-nr = {} - {} = {}", aio_max_nr, aio_nr, available_aio);

if (available_aio < requested_aio) {
auto get_smp_count = [linear_over_cpus = available_aio - std::min(reserve_iocbs, available_aio)] (unsigned network) -> unsigned {
return linear_over_cpus / (storage_iocbs + preempt_iocbs + network);
};

if (available_aio >= requested_aio_other + smp::count) { // at least one queue for each shard
network_iocbs = (available_aio - requested_aio_other) / smp::count;
seastar_logger.warn("Your system does not have enough AIO capacity for optimal network performance; reducing `max-networking-io-control-blocks'.");
Expand All @@ -4198,12 +4202,11 @@ unsigned smp::adjust_max_networking_aio_io_control_blocks(unsigned network_iocbs
"Set /proc/sys/fs/aio-max-nr to at least {} (minimum) or {} (recommended for networking performance)",
aio_nr + (requested_aio_other + smp::count), aio_nr + requested_aio);

unsigned linear_over_cpus = available_aio - std::min(reserve_iocbs, available_aio);
unsigned smp_count_max = linear_over_cpus / (storage_iocbs + preempt_iocbs + 1);
unsigned smp_count_max = get_smp_count(1);
if (smp_count_max > 0) {
err.append(format(", or decrease the logical CPU count of the application to {} (maximum)", smp_count_max));

unsigned smp_count_recommended = linear_over_cpus / (storage_iocbs + preempt_iocbs + network_iocbs);
unsigned smp_count_recommended = get_smp_count(network_iocbs);
if (smp_count_recommended > 0) {
err.append(format(" or {} (recommended for networking performance)", smp_count_recommended));
}
Expand Down

0 comments on commit 37b4f3a

Please sign in to comment.