0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 23:44:01 +01:00

ircd::fs: Add nodelay option to write_opts; relax the flush on write by default.

This commit is contained in:
Jason Volk 2018-12-27 14:01:05 -08:00
parent 29fd84010f
commit 7f41ca2f48
2 changed files with 25 additions and 7 deletions

View file

@ -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

View file

@ -544,19 +544,32 @@ ircd::fs::aio::kernel::submit(request &request)
queue.at(qcount++) = static_cast<iocb *>(&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)