0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 00:32:35 +01:00

ircd::ios: Torch any possible idiv in core epoll(2) instruction stream.

This commit is contained in:
Jason Volk 2020-12-18 19:50:35 -08:00
parent c9b4fe6797
commit 7d1de2ded7

View file

@ -51,28 +51,36 @@ ircd::ios::epoll_wait(int _epfd,
int _timeout) int _timeout)
noexcept noexcept
{ {
const bool peek // Call elision tick counter.
{ thread_local uint64_t tick;
_timeout == 0
};
// Configured frequency to allow the call.
const uint64_t freq const uint64_t freq
{ {
empt::freq empt::freq
}; };
const bool skip_tick const bool skip
{ {
!freq || (uint64_t(empt::peek) % freq) !freq || (tick < freq)
};
const bool peek
{
_timeout == 0
}; };
// Always allow blocking calls; only allow non-blocking calls which // Always allow blocking calls; only allow non-blocking calls which
// satisfy our conditions. // satisfy our conditions.
const bool call const bool call
{ {
!peek || !skip_tick !peek || !skip
}; };
// Modify tick counter prior to call, while we have the line.
tick -= boolmask<decltype(tick)>(call) & tick;
tick += boolmask<decltype(tick)>(!call) & 0x01;
const int ret const int ret
{ {
call? call?
@ -94,8 +102,9 @@ noexcept
log::logf log::logf
{ {
log, ircd::log::DEBUG, log, ircd::log::DEBUG,
"EPOLL %5d peek:%lu skip:%lu call:%lu none:%lu result:%lu low:%lu med:%lu high:%lu stall:%lu", "EPOLL %5d tick:%lu peek:%lu skip:%lu call:%lu none:%lu result:%lu low:%lu med:%lu high:%lu stall:%lu",
ret, ret,
tick,
uint64_t(empt::peek), uint64_t(empt::peek),
uint64_t(empt::skip), uint64_t(empt::skip),
uint64_t(empt::call), uint64_t(empt::call),