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

ircd::fs::aio: Add custom allocator at descriptor site for the sigfd operation.

This commit is contained in:
Jason Volk 2019-03-27 03:06:46 -07:00
parent 3225c1fdfe
commit 334484c4bc
2 changed files with 33 additions and 6 deletions

View file

@ -781,12 +781,7 @@ try
std::bind(&system::handle, this, ph::_1, ph::_2)
};
static ios::descriptor descriptor
{
"ircd::fs::aio sigfd"
};
resfd.async_read_some(bufs, ios::handle(descriptor, std::move(handler)));
resfd.async_read_some(bufs, ios::handle(handle_descriptor, std::move(handler)));
}
catch(...)
{
@ -794,6 +789,34 @@ catch(...)
throw;
}
decltype(ircd::fs::aio::system::handle_descriptor)
ircd::fs::aio::system::handle_descriptor
{
"ircd::fs::aio sigfd",
// allocator; custom allocation strategy because this handler
// appears to excessively allocate and deallocate 120 bytes; this
// is a simple asynchronous operation, we can do better (and perhaps
// even better than this below).
[](auto &handler, const size_t &size)
{
assert(ircd::fs::aio::system);
auto &system(*ircd::fs::aio::system);
if(unlikely(!system.handle_data))
{
system.handle_size = size;
system.handle_data = std::make_unique<uint8_t[]>(size);
}
assert(system.handle_size == size);
return system.handle_data.get();
},
// no deallocation; satisfied by class member unique_ptr
[](auto &handler, void *const &ptr, const auto &size) {}
};
/// Handle notifications that requests are complete.
void
ircd::fs::aio::system::handle(const boost::system::error_code &ec,

View file

@ -44,6 +44,10 @@ struct ircd::fs::aio::system
size_t in_flight {0};
bool handle_set {false};
size_t handle_size {0};
std::unique_ptr<uint8_t[]> handle_data;
static ios::descriptor handle_descriptor;
/// An eventfd which will be notified by the system; we integrate this with
/// the ircd io_service core epoll() event loop. The EFD_SEMAPHORE flag is
/// not used to reduce the number of triggers. The semaphore value is the