One of the users of my library async-timer encountered the issue with tokio unexpectedly waking up timerfd based Future.
Issue itself is here https://github.com/DoumanAsh/async-timer/issues/9
But tl;dr is following:
- Create timer with PollEvented;
- Poll once to arm timer
- Then for some reason tokio forces few wake ups when there is no interested from mio
- Once timer is actually expired and mio notifies about read interest, timer is polled
I briefly looked over tokio source code and debugged code.
I'm pretty sure wake up is not coming from mio at least, but I do not understand why it would wake up without reason.
The only possible suspicion is that the way tokio's
- It iterates by polling passed future
- It then iterates over pending futures(spawned) up to some constant number.
So my assumption is that something wakes up thread, but I do not see what could be.
If anyone has idea I would appreciate as I otherwise I'm lacking insight in tokio (and time to fix it)
P.s. do not ask why I do not post it on tokio discord, I'll appreciate any advise
P.s.s it happens only with timerfd/kqueue based timers which require mio.