mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::fs::aio: Split max events query into init method.
This commit is contained in:
parent
56bbc04527
commit
e403c20cc6
2 changed files with 36 additions and 26 deletions
|
@ -87,6 +87,8 @@ struct ircd::fs::aio::stats
|
||||||
struct [[gnu::visibility("hidden")]]
|
struct [[gnu::visibility("hidden")]]
|
||||||
ircd::fs::aio::init
|
ircd::fs::aio::init
|
||||||
{
|
{
|
||||||
|
static size_t query_max_events();
|
||||||
|
|
||||||
init();
|
init();
|
||||||
~init() noexcept;
|
~init() noexcept;
|
||||||
};
|
};
|
||||||
|
|
|
@ -82,10 +82,6 @@ ircd::fs::aio::submit_coalesce
|
||||||
|
|
||||||
ircd::fs::aio::init::init()
|
ircd::fs::aio::init::init()
|
||||||
{
|
{
|
||||||
assert(!system);
|
|
||||||
if(!aio::enable)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Don't init AIO if the io_uring is established. If it is, that means it
|
// Don't init AIO if the io_uring is established. If it is, that means it
|
||||||
// was supported by the build, this kernel, and didn't encounter an error
|
// was supported by the build, this kernel, and didn't encounter an error
|
||||||
// to construct. In all other cases AIO can serve as a fallback.
|
// to construct. In all other cases AIO can serve as a fallback.
|
||||||
|
@ -94,29 +90,12 @@ ircd::fs::aio::init::init()
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// We don't know which storage device (if any one) will be used by this
|
assert(!system);
|
||||||
// application, and we only have one aio instance shared by everything.
|
if(!aio::enable)
|
||||||
// To deal with this for now, we look for the most favorable device and
|
return;
|
||||||
// tune to it. The caveat here is that if the application makes heavy use
|
|
||||||
// of an inferior device on the same system, it wont be optimally utilized.
|
|
||||||
if(max_events == 0UL)
|
|
||||||
fs::dev::for_each("disk", []
|
|
||||||
(const ulong &id, const fs::dev::blk &device)
|
|
||||||
{
|
|
||||||
max_events._value = std::clamp
|
|
||||||
(
|
|
||||||
device.queue_depth, size_t(max_events), MAX_EVENTS
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
if(!max_events)
|
||||||
});
|
max_events._value = query_max_events();
|
||||||
|
|
||||||
// If max_events is still not determined here set a sane default.
|
|
||||||
if(max_events == 0UL)
|
|
||||||
{
|
|
||||||
static const auto MAX_EVENTS_DEFAULT {32UL};
|
|
||||||
max_events._value = std::min(MAX_EVENTS, MAX_EVENTS_DEFAULT);
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(max_events);
|
assert(max_events);
|
||||||
system = new struct aio::system
|
system = new struct aio::system
|
||||||
|
@ -134,6 +113,35 @@ noexcept
|
||||||
system = nullptr;
|
system = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We don't know which storage device (if any one) will be used by this
|
||||||
|
// application, and we only have one aio instance shared by everything.
|
||||||
|
// To deal with this for now, we look for the most favorable device and
|
||||||
|
// tune to it. The caveat here is that if the application makes heavy use
|
||||||
|
// of an inferior device on the same system, it wont be optimally utilized.
|
||||||
|
size_t
|
||||||
|
ircd::fs::aio::init::query_max_events()
|
||||||
|
{
|
||||||
|
size_t ret(0);
|
||||||
|
fs::dev::for_each("disk", [&ret]
|
||||||
|
(const ulong &id, const fs::dev::blk &device)
|
||||||
|
{
|
||||||
|
ret = std::clamp
|
||||||
|
(
|
||||||
|
device.queue_depth, ret, MAX_EVENTS
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(!ret)
|
||||||
|
{
|
||||||
|
static const auto MAX_EVENTS_DEFAULT {32UL};
|
||||||
|
ret = std::min(MAX_EVENTS, MAX_EVENTS_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// ircd/fs/op.h
|
// ircd/fs/op.h
|
||||||
|
|
Loading…
Reference in a new issue