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: Concurrency via isolated process/thread Date: Mon, 10 Jul 2023 17:53:20 +0300 Message-ID: References: <871qhnr4ty.fsf@localhost> <87h6qhnalc.fsf@yahoo.com> <87ilax71wo.fsf@localhost> <831qhli14t.fsf@gnu.org> <87wmzdxewc.fsf@localhost> <83r0plgjeo.fsf@gnu.org> <87o7kpxapo.fsf@localhost> <83mt09gcaf.fsf@gnu.org> <87wmzbc3af.fsf@localhost> <87edljhmjq.fsf@yahoo.com> <87fs5zbuwn.fsf@localhost> <871qhjgrku.fsf@yahoo.com> <831qhieumz.fsf@gnu.org> <87lefqg7yl.fsf@yahoo.com> <83h6qed8kw.fsf@gnu.org> <87h6qefwj0.fsf@yahoo.com> <83bkgmcx0q.fsf@gnu.org> <87a5w5gbs4.fsf@yahoo.com> <83bkglbmai.fsf@gnu.org> <87o7kleeub.fsf@yahoo.com> <835y6tbkr2.fsf@gnu.org> <87v8et8qkk.fsf@localhost> <834jmdbhns.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14249"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cc: luangruo@yahoo.com, emacs-devel@gnu.org To: Eli Zaretskii , Ihor Radchenko Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jul 10 16:54:24 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 1qIsHO-0003PH-OF for ged-emacs-devel@m.gmane-mx.org; Mon, 10 Jul 2023 16:54:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIsGc-0006Yw-5A; Mon, 10 Jul 2023 10:53:36 -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 1qIsGX-0006YU-F1 for emacs-devel@gnu.org; Mon, 10 Jul 2023 10:53:30 -0400 Original-Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIsGV-0005Ed-61; Mon, 10 Jul 2023 10:53:28 -0400 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 801E35C0158; Mon, 10 Jul 2023 10:53:23 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 10 Jul 2023 10:53:23 -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=fm1; t= 1689000803; x=1689087203; bh=x4uiswtQmzf/L4IUa4qu2CkcDW1A6UPLS70 vRBk0W/g=; b=fCsyLMBjutYK1NIL80oVjs54l9EEwYM0AILbM5e7mXXgyh9LcAc PY3moxpu5kqPjJCnI+G8M5u2A8g44Io3mq2wq3sZ3BKaDtmJ0o4jSqvvINulaqmV 0MAMaHNc5DIlKwQVEC/kSYhPZ4UGO+pZd5v4Q4zMhdQruoC9LFdlI0Irxp6IKANN HF08LQf4Jvhfvo9UkqYIgIxifJ61P5VrFnt+Ifu1zpZMj/0wM4R6HgLJykNhVlNj lg9gKdgjvVmAEOnoeiw5Fej+29TG08qEXIT/6lHC+yDuk+yq415oZFAkGsQlKOrw 8gNF+xus5oyx6P9YJMKJLZApwdJhjMTyI3w== 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= 1689000803; x=1689087203; bh=x4uiswtQmzf/L4IUa4qu2CkcDW1A6UPLS70 vRBk0W/g=; b=NOxlMsVSZB0LfC4HYrGHIXGeLRiZWyfNjK+ChZLpqGrgpbFriEm D6XAfCSXTXnzNvIFoXbCiaNYLdGkZaALoKkzOG1ZVR6Jy05hzA154+IEmhhLyqBR r7Yo04AzQygW7tYpQnJ5M8jXsHWFdEKb24G9//AM8WIgY/CiMBFnT+7t4cyNFPaF tWRDaPgyW0tkMbz1KeFU5abWv2LrmEBzazmXqX4AbC4jBPuUtXpaIH50iVQFNRc6 f6TX2hqqJphAHoBsM8G3ZqKrSIBIlLeOGyxj3TGPQneWV2PBAE3W77P43aYuJXMI +6J3es1vdLVKkncv7VPBePocVs6CmmCzhuA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrvdekgdejvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthejredttdefjeenucfhrhhomhepffhmihht rhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrghtth gvrhhnpeeigfetveehveevffehledtueekieeikeeufeegudfgfeeghfdulefgfeevledv veenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegumh hithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 10 Jul 2023 10:53:22 -0400 (EDT) Content-Language: en-US In-Reply-To: <834jmdbhns.fsf@gnu.org> Received-SPF: pass client-ip=66.111.4.26; envelope-from=dmitry@gutov.dev; helo=out2-smtp.messagingengine.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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=-0.101, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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:307725 Archived-At: On 09/07/2023 11:41, Eli Zaretskii wrote: >> From: Ihor Radchenko >> Cc: Po Lu,emacs-devel@gnu.org >> Date: Sun, 09 Jul 2023 07:57:47 +0000 >> >> Eli Zaretskii writes: >> >>>> When programmers write such code for other interactive programs, they >>>> are comfortable with the limitations of running code outside of the UI >>>> thread. Why should writing new, thread-safe Lisp for Emacs be any more >>>> difficult? >>> Because we'd need to throw away 40 years of Lisp programming, and >>> rewrite almost every bit of what was written since then. It's a huge >>> setback for writing Emacs applications. >> May you please elaborate why exactly do we need to rewrite everything? > We already did, please read the previous messages. In a nutshell: > because most of the Lisp code we have cannot be run from an async > thread. IME most of the code we have works decently already, and what we've been missing is a way to speed up certain crunchy bits without spawning an additional Emacs process (with all the coding pain and overhead that that entails). Workloads, for example, like creating a buffer (pinned to the thread), calling a process (asynchronously or not), getting JSON from it, parsing said JSON, processing the result, and returning it in some shape to the parent (probably main) thread. Most of the work that Gnus does, I think, also fits in that rough category. Reporting on progress can be done by sending messages to the main thread, either via a dedicated mechanism ("messages" like in JavaScript Workers), or by changing some global variable as decided by the code author. The variable access would have to be synchronized, of course. The worker thread will need an efficient way to return the computation result too (which still might be large, memory-wise), though. Maybe it'll use the same communication mechanism as progress report, maybe not. But it's something to keep in mind.