From 7f41ca2f48adb1f32b2b43e359005019c80a121a Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 27 Dec 2018 14:01:05 -0800 Subject: [PATCH] ircd::fs: Add nodelay option to write_opts; relax the flush on write by default. --- include/ircd/fs/write.h | 5 +++++ ircd/aio.cc | 27 ++++++++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/include/ircd/fs/write.h b/include/ircd/fs/write.h index b80820251..c22736ea9 100644 --- a/include/ircd/fs/write.h +++ b/include/ircd/fs/write.h @@ -83,6 +83,11 @@ struct ircd::fs::write_opts /// an exception will be thrown. We default to true because we have faith /// in the useful propagation of an exception for this event. bool interruptible {true}; + + /// Submits the I/O request immediately rather than allowing IRCd to + /// queue requests for a few iterations of the ircd::ios event loop. + /// (only relevant to aio). + bool nodelay {false}; }; inline diff --git a/ircd/aio.cc b/ircd/aio.cc index 966dec1de..ce73e658f 100644 --- a/ircd/aio.cc +++ b/ircd/aio.cc @@ -544,19 +544,32 @@ ircd::fs::aio::kernel::submit(request &request) queue.at(qcount++) = static_cast(&request); stats.cur_queued++; + // Determine whether the user wants (or needs) to submit without delay. + bool nodelay; switch(request.aio_lio_opcode) + { + case IOCB_CMD_PREADV: + nodelay = request.ropts->nodelay; + break; + + case IOCB_CMD_PWRITEV: + nodelay = request.wopts->nodelay; + break; + + default: + nodelay = true; + break; + } + const bool flush_now { + // The nodelay flag is set + nodelay + // The queue has reached the configured size - qcount >= size_t(max_submit) + || qcount >= size_t(max_submit) // The queue has reached its maximum size || qcount >= queue.size() - - // The request causes serialization. This is considered true for all - // non-reading events, even for different files and locations. It may - // be possible to optimize this condition. - || request.aio_lio_opcode != IOCB_CMD_PREADV - || request.ropts->nodelay }; if(flush_now)