unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: larsi@gnus.org, aaronjensen@gmail.com, emacs-devel@gnu.org
Subject: Re: A whole lotta auto-saving going
Date: Mon, 11 Jan 2021 13:00:33 -0500	[thread overview]
Message-ID: <jwvsg775qkk.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <831rerfm7p.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 11 Jan 2021 18:54:34 +0200")

>> But the `do_display` argument indicates that if redisplay is needed it
>> can happen without returning from `wait_reading_process_output`.
> Do we get to where that causes redisplay in this case?

I don't know, but we should because the code does pass a true value for
this parameter.

>> > I think a simple solution to this would be to check the time passed
>> > after sit_for returns, and if some of the wait time is left, not call
>> > auto-save.  This would mimic what happened before the offending
>> > changeset.
>> The patch below implements that option.
> Thanks.
> I see you look at the number of bytes read, but what about the case
> that a process exited?

I don't know anything about that case, sorry (i.e. I don't know if it
causes `wait_reading_process_output` to exit early).  So ... let me test it.
Hmm... interesting.  I used the current `master` code with the following
base test case:

    src/emacs -Q --eval '(start-process "toto" "*scratch*" "sh" "-c" "while sleep 1; do echo hi; done")' ~/tmp/foo.c

This triggers the problem where auto-save is done pretty much after
every keystroke (with ~1s delay).  But if I change that to:

    src/emacs -Q --eval '(add-hook `post-command-hook (lambda () (start-process "toto" "*scratch*" "sh" "-c" "sleep 1; echo hi")))' ~/tmp/foo.c

then the problem doesn't seem to occur any more (or rather it still
does, but more rarely, with a pattern I have trouble discerning).
It does occur, OTOH with:

    src/emacs -Q --eval '(add-hook `post-command-hook (lambda () (start-process "toto" "*scratch*" "sh" "-c" "sleep 1; echo hi; sleep 1")))' ~/tmp/foo.c

So it looks like running sentinels does not trigger this problem (it
may even avoid it if the sentinel is run "at the same time" as we
receive output).

With the patch applied, none of the above test cases exhibit the problem
of "A whole lotta auto-saving going".

>> There's one other call to `sit_for` which can be affected:
>>
>> 	  tem0 = sit_for (Vecho_keystrokes, 1, 1);
>> 	  unbind_to (count, Qnil);
>> 	  if (EQ (tem0, Qt)
>> 	      && ! CONSP (Vunread_command_events))
>> 	    echo_now ();
>>
>> I believe it's an improvement there as well.
>
> Why do you believe that?

Because I remember noticing that the echo-keystrokes output sometimes
was displayed earlier than expected (and that it seemed related to
process output).

> It's a different use case, and I don't think we saw any adverse
> effects there from the removal of the buffer-switch "event".
> Are there any adverse effects?

The fact that echo-keystrokes were displayed earlier than expected was
not a serious issue, so I didn't bother to report it.  But I do think
it's an adverse effect.

This said, the current patch has the inverse effect (just like the old
code): auto-save (and echo-keystrokes) can be delayed (potentially
indefinitely) by process output since the `sit_for` call will only
return nil if we waited until timeout without being interrupted by any
process output.  That's why I think in the long run it would be good to
change `sit_for` so it actually does wait the specified time even when
process output comes in (just like The Elisp `sit-for` function does).


        Stefan




  reply	other threads:[~2021-01-11 18:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-06 22:05 A whole lotta auto-saving going Aaron Jensen
2021-01-07 12:24 ` Lars Ingebrigtsen
2021-01-07 15:21   ` Stefan Monnier
2021-01-08 14:05     ` Aaron Jensen
2021-01-08 14:19       ` Aaron Jensen
2021-01-10 11:10         ` Lars Ingebrigtsen
2021-01-10 15:08           ` Aaron Jensen
2021-01-10 15:24             ` Lars Ingebrigtsen
2021-01-10 17:27               ` Eli Zaretskii
2021-01-10 17:38                 ` Stefan Monnier
2021-01-11  4:23                   ` Stefan Monnier
2021-01-11 15:04                     ` Eli Zaretskii
2021-01-11 16:00                       ` Stefan Monnier
2021-01-11 16:54                         ` Eli Zaretskii
2021-01-11 18:00                           ` Stefan Monnier [this message]
2021-01-12 14:58                             ` Eli Zaretskii
2021-01-12 15:18                               ` Stefan Monnier
2021-01-13 22:25                             ` Stefan Monnier
2021-01-18 16:06                               ` Lars Ingebrigtsen
2021-01-10 17:18           ` Stefan Monnier
2021-01-10 18:34             ` T.V Raman
2021-01-10 18:54               ` Aaron Jensen
2021-01-12 16:02                 ` T.V Raman via Emacs development discussions.
2021-01-07 14:55 ` Eli Zaretskii
2021-01-10 11:09   ` Lars Ingebrigtsen

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=jwvsg775qkk.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=aaronjensen@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    /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).