Subject: bug#19776: timerfd doesn't work when busy-looping

From: Lars Ingebrigtsen <[email-masked]>
Date: Mon, 25 Oct 2021 17:05:10 +0200

The timerfd stuff was added in

commit 768b24eb0e880c0b39e36fd089905cdca572a758
Author:     Dmitry Antipov <[email-masked]>
AuthorDate: Mon Jul 28 10:28:15 2014 +0400

    On GNU/Linux, use timerfd for asynchronous timers.

so I've added Dmitry to the CCs to get some input.

Dmitry, the issue is that with timerfd, no atimers are delivered when
Emacs is busy-looping, like:

  (with-delayed-message 2 "Yes"
    (while t))

If we disable the timerfd stuff, then the timer will fire after two
seconds.  So I'm wondering whether this used to work when timerfd was
introduced (and this has regressed over the years), or whether it's
always been a design constraint that timerfd events would never be
delivered when Emacs ways busy-looping?

When Emacs is idling (and polling the fds), then the timerfd approach
works well, for instance with:

  (with-delayed-message 2 "Yes"
    (sleep-for 10))

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no