From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#66117: 30.0.50; `find-buffer-visiting' is slow when opening large number of buffers Date: Tue, 12 Dec 2023 19:18:19 +0000 Message-ID: <87jzpjxm9w.fsf@localhost> References: <878r919qfh.fsf@localhost> <87lecp84mf.fsf@localhost> <83ttrdx8j9.fsf@gnu.org> <87a5su261p.fsf@localhost> <838r8e24yy.fsf@gnu.org> <87y1gezspg.fsf@localhost> <834jj21z05.fsf@gnu.org> <87il7izo4l.fsf@localhost> <831qe61xrh.fsf@gnu.org> <87cyxqzmhh.fsf@localhost> <83zg0uzlgw.fsf@gnu.org> <87v8bhxzcu.fsf@localhost> <83y1gdxws8.fsf@gnu.org> <87jzrwm7ul.fsf@localhost> <87h6n0m781.fsf@localhost> <87v8935wik.fsf@localhost> <83msuftr0i.fsf@gnu.org> <87plzbxtxa.fsf@localhost> <83fs07tjre.fsf@gnu.org> <87msufxqmo.fsf@localhost> <83a5qftghr.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37858"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dmitry@gutov.dev, 66117@debbugs.gnu.org, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 12 20:16:05 2023 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 1rD8Ee-0009an-MR for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Dec 2023 20:16:04 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rD8ER-0005rg-Re; Tue, 12 Dec 2023 14:15:51 -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 1rD8EN-0005rQ-6B for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2023 14:15:47 -0500 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 1rD8EM-0007Wt-OX for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2023 14:15:46 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rD8Eb-0005ym-Uu for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2023 14:16:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Dec 2023 19:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66117 X-GNU-PR-Package: emacs Original-Received: via spool by 66117-submit@debbugs.gnu.org id=B66117.170240853922951 (code B ref 66117); Tue, 12 Dec 2023 19:16:01 +0000 Original-Received: (at 66117) by debbugs.gnu.org; 12 Dec 2023 19:15:39 +0000 Original-Received: from localhost ([127.0.0.1]:57572 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rD8EF-0005y7-Du for submit@debbugs.gnu.org; Tue, 12 Dec 2023 14:15:39 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:58621) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rD8EE-0005xu-01 for 66117@debbugs.gnu.org; Tue, 12 Dec 2023 14:15:38 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id CDFA3240027 for <66117@debbugs.gnu.org>; Tue, 12 Dec 2023 20:15:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1702408516; bh=ptUlJRv4WKefStLuu74gtrywgPK1Ya9Y9/kAMNG4Ic0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=BNV43MkzAK6YGTxpzYXUu3tSnliwGV+iXnmeH9d9UbzXx7ZOX0orWYXYYONAOMUs+ EPY2sfvwEXmhjSoJzPSSPxeQ0zDHB7X7kBxTcWmYhm9Km8pBEv4NN3M/5Y4mSGbSfh aXKh1Ql2vMGgpnw9ZKZVu1EhbieRQXlHC836H9po1J1HKsl7GvsTAIP1KADUCziHAT OI3SV+J24ysdECeU7/zDiecgpA/q6BC2U3oRA+Gl/4Lw4RhTyOIH+2G8JxfAK0uGxC zSsNuDkqCIpAfVUxvYqVJFUPRfP41GY+4buWUzQvMme05fodZr/FbMYTDhYt3X0Dm4 5Yxc3b0Lpr8lA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SqSxH6KXQz9rxL; Tue, 12 Dec 2023 20:15:15 +0100 (CET) In-Reply-To: <83a5qftghr.fsf@gnu.org> 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:276072 Archived-At: Eli Zaretskii writes: >> > So for starters, we make each BVAR more expensive, i.e. make Emacs >> > uniformly slower (because we call BVAR all over the place). >> >> Yes, although I do not believe that it will have large impact in >> practice. It is just an extra == comparison. > > We've seen how similar extra comparisons slow down Emacs when we > introduced symbols-with-location. IMO, BVAR might be even more > expensive, since it is used much more frequently and widely. It might. Do you know a good way to test such thing? Because I do not think that a mere suspicion that this change might make things slower should stop the discussion. >> > ... And then >> > I'm not sure I understand how buffer_overrides will get the values of >> > those temporary bindings without having to use the same loops when we >> > have let-binding within another one. Also, what about threads? >> >> Just as any other global state variable - via `specbind'. Entering inner >> let will push the previous value into specpdl and recover it upon >> exiting. > > And that will not require looping similar to what we have now? No. AFAIK, the way let-binding for dynamic scoping works is: 1. push existing variable value to specpdl 2. assign a new value 3. when leaving let scope, pop the record from specpdl and assign the old value What I propose is changing the way value is assigned. Now, the assignment of buffer-local variable that is recorded into buffer object slot involves doing it in all the live buffers. I propose to do it in a special buffer object instead, which is strictly faster. >> Threads work similarly, maintaining their own local specpdl queue heads >> that make sure that global state is recorded and rewinded as needed. > > I don't think I follow you here. See `rebind_for_thread_switch' and `unbind_for_thread_switch'. The workhorse is `specpdl_unrewind', which see. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at