From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Tom Tromey <tromey@redhat.com>
Cc: Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: advice needed for multi-threading patch
Date: Thu, 24 Sep 2009 13:25:03 -0400 [thread overview]
Message-ID: <jwvtyysnui4.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <m31vlyqrk8.fsf@fleche.redhat.com> (Tom Tromey's message of "Tue, 22 Sep 2009 21:16:07 -0600")
> Yeah. What I meant here is that specbind has a little extra code in it
> to install a Lisp_ThreadLocal object when needed. So, if the C code
> uses specbind to do let-like binding, everything will work fine. If the
> C code does not do this, then things will break.
I see, yes of course it's a problem. And it's worse than that: the same
holds for *all* global variables, whether they are exported to Lisp
or not.
Stefan> I think it should, unless some of the buffer-local variables are
Stefan> let-bound by the thread.
> I've been thinking about this a bit. It is trickier than it seems,
> because a thread can actually have let-bindings for buffer-locals from
> multiple buffers at the same time. There's an example of this in the
> elisp manual. (This is also an area the threading code does not handle
> well yet.)
> I think this means it does not suffice to keep a simple per-thread count
> of buffer-local bindings.
Indeed. The lock should probably be on the buffer-local binding itself
(i.e. the combination of the buffer and the variable).
> While thinking about this I realized that (I think) the current code
> does the wrong thing if one thread let-binds a variable and then another
> thread calls make-variable-buffer-local on it.
Calling make-variable-buffer-local or make-local-variable when the
variable is let-bound is a serious problem, yes. IIRC we already have
bugs in such cases in the current code.
AFAICT, the only good answer is to disallow such things (e.g. signal an
error in make-variable-buffer-local and make-local-variable when the var
is let-bound).
I already took a tiny step in that direction when I added a warning to
defvar when called while the variable is let-bound.
> It is hard for me to see how this could be done in a compatible way.
Agreed.
> Right now elisp operates with few constraints; an elisp program can call
> select-frame, which seems to imply that per-frame or per-keyboard
> threads can't be done.
The way I think of it is that select-frame would send a message to the
relevant frame, along with a function to run there, and the destination
to which to send the result when the function is done.
But how to link it with the dynamic and foo-local scoping of
let-bindings is still far from clear.
> One thing that would help me is having a concrete idea of what subset of
> features would make this work be actually useful. I mostly implemented
> it because it was cool, and because Giuseppe's initial patch convinced
> me that it was possible (before that I'd written it off as totally
> impractical). Now that a proof of concept works it would be nice to
> have a concrete goal.
Some goals could be:
- run Gnus in its own thread. This should be easy-ish since Gnus
shouldn't interact with pretty much anything else.
- split Gnus into several threads (e.g. in my case, the most important
one would be a thread to do the "g", i.e. refresh the *Group* buffer,
which with IMAP boxes can takes ages).
This is a lot more difficult since this thread would need to interact
with the main Gnus thread.
- move the jit-lock-context to a thread. Might be non-trivial, but at
least the code is small.
- move some VC operations to threads (e.g. vc-checkin).
- run some of the buffer-parsing code in threads (e.g. the one in
CEDET's semantic, or the one in js2-mode).
Stefan
next prev parent reply other threads:[~2009-09-24 17:25 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
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 [this message]
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=jwvtyysnui4.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=tromey@redhat.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 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.