Skip to content

Commit

Permalink
Teach posixaio about iodepth_batch_complete_max.
Browse files Browse the repository at this point in the history
The posixaio engine prevously ignored iodepth_batch_complete_max and
polled the whole set of in flight IOs.  To enable apples-for-apples
comparisons with other engines (such as posixaio_waitcomplete), provide
a new option --posixaio_respect_iodepth_batch_complete_max.  Not enabled
by default, so as not to change any results unexpectedly.

Signed-off-by: Thomas Munro <[email protected]>
  • Loading branch information
macdice committed Aug 22, 2021
1 parent 7a7897a commit b24866d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
9 changes: 9 additions & 0 deletions HOWTO
Original file line number Diff line number Diff line change
Expand Up @@ -1944,6 +1944,7 @@ I/O engine
**posixaio**
POSIX asynchronous I/O using :manpage:`aio_read(3)` and
:manpage:`aio_write(3)`.
This engine defines engine specific options.

**posixaio_waitcomplete**
POSIX asynchronous I/O, using FreeBSD's
Expand Down Expand Up @@ -2609,6 +2610,14 @@ with the caveat that when used on the command line, they must come after the

If set, stdout and stderr streams are redirected to files named from the job name. Default is true.

.. options:: posixaio_respect_iodepth_batch_complete_max=bool : [posixaio]

If set, limit batch completions according to
:option:`iodepth_batch_complete_max`, as other engines do. Default is
false, effectively behaving as though
:option:`iodepth_batch_complete_max` has the same value as
:option:`iodepth`.

I/O depth
~~~~~~~~~

Expand Down
28 changes: 28 additions & 0 deletions engines/posixaio.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,34 @@
#include <fcntl.h>

#include "../fio.h"
#include "../optgroup.h"

struct posixaio_data {
struct io_u **aio_events;
unsigned int queued;
};

struct posixaio_options {
void *pad;
unsigned int respect_iodepth_batch_complete_max;
};

static struct fio_option options[] = {
{
.name = "posixaio_respect_iodepth_batch_complete_max",
.lname = "Respect iodepth_batch_complete_max",
.type = FIO_OPT_BOOL,
.off1 = offsetof(struct posixaio_options, respect_iodepth_batch_complete_max),
.help = "Whether to cap batch completion",
.def = "0",
.category = FIO_OPT_C_ENGINE,
.group = FIO_OPT_G_POSIXAIO,
},
{
.name = NULL,
},
};

static unsigned long long ts_utime_since_now(const struct timespec *start)
{
struct timespec now;
Expand Down Expand Up @@ -114,6 +136,7 @@ static int fio_posixaio_getevents(struct thread_data *td, unsigned int min,
unsigned int max, const struct timespec *t)
{
struct posixaio_data *pd = td->io_ops_data;
struct posixaio_options *o = td->eo;
os_aiocb_t *suspend_list[SUSPEND_ENTRIES];
struct timespec start;
int have_timeout = 0;
Expand Down Expand Up @@ -158,6 +181,9 @@ static int fio_posixaio_getevents(struct thread_data *td, unsigned int min,
io_u->resid = io_u->xfer_buflen - retval;
} else
io_u->error = err;

if (o->respect_iodepth_batch_complete_max && r >= max)
break;
}

if (r >= min)
Expand Down Expand Up @@ -274,6 +300,8 @@ static struct ioengine_ops ioengine = {
.open_file = generic_open_file,
.close_file = generic_close_file,
.get_file_size = generic_get_file_size,
.options = options,
.option_struct_size = sizeof(struct posixaio_options),
};

#ifdef CONFIG_HAVE_AIO_WAITCOMPLETE
Expand Down
7 changes: 7 additions & 0 deletions fio.1
Original file line number Diff line number Diff line change
Expand Up @@ -2372,6 +2372,13 @@ Defines the time between the SIGTERM and SIGKILL signals. Default is 1 second.
.TP
.BI (exec)std_redirect\fR=\fbool
If set, stdout and stderr streams are redirected to files named from the job name. Default is true.
.TP
.BI (posixaio)posixaio_respect_iodepth_batch_complete_max\fR=\fPbool
If set, limit batch completions according to
\fBiodepth_batch_complete_max\fR, as other engines do. Default is
false, effectively setting
\fBiodepth_batch_complete_max\fR to the same value as
\fBiodepth\fR.
.SS "I/O depth"
.TP
.BI iodepth \fR=\fPint
Expand Down
2 changes: 2 additions & 0 deletions optgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ enum opt_category_group {
__FIO_OPT_G_LIBCUFILE,
__FIO_OPT_G_DFS,
__FIO_OPT_G_NFS,
__FIO_OPT_G_POSIXAIO,

FIO_OPT_G_RATE = (1ULL << __FIO_OPT_G_RATE),
FIO_OPT_G_ZONE = (1ULL << __FIO_OPT_G_ZONE),
Expand Down Expand Up @@ -116,6 +117,7 @@ enum opt_category_group {
FIO_OPT_G_FILESTAT = (1ULL << __FIO_OPT_G_FILESTAT),
FIO_OPT_G_LIBCUFILE = (1ULL << __FIO_OPT_G_LIBCUFILE),
FIO_OPT_G_DFS = (1ULL << __FIO_OPT_G_DFS),
FIO_OPT_G_POSIXAIO = (1ULL << __FIO_OPT_G_POSIXAIO),
};

extern const struct opt_group *opt_group_from_mask(uint64_t *mask);
Expand Down

0 comments on commit b24866d

Please sign in to comment.