mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::fs: Add nodelay option to write_opts; relax the flush on write by default.
This commit is contained in:
parent
29fd84010f
commit
7f41ca2f48
2 changed files with 25 additions and 7 deletions
|
@ -83,6 +83,11 @@ struct ircd::fs::write_opts
|
||||||
/// an exception will be thrown. We default to true because we have faith
|
/// an exception will be thrown. We default to true because we have faith
|
||||||
/// in the useful propagation of an exception for this event.
|
/// in the useful propagation of an exception for this event.
|
||||||
bool interruptible {true};
|
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
|
inline
|
||||||
|
|
27
ircd/aio.cc
27
ircd/aio.cc
|
@ -544,19 +544,32 @@ ircd::fs::aio::kernel::submit(request &request)
|
||||||
queue.at(qcount++) = static_cast<iocb *>(&request);
|
queue.at(qcount++) = static_cast<iocb *>(&request);
|
||||||
stats.cur_queued++;
|
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
|
const bool flush_now
|
||||||
{
|
{
|
||||||
|
// The nodelay flag is set
|
||||||
|
nodelay
|
||||||
|
|
||||||
// The queue has reached the configured size
|
// The queue has reached the configured size
|
||||||
qcount >= size_t(max_submit)
|
|| qcount >= size_t(max_submit)
|
||||||
|
|
||||||
// The queue has reached its maximum size
|
// The queue has reached its maximum size
|
||||||
|| qcount >= queue.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)
|
if(flush_now)
|
||||||
|
|
Loading…
Reference in a new issue