From: Tom Tromey <tromey@redhat.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: advice needed for multi-threading patch
Date: Fri, 18 Sep 2009 16:59:37 -0600 [thread overview]
Message-ID: <m37hvvc10m.fsf@fleche.redhat.com> (raw)
In-Reply-To: <jwvk50q75rs.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 26 Aug 2009 15:18:06 -0400")
Tom> I'm trying to properly implement per-thread let binding in the presence
Tom> of buffer-local variables.
Stefan> The problem with that is that we first need to figure out what its
Stefan> semantics should be. And to me the semantics of a let-bound
Stefan> buffer-local variable is very much unclear in the presence of threads
Stefan> (it's already pretty messy even without threads).
Stefan> So I'd rather disallow other threads from accessing this buffer's
Stefan> variable while the let-binding is active.
I thought I'd post a status report on the multi-threading patch.
First, thanks to Giuseppe, it is all hosted on Gitorious:
http://gitorious.org/emacs-mt
'mt' is the branch I've been working on, he's done some additional fixes
and changes on g-exp. (I am behind on pulling from him... and we don't
agree about everything, hence two branches :-)
What works:
* You can start a new thread with run-in-thread. The exact use differs
between the branches. Threads are cooperative, you can yield with an
explicit call to yield.
* The GC handles multiple threads.
* Many, but not all, of the 9 kinds of variables that Emacs implements
work properly with threads. In particular, working ones are
defvaralias, objfwd, and ordinary. These all should do the right
thing in all cases. Buffer-local and buffer objfwd mostly work,
because we do buffer locking. (However, I think make-local-variable
doesn't work properly with let-binding and multiple threads.) Not
working on intfwd, boolfwd, keyboard-local and frame-local.
* Buffer locking.
There are also a number of problem areas.
* Buffer locking is actually quite a pain.
If you have a background thread locking some buffer, you can't switch
to that buffer. Emacs will just pause. I don't think we allow
interrupting a lock acquisition (clearly a bug).
* Giuseppe implemented minibuffer exclusion. But really the keyboard
should only be available to one thread at a time.
* I think there are some V* variables that probably should always be
per-thread. My notes say Vsignaling_function, but I know I've run
into other ones. (What is noteworthy about this is that it implies
that a big audit of the C code is necessary..)
* I/O is also an unsolved problem. Right now it is easy to make emacs
appear to hang by running a process filter in one thread while a
different thread owns the buffer lock. (Probably, if a thread owns a
buffer lock, then only that thread should be able to run associated
process filters.)
I think Giuseppe probably knows of more problems.
Also, there are tons more problems if you want preemptive
multithreading... redisplay probably needs work, regex is not reentrant,
the GC needs a bit more work, you need lisp-level locks, etc.
Sometimes I wonder whether it would be better to just fork a second
emacs and communicate with it using pipes + princ + read. This uses
more memory but the implementation would be a lot simpler and (I think)
it would suffice for the one case that seems most important: Gnus.
Anyway, give it a try. We welcome your advice and input.
Finally, we've been doing all our discussions privately on irc. I'd
prefer we discuss everything in the open. Is it ok to use emacs-devel
for this? If not we'll set up a new mailing list somewhere.
Tom
next prev parent reply other threads:[~2009-09-18 22:59 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-26 4:38 advice needed for multi-threading patch Tom Tromey
2009-08-26 7:06 ` Ken Raeburn
2009-08-26 14:52 ` Stefan Monnier
2009-08-26 18:50 ` Ken Raeburn
2009-08-27 3:12 ` Stefan Monnier
2009-08-27 6:28 ` Ken Raeburn
2009-08-27 17:02 ` Stefan Monnier
2009-08-26 16:08 ` Tom Tromey
2009-08-26 18:50 ` Ken Raeburn
2009-08-27 5:07 ` Miles Bader
2009-08-27 6:39 ` Ken Raeburn
2009-08-27 6:50 ` Miles Bader
2009-08-28 20:48 ` Juri Linkov
2009-08-28 22:15 ` Miles Bader
2009-08-28 23:27 ` Juri Linkov
2009-08-28 23:54 ` Miles Bader
2009-08-29 20:21 ` Richard Stallman
2009-08-26 15:02 ` Stefan Monnier
2009-08-26 15:31 ` Tom Tromey
2009-08-26 19:18 ` Stefan Monnier
2009-09-18 22:59 ` Tom Tromey [this message]
2009-09-19 0:09 ` Stephen J. Turnbull
2009-09-19 0:32 ` Chong Yidong
2009-09-21 21:19 ` Stefan Monnier
2009-09-21 21:50 ` Tom Tromey
2009-09-22 14:24 ` Stefan Monnier
2009-09-22 23:59 ` Ken Raeburn
2009-09-23 3:11 ` Stefan Monnier
2009-09-23 15:53 ` Chong Yidong
2009-09-23 3:16 ` Tom Tromey
2009-09-24 17:25 ` Stefan Monnier
2009-09-24 17:57 ` Tom Tromey
2009-09-27 20:59 ` Tom Tromey
2009-09-27 23:05 ` Stefan Monnier
2009-09-28 4:27 ` Tom Tromey
2009-09-29 0:27 ` Stefan Monnier
2009-09-29 2:26 ` Ken Raeburn
2009-09-29 3:20 ` Stefan Monnier
2009-09-29 3:57 ` Ken Raeburn
2009-09-29 3:33 ` Tom Tromey
2009-09-29 4:07 ` Ken Raeburn
2009-09-29 2:30 ` Tom Tromey
2009-09-23 18:43 ` Giuseppe Scrivano
2009-09-24 17:29 ` Stefan Monnier
2009-09-24 18:53 ` Giuseppe Scrivano
2009-09-24 20:04 ` Tom Tromey
2009-09-24 21:59 ` Stefan Monnier
2009-09-24 22:23 ` Giuseppe Scrivano
2009-09-24 22:47 ` Ken Raeburn
2009-09-28 14:52 ` Ted Zlatanov
2009-10-05 6:02 ` joakim
2009-09-28 7:44 ` Lynbech Christian
2009-08-29 0:28 ` Giuseppe Scrivano
2009-08-29 4:57 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m37hvvc10m.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.