Subject: Re: bug#76609: 31.0.50; The 0.1s repeat timer is very CPU-intensive; it might be a bug?

From: Eval Exec <[email-masked]>
Date: Thu, 27 Feb 2025 23:13:44 +0800

> Look at the code Emacs runs in its idle loop

Could you please guide me where is the idle loop related code in emacs
source repo? which file and which lines ranges.
Thank you.

On Thu, Feb 27, 2025 at 11:07 PM Eli Zaretskii <[email-masked]> wrote:

> > From: Eval Exec <[email-masked]>
> > Date: Thu, 27 Feb 2025 22:38:35 +0800
> > Cc: [email-masked]
> >
> > Compare to a bash script:
> > while true; do
> >   sleep 0.1;
> >    date
> > done
> >
> > above script have 0% CPU usage on my laptop.
> >
> > change it to 0.0001:
> > while true; do
> >   sleep 0.0001;
> >    date
> > done
> >
> > even 0.0001 s repeat, the bash script only have 4% cpu usage.
> >
> > So I think a 0.1s repeat timer in Emacs consume 45% is very surprise.
> > I think maybe we should improve the timer performance
>
> This is not a serious argument, sorry.  Look at the code Emacs runs in
> its idle loop, and you will understand how invalid is any comparison
> with a shell script which does little except sleeping for 0.1 sec.
>