From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: Emacs design and architecture Date: Sat, 16 Sep 2023 22:40:58 +0300 Message-ID: <47dabd46-0831-526c-e7c1-754f028507f3@gutov.dev> References: <83h6nwlmt4.fsf@gnu.org> <456d12ac-ecf4-3de4-56bb-a2440580777f@gutov.dev> <83a5tokmsv.fsf@gnu.org> <83sf7fki5g.fsf@gnu.org> <43d642a8-d1b4-05ed-41e0-6e52d22df2d4@gutov.dev> <83edizjn0v.fsf@gnu.org> <0518f65b-1dd1-6923-8497-da4d3aeac631@gutov.dev> <1cff05f8-df80-b776-5175-dd27a6e59799@gutov.dev> <87wmwqiax9.fsf@whxvd.name> <87a5tmz319.fsf@yahoo.com> <87a5tmp5cv.fsf@thaodan.de> <8b144985-85f2-79e7-d932-2070336b13aa@gutov.dev> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28728"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: =?UTF-8?Q?Bj=c3=b6rn_Bidar?= , Po Lu , Sebastian Miele , Eli Zaretskii , yuri.v.khan@gmail.com, owinebar@gmail.com, rms@gnu.org, emacs-devel@gnu.org To: =?UTF-8?Q?Gerd_M=c3=b6llmann?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Sep 16 21:42:08 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qhbB9-0007Gr-JR for ged-emacs-devel@m.gmane-mx.org; Sat, 16 Sep 2023 21:42:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhbAG-0001Vv-QY; Sat, 16 Sep 2023 15:41:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhbAG-0001Vj-0l for emacs-devel@gnu.org; Sat, 16 Sep 2023 15:41:12 -0400 Original-Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhbAB-0003Sx-Pn; Sat, 16 Sep 2023 15:41:10 -0400 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id AB2793200302; Sat, 16 Sep 2023 15:41:03 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sat, 16 Sep 2023 15:41:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1694893263; x=1694979663; bh=IQ3yJrdl524AhU/j+hMw3EHLbvnPofTpuaa 8wU2VJR8=; b=Uup/30Lq3SHQ1H7L6e0D2Luh5BzoMah6l/xnOZh3wIZ3f75g++9 fnFhWW4HbPb1rApBmd/xW3EArtg74EnmMxeAiCIdbGikrwGsvxZ4IQ3/KUNJUSjj PzZrv/qdHnUpuuYM2ouukGDHvgTM5nEtqRUj/57e/rngeJK9Z8pJ6peisSTZkaFy oKQNwrSLVGGaKRQSKKzEhBh+x1FztCsPycV0Eakufz44p03rT1MxB2q73u9iDLix ENSWR9pduU5ExNBX8DC7bBI89VV4DNFmJKIa1PjUqJuLeK84PfLDMmeGpDstrEJX f4WtCjfESOBG7Qx0ji2vxmZTOGnDYa9ik+Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1694893263; x=1694979663; bh=IQ3yJrdl524AhU/j+hMw3EHLbvnPofTpuaa 8wU2VJR8=; b=UU9U8OntPkWg0dGWNcbjN1otE7N1ojJjZYp7dvghZUw5S5GAe+T Z2PR97lo6Nplyt3fRktImFEMPIYX0tukd2nnWYGY24l7+OhgBWpli/gu7Da6qdC9 SEQGJw1Ya/Bt1wgTx4CsWUBtJfsO2nyM8uaO0I1ZhnGuoUPk0ptqQGBthToP/+1c RFnMJ3Vr75eawmtiXo+w+dYCR5SV7LqezEu377j00DBMFiFpN+JM7+HRFPdPBHeR bJUGUn90EKq5skCnbV8QsLbagNyOWEck7yZEEP2uR+jV3yrtopVROM+6SYFLsyOV l2O+5JnU2ZMmHf6VJzuVaT3x4038VuGfJlQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudejgedgudeflecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttdefjeenucfhrhhomhepffhm ihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrg htthgvrhhnpeegjeegieduueduvdelhfehteevkefgjeffueevheelteffjeefhfevhfev ffegffenucffohhmrghinhepmhgvughiuhhmrdgtohhmpdhrvgguughithdrtghomhenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegumhhithhr hiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 16 Sep 2023 15:41:00 -0400 (EDT) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=64.147.123.25; envelope-from=dmitry@gutov.dev; helo=wout2-smtp.messagingengine.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-1.473, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:310640 Archived-At: On 16/09/2023 21:33, Gerd Möllmann wrote: > Dmitry Gutov writes: > >> On 16/09/2023 20:07, Gerd Möllmann wrote: >>> Dmitry Gutov writes: >>> >>>> On 16/09/2023 17:20, Björn Bidar wrote: >>>>> These more extensive modes require more advanced features similar as >>>>> when turning Emacs into a "word processor". >>>>> In my opinion Emacs being single threaded is the biggest hurdle in that, >>>>> gui lockup is the biggest no no in regular gui apps. >>>> JavaScript is single-threaded. >>>> >>>> They have a certain solution for parallelism in specific workloads, >>>> though (called Web Workers). >>> In Emacs, GC can run Lisp I'm told (finalizers), regexp matching can >>> definitely run Lisp (bug#58042), and the devil knows what else 🙁. I >>> personally have no idea how it would be possible to untangle this for a >>> multi-threaded Lisp. >> >> Each Web Worker (in JS) uses a separate address space, without sharing >> references, exchanging information through "messages" (which are >> copied, not shared). > > Yes, that's what I gathered from reading about web workers on the web. > Do you know what, if anything, makes JS single-threaded? I'm not sure if I understand the question, but to my knowledge, it uses the same kind of "interpreter lock" as is common in other "interpreted" languages too (Ruby, Python, PHP, Lua). That's not the whole story, though, because it's a lock within the "interpreter context", and every open tab has its own. Most tab do not interact in any way, cannot access each other's data, so it's fine to run their JS code in parallel. Likewise, JS on the web doesn't have any access to the browser chrome, meaning they're fine to run in parallel too. In fact, modern browsers run several processes: one for the UI and several for the browser tabs (last info I saw on this, link below, is that Chrome used a process-per-tab, and Firefox combined several tabs in one process using parallel threads). https://medium.com/mozilla-tech/the-search-for-the-goldilocks-browser-and-why-firefox-may-be-just-right-for-you-1f520506aa35 This is already more parallelism than we have (each piece of our code can access everything), but OTOH they have more spinning plates at the same time. >> So this would be like parallel Lisp interpreters with separate >> obarrays, memory spaces, etc. > > Which means someone has to "modularize" the current C code, so that, for > example, more than one GC module, Interpreter module, etc. could exist. > > Not easy, but in my eyes, it would definitely be an improvement. Is > there someone already working in this direction? > > (Not that anyone gets thei mpression I'd work on this... Just saying > :-). The best I can point to are comments on Reddit around when emacs-ng launched: https://www.reddit.com/r/emacs/comments/kmh9k1/comment/ghm68j2/ It included the ability to run code in Deno's Web Workers. It feels like something that would help with some existing problems (e.g. parting JSON in a worker, extracting a subpath from it and sending the result to the parent process), but I don't remember reading any serious code done with it. Possibly just because all big packages have to keep compatibility with the GNU version anyway, so I'm hopeful about such prospects if we ever even get a prototype in GNU Emacs. At the very least, it can be like a faster async.el, with all of its existing use cases.