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#66117: 30.0.50; `find-buffer-visiting' is slow when opening large number of buffers Date: Tue, 12 Dec 2023 20:36:48 +0200 Message-ID: <83a5qftghr.fsf@gnu.org> References: <878r919qfh.fsf@localhost> <87pm2584oz.fsf@localhost> <83cyy11ln1.fsf@gnu.org> <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> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2456"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dmitry@gutov.dev, 66117@debbugs.gnu.org, monnier@iro.umontreal.ca To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 12 19:38:08 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 1rD7dw-0000O0-9s for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Dec 2023 19:38:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rD7dc-0000yP-RR; Tue, 12 Dec 2023 13:37:48 -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 1rD7db-0000x2-3a for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2023 13:37: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 1rD7da-0000vT-Ro for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2023 13:37:46 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rD7dq-0004wA-AL for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2023 13:38:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Dec 2023 18:38:02 +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.170240624018925 (code B ref 66117); Tue, 12 Dec 2023 18:38:02 +0000 Original-Received: (at 66117) by debbugs.gnu.org; 12 Dec 2023 18:37:20 +0000 Original-Received: from localhost ([127.0.0.1]:57537 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rD7dA-0004vA-C4 for submit@debbugs.gnu.org; Tue, 12 Dec 2023 13:37:20 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36518) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rD7d7-0004uv-V9 for 66117@debbugs.gnu.org; Tue, 12 Dec 2023 13:37:19 -0500 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 1rD7cm-0000YO-Bw; Tue, 12 Dec 2023 13:36:56 -0500 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=0zl0GWuXM2igWkBoPQPJx1zhmkBStDsWX6QnuBe+7fg=; b=jACCneC0ZE5z 5YJ93z4W0aZrTt3/whVxxcmhufsW8DoRDrfYMt6WIAUJiDBEKctHIphZ82EercvWQJt14yP/gyT6/ 33lYXA+QO4FLUUtw5nE8y0RvL5qr3a5rV3r8OMqeKbtsq2vjZRMV96WSt16SIp8ONXySs2kvHwLm0 LWt3v/oYYPhAusVqAmJqdy5Cvx1NlXoNslgHLMd4A5kISZf9yc9jRGysoUIDKI1d50001h4YT9G1P oQ7SS8wHxWWE5zdJtewwYSXY6cwTs1TM5kuT8I3yLfbZquF9qmJD8JZnTKzs2oCPTQr1NxWOVPw5T epG3io5bomDy9uza9CfERw==; In-Reply-To: <87msufxqmo.fsf@localhost> (message from Ihor Radchenko on Tue, 12 Dec 2023 17:44:15 +0000) 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:276069 Archived-At: > From: Ihor Radchenko > Cc: monnier@iro.umontreal.ca, dmitry@gutov.dev, 66117@debbugs.gnu.org > Date: Tue, 12 Dec 2023 17:44:15 +0000 > > Eli Zaretskii writes: > > >> #define BVAR(buf, field) (buffer_overrides->field ## _ == UNSET ?\ > >> (buf)->field ## _ :\ > >> buffer_overrides->field ## _) > >> > >> and replace the loop with simply setting buffer_overrides slot. > > > > 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. > > ... 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? > 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.