unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Ian Jackson <ijackson@chiark.greenend.org.uk>
Cc: Eli Zaretskii <eliz@gnu.org>, 53432@debbugs.gnu.org
Subject: bug#53432: [PATCH] Avoid losing keyboard input when inotify is too busy [and 1 more messages]
Date: Sun, 23 Jan 2022 09:00:02 +0800	[thread overview]
Message-ID: <87a6fntgfh.fsf@yahoo.com> (raw)
In-Reply-To: <25068.23625.512978.147194@chiark.greenend.org.uk> (Ian Jackson's message of "Sat, 22 Jan 2022 19:34:33 +0000")

Ian Jackson <ijackson@chiark.greenend.org.uk> writes:

> I'm not sure what your underlying objection is to this, so I will
> guess: I think you are concerned at the performance implications of
> allocating each time we handle inotify events.  But my proposed code
> does not allocate each time.  It only (re)allocates when it needs a
> bigger buffer than it already has.

The underlying objection is that it's IMHO wrong to allocate anything on
the heap to cater to "abuse" of a feature, in this case inotify.

> Wouldn't that lead to file notifications getting lost ?  I think that
> might result in buffers not being reverted, even though the user has
> global-auto-revert-mode enabled.  As I say that would be a problem,
> because it can end up with the user editing the wrong version of a
> file.  I don't think it is OK.

It can't end up with the user unknowingly editing the wrong version of a
file, because Emacs will ask him:

  foo.h changed on disk; really edit the buffer? (y, n, r or C-h)

When he first tries to edit the file again (the way this works is not
file notifications, but instead comparing stat data.)

There are also builds without file notifications, which are used on many
systems.

> If it is OK for file notifications to get lost, because the need for a
> buffer revert will be picked up another way somehow, then your
> suggestion makes perfect sense to me.  But in that case, I don't
> understand why this code doesn't use a buffer of fixed size (or, at
> least, limited size).

Which code?  The keyboard buffer is the "buffer of fixed size" in the
inotify code.

> Or to put it another way, the current code does a hair-raising thing
> for which the only explanation I could think of was that it is aiming
> never to lose notifications; and if there's a comment somewhere saying
> that the whole inotify system is best-effort, and it's OK for it to
> drop things when stressed, I have missed it.

All file notification systems are "best effort".  At the very least,
dropping events when the keyboard buffer is full would make the behavior
consistent with GLib file notifications, which drops notifications
whenever its own internal buffer fills up.

> If it is OK for it to be best-effort, then I think this needs to be in
> the documentation for inotify-add-watch.  Currently it says
>
>   The watch will look for ASPECT events and
>   invoke CALLBACK when an event occurs.
>
> and there's nothing saying "it might not happen, so you must arrangee
> that this is not the sole way you are looking for changes".  I think
> that'd be an API which would invite programmers to write and ship lost
> event bugs, especially since usually it would work just fine.

It's acceptable for there to be some lossage when confronted by (in your
own words) abuse of a feature.  That is taken for granted, whether or
not it is documented.

Thanks.





  parent reply	other threads:[~2022-01-23  1:00 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-21 23:36 bug#53432: [PATCH] Avoid losing keyboard input when inotify is too busy Ian Jackson
2022-01-22  0:38 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-22 19:34   ` bug#53432: [PATCH] Avoid losing keyboard input when inotify is too busy [and 1 more messages] Ian Jackson
2022-01-22 19:48     ` Eli Zaretskii
2022-01-23  2:37       ` Dmitry Gutov
2022-01-23  2:47         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-23  2:49           ` Dmitry Gutov
2022-01-23  2:53             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-23  3:23               ` Dmitry Gutov
2022-01-23  3:26                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-23  3:36                   ` Dmitry Gutov
2022-01-23  3:48                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-23  4:07                       ` Dmitry Gutov
2022-01-23  5:50                   ` Eli Zaretskii
2022-01-23 16:34                     ` Michael Albinus
2022-01-23  1:00     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-01-23 13:38       ` Ian Jackson
2022-01-23 16:37         ` Michael Albinus
2022-01-23 18:31           ` Ian Jackson
2022-01-24  0:42             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-24 14:42             ` Michael Albinus
2022-01-24 14:57               ` Eli Zaretskii
2022-01-24 15:35                 ` Michael Albinus
2022-01-24 16:52                   ` Eli Zaretskii
2022-01-24 17:12                     ` Michael Albinus
2022-01-24 17:25                       ` Eli Zaretskii
2022-01-24 15:45               ` Ian Jackson
2022-01-24 17:05                 ` Michael Albinus
2022-01-24 18:59                   ` Ian Jackson
2022-01-25 14:50                     ` Michael Albinus
2022-01-24  0:26         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-22  6:45 ` bug#53432: [PATCH] Avoid losing keyboard input when inotify is too busy Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a6fntgfh.fsf@yahoo.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=53432@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=ijackson@chiark.greenend.org.uk \
    --cc=luangruo@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).