Subject: bug#38807: [Feature request]: Support lisp workers like web workers.

From: HaiJun Zhang <[email-masked]>
Date: Wed, 1 Jan 2020 11:47:49 +0800

My understanding of the display flow:
1. an event comes which causes redisplay
2. the display engine prepares the glyph matrix
3. convert the glyph matrix to bitmap and display it

I think lots of work are in 2. During the work in 2, the display code needs to access many resources in lisp machine and even may eval lisp forms. The resources it accesses are too wildcard, so that we can't copy the resources to it and put them to queue. For multi-threading, we need a global lock.

在 2019年12月31日 +0800 AM9:39，arthur miller <[email-masked]>，写道：
> Cool idea.
>
> I have a question.  Is it even necessary for lisp machine to control UI?
>
> Couldn't lisp machine post its "ui events" to a some kind of render queue and maybe input queue, instead of drawing and handling stuff immediately in an OS window? That could decouple drawing from the rest and could open for some other interesting stuff when it comes for rendering.
>
> I don't know maybe another thread for input queue. Probably too much work and I really don't know if that would be possible with Emacs architecture, at least as of current.
>
> I mean does lisp machine really need to know where it draws? It could as well just "draw" some events to a queue which could be rendered away in different passes, by different threads and so on.
>
> Skickat från min Samsung Galaxy-smartphone.
>
>
>
> -------- Originalmeddelande --------
> Från: HaiJun Zhang <[email-masked]>
> Datum: 2019-12-31 01:42 (GMT+01:00)
> Till: Michael Albinus <[email-masked]>, Eli Zaretskii <[email-masked]>
> Kopia: [email-masked]
> Ämne: bug#38807: [Feature request]: Support lisp workers like web workers.
>
> 在 2019年12月31日 +0800 AM3:19，Eli Zaretskii <[email-masked]>，写道：
> > > From: Michael Albinus <[email-masked]>
> > > Cc: HaiJun Zhang <[email-masked]>, [email-masked]
> > > Date: Mon, 30 Dec 2019 19:31:26 +0100
> > >
> > > The point seems to be that there is a dedicated UI thread. That we don't
> > > have (yet) in Emacs, and I like this idea.
> >
> > We do have that on MS-Windows. Except that you'll be surprised how
> > much of "UI" in Emacs cannot be done in a separate thread, mainly
> > because the Lisp machine is under such complete control of what the UI
> > does, and you cannot run several instances of the Lisp machine
> > simultaneously and asynchronously.
>
> What about the following idea:
> 1. Make the current lisp machine be customized which has two profiles:
>     + full featured: as the current running lisp machine in emacs
>     + subset one: without all UI functions
> 2. Run the full featured one as emacs does now. It acts as the master lisp machine(for UI only), which behave like the UI thread(process) in the web browser.
> 3. Run some subset ones for workers. Workers are started by the master lisp machine. Workers can send messages to the master machine by calling some APIs. The messages are copied to the master lisp machine, so GCs don’t need to work across machines.
> 4. Provide some APIs for them to communicate with each other.
>