unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: HaiJun Zhang <netjune@outlook.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 38807@debbugs.gnu.org, michael.albinus@gmx.de
Subject: bug#38807: [Feature request]: Support lisp workers like web workers.
Date: Wed, 1 Jan 2020 10:59:31 +0800	[thread overview]
Message-ID: <SG2PR03MB361167A3B1244B7EF99D5BFCB7210@SG2PR03MB3611.apcprd03.prod.outlook.com> (raw)
In-Reply-To: <83lfqslafm.fsf@gnu.org>

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

在 2020年1月1日 +0800 AM12:36,Eli Zaretskii <eliz@gnu.org>,写道:
> The Lisp interpreter already sort-of "queues" display changes, because
> it only changes Lisp data structures, and then the display engine
> references those data structures at display time. So those data
> structures serve as a kind-of "queue", since redisplay runs when Emacs
> is idle (i.e., the last Lisp command completed its job).
>
> But the problem is in the other direction: it's not that Lisp somehow
> "drives" the UI, it's that the UI frequently calls into Lisp as part
> of its job. The simplest example is mode-line format: it includes
> references to variables, and can also include :eval forms that call
> the interpreter.
>

It is much clearer to me now. We can keep them all as the UI thread.

> Your idea in fact means to have several isolated Lisp machines in the
> same process. But how can we do something like that without a very
> radical redesign of Emacs, when so many things in Emacs are implicitly
> part of the global state? Buffers, global variables, windows,
> frames--all those are global resources, and every thread will want to
> access them. Emacs was not designed to allow that.
>

All those global resources are not accessible by workers. Workers can only access network, file system and other non-global resources. They only do the following things:
1. retrieve content from network, parse the data, and send the result(lisp data) to the UI thread to present it
2. communicate with subprocesses, parse the data from subprocesses, and send the result to the UI thread
3. do file indexing and send the index result to the UI thread
4. do other heavy work like mathematicl calculation and deep learning, send the result to the UI thread

Let the UI thread do as less work as possible.


> Your idea can be implemented with two processes, though. And there is
> already a package called emacs-async which does that:
>
> https://github.com/jwiegley/emacs-async
>

I knew this package. It is a good idea. Modern web browsers also use separate processes to render page content(one or more pages per process). They design specific IPC to let the worker processes to communicate with the main(UI) process. They have good performance and good user responsiveness.

I think emacs is much like web browsers. Both render large text content and care user responsiveness. We can learn from them.

> The disadvantage is that it is cumbersome to share data between the
> two instances of Emacs, and large amounts of data will make that
> inefficient.

We may design an IPC for their communication.


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

  reply	other threads:[~2020-01-01  2:59 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <aade4dc9-4992-4751-9706-9802389ff732@Spark>
2019-12-30  5:27 ` bug#38807: [Feature request]: Support lisp workers like web workers HaiJun Zhang
2019-12-30 15:23   ` Eli Zaretskii
2019-12-30 15:40     ` Dmitry Gutov
2019-12-30 16:26       ` Eli Zaretskii
2020-01-01  3:20         ` HaiJun Zhang
2020-01-01  3:37           ` Eli Zaretskii
2020-01-01  3:57             ` HaiJun Zhang
     [not found]             ` <39f1e59e-08db-4862-98db-c31c3bcbab06@Spark>
2020-01-01  4:02               ` HaiJun Zhang
2020-01-01 15:32                 ` Eli Zaretskii
2020-01-03  2:05                   ` HaiJun Zhang
2020-01-03 13:38                     ` arthur miller
2020-01-04  5:59                       ` HaiJun Zhang
2020-01-04  8:11                   ` HaiJun Zhang
2020-01-04  9:07                     ` Eli Zaretskii
2020-01-04  9:10                   ` HaiJun Zhang
2020-01-01  3:06       ` HaiJun Zhang
2019-12-30 18:31     ` Michael Albinus
2019-12-30 19:19       ` Eli Zaretskii
2019-12-30 19:22         ` Eli Zaretskii
2019-12-31  0:40         ` HaiJun Zhang
2019-12-31  1:39           ` arthur miller
2020-01-01  3:47             ` HaiJun Zhang
2020-01-01 16:23               ` Eli Zaretskii
2020-01-03  3:45                 ` HaiJun Zhang
2020-01-03  6:06                   ` Eli Zaretskii
2020-01-04  5:47                     ` HaiJun Zhang
2019-12-31 16:35           ` Eli Zaretskii
2020-01-01  2:59             ` HaiJun Zhang [this message]
2020-01-01 16:21               ` Eli Zaretskii
2020-01-03  3:18                 ` HaiJun Zhang
2020-01-03  6:02                   ` Eli Zaretskii
2020-01-04  5:26                     ` HaiJun Zhang
2020-01-04  9:00                       ` Eli Zaretskii
2020-03-21  2:24                         ` HaiJun Zhang
2020-03-21  8:16                           ` Eli Zaretskii
2020-03-22  1:12                             ` HaiJun Zhang
2020-03-22 14:32                               ` Eli Zaretskii
2020-03-24  4:22                                 ` HaiJun Zhang
2020-03-24 14:40                                   ` Eli Zaretskii
2020-03-26 13:37                                     ` HaiJun Zhang
2020-03-26 14:44                                       ` Eli Zaretskii
2020-03-26 18:14                                         ` Ivan Yonchovski
2020-03-29  2:41                                           ` HaiJun Zhang
2020-03-29  2:12                                         ` HaiJun Zhang
2020-03-25 16:44                                   ` Ivan Yonchovski
2020-03-25 17:05                                     ` Eli Zaretskii
2020-03-25 17:21                                       ` Ivan Yonchovski
2020-03-26 13:49                                     ` HaiJun Zhang
2020-01-04  5:55                     ` HaiJun Zhang
2020-01-03  3:34                 ` HaiJun Zhang
2020-01-03 14:10                   ` arthur miller
2020-01-04  6:41                     ` HaiJun Zhang
2020-01-01  3:16       ` HaiJun Zhang
2020-01-01  9:14         ` Michael Albinus
2020-01-03  2:52           ` HaiJun Zhang
2020-01-03  5:59             ` Eli Zaretskii
2020-01-04  5:19               ` HaiJun Zhang
2020-01-04  8:59                 ` Eli Zaretskii
2020-01-04  9:33                   ` HaiJun Zhang
2020-01-04  9:51                     ` Eli Zaretskii
2020-01-06  5:08                       ` HaiJun Zhang
2020-01-06 16:07                         ` Eli Zaretskii
2020-01-01 14:52   ` arthur miller
2020-01-03  1:49     ` HaiJun Zhang
2020-01-03 13:35       ` arthur miller
2020-01-03 14:26         ` Eli Zaretskii
2020-01-03 15:14           ` arthur miller
2020-01-03 14:19   ` arthur miller
2020-01-03 14:39     ` Eli Zaretskii
2022-04-30 12:32   ` 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=SG2PR03MB361167A3B1244B7EF99D5BFCB7210@SG2PR03MB3611.apcprd03.prod.outlook.com \
    --to=netjune@outlook.com \
    --cc=38807@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=michael.albinus@gmx.de \
    /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).