> From: Suhail Singh <suhailsingh...@gmail.com> > Cc: Michael Albinus <michael.albi...@gmx.de>, suhailsingh...@gmail.com, > 73...@debbugs.gnu.org > Date: Sun, 08 Sep 2024 12:46:39 -0400 > > Eli Zaretskii <e...@gnu.org> writes: > > > Waiting for a process to respond should try not to spin without > > sleeping for a few milliseconds between polling attempts. > > A constant delay busy-wait would be better than what's there today.
It isn't a delay, or at least the delay is not the main point. The main point is to yield the CPU, and that usually has dramatic effect on CPU load. > However, I thought you'd be proposing something like registering a > "callback". Out of curiosity, since I am unfamiliar with the relevant > Emacs internals, would it not be possible to add a function to the > equivalent of `after-change-functions' that processes the output? accept-process-output already does that. Except that with a timeout of zero, it just checks whether any output arrived, and if not, returns immediately. Adding a timeout will AFAIU cause us to let the OS preempt our execution thread and reschedule it only if no output arrives during the timeout.