From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#38807: [Feature request]: Support lisp workers like web workers. Date: Wed, 01 Jan 2020 18:21:16 +0200 Message-ID: <83r20jjgg3.fsf@gnu.org> References: <83o8vpn8g1.fsf@gnu.org> <87mub9u0ld.fsf@gmx.de> <831rslmxih.fsf@gnu.org> <83lfqslafm.fsf@gnu.org> Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="153548"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 38807@debbugs.gnu.org, michael.albinus@gmx.de To: HaiJun Zhang Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 01 17:22:15 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1imglC-000dmO-SI for geb-bug-gnu-emacs@m.gmane.org; Wed, 01 Jan 2020 17:22:15 +0100 Original-Received: from localhost ([::1]:59700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1imglA-00052b-Nn for geb-bug-gnu-emacs@m.gmane.org; Wed, 01 Jan 2020 11:22:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44350) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1imgl1-00052C-Pt for bug-gnu-emacs@gnu.org; Wed, 01 Jan 2020 11:22:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1imgl0-0004G2-LO for bug-gnu-emacs@gnu.org; Wed, 01 Jan 2020 11:22:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59698) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1imgl0-0004FG-Hr for bug-gnu-emacs@gnu.org; Wed, 01 Jan 2020 11:22:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1imgl0-0001ly-Dg for bug-gnu-emacs@gnu.org; Wed, 01 Jan 2020 11:22:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 01 Jan 2020 16:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38807 X-GNU-PR-Package: emacs Original-Received: via spool by 38807-submit@debbugs.gnu.org id=B38807.15778956726724 (code B ref 38807); Wed, 01 Jan 2020 16:22:02 +0000 Original-Received: (at 38807) by debbugs.gnu.org; 1 Jan 2020 16:21:12 +0000 Original-Received: from localhost ([127.0.0.1]:37434 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1imgkC-0001kO-Gb for submit@debbugs.gnu.org; Wed, 01 Jan 2020 11:21:12 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33851) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1imgkA-0001k6-6Q for 38807@debbugs.gnu.org; Wed, 01 Jan 2020 11:21:11 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:37994) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1imgk4-0001rv-50; Wed, 01 Jan 2020 11:21:04 -0500 Original-Received: from [176.228.60.248] (port=4323 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1imgk3-0000KJ-Ga; Wed, 01 Jan 2020 11:21:03 -0500 In-reply-to: (message from HaiJun Zhang on Wed, 1 Jan 2020 10:59:31 +0800) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:174043 Archived-At: > Date: Wed, 1 Jan 2020 10:59:31 +0800 > From: HaiJun Zhang > Cc: michael.albinus@gmx.de, 38807@debbugs.gnu.org > > 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 Then these threads cannot really run Lisp at all, nor even directly affect Lisp data. So in effect you want to be able to run threads that don't enter the Lisp interpreter, nor modify any Lisp data. We already have that available: you can write a module which Emacs can load, and that module can then start any number of threads doing any calculations or network communications you want. See emacs-module.h. > 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. For some data structures, yes. But buffer text and long strings are problematic, because the text can be very large.