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: Releasing the thread global_lock from the module API Date: Sat, 2 Mar 2024 01:53:05 +0200 Message-ID: <470c6bea-805d-42dd-8bbd-936ea93c6579@gutov.dev> References: <86cysdrja3.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="30736"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: emacs-devel@gnu.org To: tomas@tuxteam.de, Spencer Baugh Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Mar 02 00:54:26 2024 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 1rgChr-0007lb-Te for ged-emacs-devel@m.gmane-mx.org; Sat, 02 Mar 2024 00:54:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rgCh6-0004Ca-Jk; Fri, 01 Mar 2024 18:53:36 -0500 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 1rgCgg-0004Au-Du for emacs-devel@gnu.org; Fri, 01 Mar 2024 18:53:10 -0500 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rgCge-0002WC-FI for emacs-devel@gnu.org; Fri, 01 Mar 2024 18:53:10 -0500 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 8F3975C0095; Fri, 1 Mar 2024 18:53:07 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 01 Mar 2024 18:53:07 -0500 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:subject:subject:to:to; s=fm3; t=1709337187; x=1709423587; bh=D+LqTVcMmvubch/Rovqqln4CZjEh9gGGagv6SMYsh0E=; b= W7Irei1sZGwMqELcX6wC8MzTnxtJ2h7of5xhYMTubNlheBYzxnxPmIZWK1LNe9FA Uxt2Y+4nmCRqPmmMpJJ9o0KNq8t2RyVtS9A0OSEIYslaBIPg+Pb5g8XoaU2aZZ4i t+mvoO8g5as8Pt7NuY9Tz0p3Tzx9P6AmCZTdAz3amYbo8OacoqSe+sZE1QrA+sJO cu9HAn8RyoZwGtrRcAaA0lPGbz/LQBzYsW7OldodDHwfwaHrRBimhnDRzXgkE1Cx VcmXuEkLJfifR7Dw1qZVyryZXNtk7UEvgSqlNN1iuvW9Old/y8ixhnwKXpiQhGVq 52frk5QCWLcn9OpIDYSqSQ== 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:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1709337187; x= 1709423587; bh=D+LqTVcMmvubch/Rovqqln4CZjEh9gGGagv6SMYsh0E=; b=r UKD/0HdL06LWP5isvagn5onJWylzsoZmhEp9ibj++LvkmPBtMoutIoudjfTFTfEf PV6DZxOWP3qVWeTOvv3qQU/84ZS4KegG4sy86ZnWXKQ+xjpT0EyROMHcIMyf9/rJ qe9wVhcafk9BDoHFQyZEwkfJ6+VKwYQ6kielem8k4RwU6fX0pDWNZVzFZj4vIcxe VAtItT85ilwN4PhST7KjR8I9BjxxaDWXlkQ3ouSZxYyqEbTPEqApPlATAifUvX2T MqFX4wWhv4vcL+DN6YZpYKdWs18uj6cn4F3qWuOp0HDrm4kky11mqYIPBd2YhNjF uRdS2Y8lMvaB5G13aH1uQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrhedvgddugecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthejredttddvjeenucfhrhhomhepffhmihht rhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrghtth gvrhhnpeetudeljeegheetgfehgeejkeeuhedvveeikeeufedtvddtveefhfdvveegudej heenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegumh hithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 1 Mar 2024 18:53:06 -0500 (EST) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=66.111.4.25; envelope-from=dmitry@gutov.dev; helo=out1-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, 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:316687 Archived-At: On 01/03/2024 21:30, tomas@tuxteam.de wrote: >> - Unrelated Lisp thread B is able to take the global lock and run Lisp code >> in parallel with module_work on thread A. >> - On thread A, module_work finishes and returns to Lisp. > Why has thread A wait up to here? This is what's keeping your thread B > from playing, no? I imagine thread A will want to continue its execution when the results of the "Emacs-independent work" arrive. Said work might look like making a network request (as Spencer outlined), getting a response, parsing the received JSON structure (not into Lisp objects yet, just into the native data structures provided by the library), and potentially filtering the parsed structure as well. Then the lock is re-acquired (which will naturally involve some spinning waiting for it), and the parsed data is converted into Lisp structures.