[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#44638: [PATCH 1/2] autorevert: don't reuse existing watch descriptor

From: Spencer Baugh
Subject: bug#44638: [PATCH 1/2] autorevert: don't reuse existing watch descriptors
Date: Sat, 14 Nov 2020 16:19:07 -0500

Eli Zaretskii <eliz@gnu.org> writes:
>> From: Spencer Baugh <sbaugh@catern.com>
>> Date: Sat, 14 Nov 2020 11:54:58 -0500
>> Cc: Spencer Baugh <sbaugh@catern.com>
>> Previously, when enabling autorevert for a new buffer, we would search
>> the buffers already registered with autorevert to see if any of them
>> had the same filename.
>> This is very slow with a large number of buffers - with 1000, it takes
>> 2 seconds on my system. This 2-second overhead is paid for every new
>> file opened.
>> But this is an unnecesary optimization; registering the same file
>> twice with file-notify has minimal or no overhead, depending on the
>> implementation.
> Emacs actually watches the file's directory, not the file itself.  The
> directory is what's registered with inotify and other similar
> backends.
>> In fact, file-notify has some baked-in overhead to support registering
>> the same file twice without problems. For example, inotify on Linux
>> returns the same inotify watch descriptor when the same file is
>> registered twice; file-notify adds an additional uniquifying id so
>> that all watch descriptors are unique in Emacs, even with inotify.
> Again, we watch the directory of the file, so what inotify does with
> files is not really relevant, IMO.  I wonder what that means for the
> changes you propose.

Ah. Well, the inotify comment was just an example. Even given that Emacs
watches directories rather than files, I think this change is for the
best - the overhead of registering 5 files directly instead of 1
underlying directory is minimal.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]