From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#72689: 31.0.50; Proposal to improve string-pixel-width Date: Wed, 21 Aug 2024 16:17:12 +0300 Message-ID: <86jzgauiav.fsf@gnu.org> References: <54d1d667-55d0-41fc-9eec-38b3881d799b@orange.fr> <86bk1q1m0l.fsf@gnu.org> <8634n219b1.fsf@gnu.org> <35119d55-c582-4f4b-b80d-d94fc6b8886c@orange.fr> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40603"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72689@debbugs.gnu.org To: David Ponce Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 21 15:18:40 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1sglEW-000AQD-5c for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 21 Aug 2024 15:18:40 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sglEF-0007Su-DW; Wed, 21 Aug 2024 09:18:23 -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 1sglEC-0007HB-3p for bug-gnu-emacs@gnu.org; Wed, 21 Aug 2024 09:18:20 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sglEA-0000WX-AR for bug-gnu-emacs@gnu.org; Wed, 21 Aug 2024 09:18:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=T6PXNMJ3lhHqt44Qo1jUrxX2CFWLR6xTw2vvRg7+wIg=; b=gNY1Ciy9FTVN7eqGlE3WqJq8C4a6W+MmhLkrz/s++HpMHWM+yZaAGgqiYPwJBjIpgh/RfdsMxvZgn2TNE9R5SIUkNwxNibwNXal3OPV302Ue6csd5oNbR9wc/0s9cuIn5kXiG2gzMYaISyyL5rGwsYtcWp0I9C2/LGQiJNUdSMWX0ky8EzIjoTSja/67JEKMUqKgo4etyXoeHsXFKc+EQppdcF2kheujj+IZtOAhMbQdscMHqkyEYmt2i4Wq73wdGGwl/YnredgKAg/7AXTETaFDtXO6pJQ6HL138ARV2OhAR9z/mUnfeUAzFehgdBzN11dBhpG0Y+NcwRzop0hLYg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sglEs-0002Rj-FP for bug-gnu-emacs@gnu.org; Wed, 21 Aug 2024 09:19:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Aug 2024 13:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72689 X-GNU-PR-Package: emacs Original-Received: via spool by 72689-submit@debbugs.gnu.org id=B72689.17242462899328 (code B ref 72689); Wed, 21 Aug 2024 13:19:02 +0000 Original-Received: (at 72689) by debbugs.gnu.org; 21 Aug 2024 13:18:09 +0000 Original-Received: from localhost ([127.0.0.1]:35168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sglE0-0002QN-KM for submit@debbugs.gnu.org; Wed, 21 Aug 2024 09:18:09 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:48782) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sglDy-0002Pn-2l for 72689@debbugs.gnu.org; Wed, 21 Aug 2024 09:18:07 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sglD9-0000O3-QH; Wed, 21 Aug 2024 09:17:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=T6PXNMJ3lhHqt44Qo1jUrxX2CFWLR6xTw2vvRg7+wIg=; b=h6fr9XgqRQqV nAHSyDVlzCKa5qsPhHhThdFu8K9y1co41+gzSkVVKpcTIeb+KQmicYWIS3zYPdT/0cKfXnB1r0mt0 VUojossqi1yLKb1If9gwTHplwLoPAl5p2c8g3l9L5FCznDXBxUBS5Vv5vDIy6vU0stzjvYUH9PzBx PUwvBuWf1qJ2eImWJC0TXM/U/Rz0P6PSsScZBd0E6xffHZXPITpsV7EHZE0OrmanJKzRKsKPZ13cZ 7bcC8rhs7e8ZSAYDl1RuKJLk1aAGDCJCSW2BB2PokG+Ry8nygXg2oLDco4vyd8/P0PRgG6zgJCVsL Wyd5RATyBRyGkfsilVJyGQ==; In-Reply-To: <35119d55-c582-4f4b-b80d-d94fc6b8886c@orange.fr> (message from David Ponce on Tue, 20 Aug 2024 17:12:45 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:290486 Archived-At: > Date: Tue, 20 Aug 2024 17:12:45 +0200 > Cc: 72689@debbugs.gnu.org > From: David Ponce > > On 18/08/2024 11:15 AM, Eli Zaretskii wrote: > [...] > >>> Thanks. The idea SGTM, but I think the implementation needs to cater > >>> for the case where more than one execution thread performs this job > >>> "in parallel" (however improbable this could sound), so we need to be > >>> able to detect when this buffer is "busy". The simplest way is to use > >>> some boolean buffer-local variable, which will be set non-nil when the > >>> function starts using the buffer and reset to nil when the function is > >>> done with its job. > > I've been thinking more about the parallelism issue when a function > reuses a temporary buffer for its activity, and I wonder if we could > use a simple API like the one below to safely get an exclusive working > buffer without having to create a new one on each call? Thanks, but using a mutex is overkill: there could be no race between two or more threads in this case in accessing the buffer-local variable, because only one Lisp thread can be running at any given time. So the simpler method of testing the "busy" flag should be sufficient. > Compared to my previous proposal the quick benchmark above shows > similar results for both performance and memory usage, but the new > implementation is simpler, and the API might be useful in other > similar cases. Simpler implementation is OK, but I think it will be simpler yet if you remove the mutex, which is not needed.