Subject: Re: bug#38644: 26.3; emacs uses 100% CPU with auto-revert-mode

From: Michael Albinus <[email-masked]>
Date: Sun, 29 Dec 2019 16:23:46 +0100

Peter Ludemann <[email-masked]> writes:

Hi Peter,

>> In bug#33194, a patch for Emacs 27.0.50 is mentioned. Do you have a
>> chance to run this for test?
>
> Emacs 27.0.50 somewhat fixes the problem with global-auto-revert-mode,
> using the same desktop file (and same open files) that was causing
> problems with Emacs 26.3. (Sorry I took so long to test this.)

Thanks for the feedback, the fix in Emacs 27 seems to work.

> Emacs CPU utilization is now ~30-80% (according to top(1)) instead of
> 100%; and responsiveness is good. Of course, it would be nicer if
> emacs CPU utilization were less, so that I could fully utilize that
> core (I only have 4 cores, so losing half a core is notable on large
> tests).

If I count correctly, your desktop file contains 489 buffers. Heavy load
for global-auto-revert-mode.

> Michael Albinus - you had a number of other questions ... do you still
> want them (or some of them) answered?

No, I don't believe so.

> PS: Here's the desktop file, in case that can give some clue as to
> what file or directory is causing problems. The "compilation"
> processes both input from and output into /tmp/pykythe_test -- as you
> can see, there are a couple of open files from that directory, but
> they're not being continuously updated, only once or twice per test.

auto-revert watches directories. Even if you watch only some few files
in a directory (I count 29 buffers which are bound to "/tmp"), there
will be lot of file notification events when other files in that
directory are changed. Maybe it helps to set auto-revert-use-notify to
nil for those files? You could do it via directory-local variales, as in

(dir-locals-set-class-variables 'auto-revert-with-polling
   '((nil . ((auto-revert-use-notify . nil)))))

(dir-locals-set-directory-class
   "/tmp/" 'auto-revert-with-polling)

(This is untested.)

> best,
> - peter

Best regards, Michael.