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 19:26:13 +0200 Message-ID: <83fs07tjre.fsf@gnu.org> References: <878r919qfh.fsf@localhost> <83zg1d468w.fsf@gnu.org> <87bkdr2651.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> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35561"; 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 18:27:16 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 1rD6XL-00094b-Cp for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Dec 2023 18:27:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rD6Wv-0008U2-BB; Tue, 12 Dec 2023 12:26:49 -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 1rD6Wt-0008T0-8p for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2023 12:26: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 1rD6Wt-0006tl-10 for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2023 12:26:47 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rD6X8-0008Uw-7P for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2023 12:27: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 17:27: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.170240201532652 (code B ref 66117); Tue, 12 Dec 2023 17:27:02 +0000 Original-Received: (at 66117) by debbugs.gnu.org; 12 Dec 2023 17:26:55 +0000 Original-Received: from localhost ([127.0.0.1]:57432 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rD6X0-0008Ua-Dp for submit@debbugs.gnu.org; Tue, 12 Dec 2023 12:26:54 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35438) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rD6Wq-0008UC-Fp for 66117@debbugs.gnu.org; Tue, 12 Dec 2023 12:26:52 -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 1rD6WU-0006M1-B8; Tue, 12 Dec 2023 12:26:22 -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=fQma0UqCt+N7jcxKyT1wLzbPlNrR7k1bZXad9u1qHAE=; b=IH8UtZBGVaYL xkBn2T+cq4oaf5r+JYaf7B0gIm1lQ2LiQ5/1ypblJc6I7wqYrizOo2y9dZiMQtMwigGIbSi/8DH1E lXtShiPc5MMwOfWYEw5tf4v76llejx4TPGkEKcZALeeqzo3147QU6WM/h81nLhROPjCm3qWrMWoiw HKNjCbOoSlICwVp0xcnoJaa81X6Ditbay1yFK4D1vhVzes79/k/6vHCfvw9Ow4EK8+/YAidff1ML0 kkRsu5BOxDsGHKwNCdH0/TigEU0J6XZPzRPR2s1UyAG0dx1eDtle+5gbc7gEMHtsRTNccxWqkETkl 8moEC94dw1gYk5RSH5AYPg==; In-Reply-To: <87plzbxtxa.fsf@localhost> (message from Ihor Radchenko on Tue, 12 Dec 2023 16:33:05 +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:276065 Archived-At: > From: Ihor Radchenko > Cc: Stefan Monnier , dmitry@gutov.dev, > 66117@debbugs.gnu.org > Date: Tue, 12 Dec 2023 16:33:05 +0000 > > - Then, `set_default_internal', for any variable with positive > buffer_local_flags loops over all the live buffers to overwrite the > buffer-local value. > > This loop is the bottleneck, making let-binding > of `case-fold-search' (and any other variable marked in buffer.c:4691 > block) scale with the number of open buffers. > > - What I propose is to avoid this loop in `do_specbind' altogether. > Instead of having to loop through all the buffers to set temporary > buffer-local value, I propose to introduce special buffer object > `buffer_overrides' that will hold such temporary bindings. > Then, we can change BVAR to something like > > #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). 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?