unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ken Raeburn <raeburn@raeburn.org>
To: "Elias Mårtenson" <lokedhs@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: "concurrency" branch updated
Date: Tue, 3 Nov 2015 04:40:11 -0500	[thread overview]
Message-ID: <3C732C2C-27AA-44D3-8E00-7742C004960C@raeburn.org> (raw)
In-Reply-To: <CADtN0WL8UCv1+pfequQhjwxcSUs79qeXLEOzM+picxXUmKM3FQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2521 bytes --]


> On Nov 2, 2015, at 22:58, Elias Mårtenson <lokedhs@gmail.com> wrote:
> 
> I started playing around with this branch a bit and I quickly discovered an issue. I wanted to take the opportunity of describing this issue while at the same time hopefully gain some insight into the design of the feature.
> 
> What I did was to write the following function:
> 
>     (defun foo ()
>       (loop for i from 0 below 10
>             do (message (format "Message %d" i))
>             do (sit-for 1)))
> 
> I then started this function in a thread:
> 
>     (make-thread #'foo)
> 
> What happened was that the 10 messages were printed to the *Messages* buffer without any delay between them, and then the entire Emacs session became incredibly sluggish.

Interesting… my use has been pretty minimal thus far, certainly not enough to be looking at performance issues. Though, I tried running your test case, and after displaying the messages, one per second, Emacs crashed! :-(

In my tests I’m usually running a pretty minimal environment — “emacs -Q”, no subprocesses or timers set up, Emacs should be basically quiescent when I’m not doing something to it. Could there have been any sort of input events pending (mouse motion, for example) that could cause it to skip the delay in sit-for in your test?

I do suspect that some things dealing with user input (reading, testing availability, even the flag indicating we’re waiting) might get confused in a multithreaded setup. The test I was using recently that reliably crashed Emacs was:

  (make-thread (lambda () (signal ‘foo nil)))

…though it has to be in an interactive Emacs, where the waiting_for_input flag can be set, which the “signal” routine really doesn’t like. Possibly waiting_for_input needs to be thread-local… or if it stays global, maybe Fsignal() just shouldn’t be looking at it any more.

A previous test which broke the pre-merged concurrency branch but which I haven’t tested recently was to create a thread and have it prompt for input… I think it was either yes-or-no-p or y-or-n-p; it seemed to put Emacs into a state where there were no key bindings, so it would complain about every character I typed.

So…yeah. Input seems to be a fragile area on the branch.

> Looking at the implementation of sit-for, it seems as though it ends up calling read-event on a different thread which is probably not a good idea. Is this a correct assessment?

Sounds about right to me, yes.

Ken

[-- Attachment #2: Type: text/html, Size: 4056 bytes --]

  reply	other threads:[~2015-11-03  9:40 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-01  6:19 "concurrency" branch updated Ken Raeburn
2015-11-02 17:09 ` Eli Zaretskii
2015-11-02 20:23 ` John Wiegley
2015-11-02 20:35   ` Eli Zaretskii
2015-11-02 20:41     ` Eli Zaretskii
2015-11-02 21:57       ` John Wiegley
2015-11-03  3:58         ` Elias Mårtenson
2015-11-03  9:40           ` Ken Raeburn [this message]
2015-11-03 16:26             ` Eli Zaretskii
2015-11-03 16:23           ` Eli Zaretskii
2015-11-03  9:40   ` Ken Raeburn
2015-11-03 11:50     ` other "concurrency" approaches Nic Ferrier
2015-11-03 15:44       ` Eli Zaretskii
2015-11-03 17:16         ` Nic Ferrier
2015-11-03 17:23           ` Eli Zaretskii
2015-11-03 22:28             ` Nic Ferrier
2015-11-04  3:48               ` Eli Zaretskii
2015-11-03 15:14     ` "concurrency" branch updated Filipp Gunbin
2015-11-03 15:35       ` Michael Albinus
2015-11-03 16:38         ` Thierry Volpiatto
2015-11-03 16:29     ` Eli Zaretskii
2015-11-04  9:20       ` Ken Raeburn
2015-11-04 15:40         ` Eli Zaretskii
2015-11-04 19:48           ` Ken Raeburn
2015-11-04 20:51             ` Eli Zaretskii
2015-11-05  5:16               ` Ken Raeburn
2015-11-04 23:09         ` Richard Stallman
2015-11-05  3:41           ` Eli Zaretskii
2015-11-05  6:29           ` Ken Raeburn
2015-11-05 13:17             ` John Wiegley
2015-11-05 14:17               ` David Kastrup
2015-11-05 15:07                 ` John Wiegley
2015-11-05 21:55               ` Tom Tromey
2015-11-05 22:01                 ` John Wiegley
2015-11-05 22:46             ` Richard Stallman
2015-11-06  8:37               ` Eli Zaretskii
2015-11-05 21:49           ` Tom Tromey
2015-11-05 21:46         ` Tom Tromey
2015-11-06  7:58           ` Eli Zaretskii
2015-11-06 14:58             ` Tom Tromey

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=3C732C2C-27AA-44D3-8E00-7742C004960C@raeburn.org \
    --to=raeburn@raeburn.org \
    --cc=emacs-devel@gnu.org \
    --cc=lokedhs@gmail.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).