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: Wed, 13 Dec 2023 15:25:41 +0200 Message-ID: <83jzpis08a.fsf@gnu.org> References: <878r919qfh.fsf@localhost> <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> <87y1dzvvf0.fsf@localhost> <83plzas3pg.fsf@gnu.org> <87r0jqw8u9.fsf@localhost> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9387"; 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 Wed Dec 13 14:27:17 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 1rDPGe-0002F7-WC for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Dec 2023 14:27:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rDPGE-0005Vz-E6; Wed, 13 Dec 2023 08:26:50 -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 1rDPGB-0005VW-Nk for bug-gnu-emacs@gnu.org; Wed, 13 Dec 2023 08: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 1rDPGB-00071A-Bw for bug-gnu-emacs@gnu.org; Wed, 13 Dec 2023 08:26:47 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rDPGQ-00061Q-JC for bug-gnu-emacs@gnu.org; Wed, 13 Dec 2023 08: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: Wed, 13 Dec 2023 13: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.170247397523091 (code B ref 66117); Wed, 13 Dec 2023 13:27:02 +0000 Original-Received: (at 66117) by debbugs.gnu.org; 13 Dec 2023 13:26:15 +0000 Original-Received: from localhost ([127.0.0.1]:58408 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rDPFe-00060M-TF for submit@debbugs.gnu.org; Wed, 13 Dec 2023 08:26:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35682) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rDPFb-000608-Im for 66117@debbugs.gnu.org; Wed, 13 Dec 2023 08:26:13 -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 1rDPFF-0006qR-Sk; Wed, 13 Dec 2023 08:25:49 -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=fgKE2oznL4QHkWiZSzlO/npo/v19VLBHsO3g8w+fjDk=; b=X2xBFtsDOs9C N75zKW/I/I9EO5uGSp3BGiFK7elYHoy33IEmHTzNnSxXgfNH2eO8POIopLJm0uuwBMetz49P1AsFh 3zDQ+2q/BCMCGCIUdwTwAgPiuB/8CHZ0VD887jFBoP1Df1rjlJy5Ibv5KHEX3OKKFZqEJZzBy2oJ3 +SpvBW+nsp3fCrzHE1Dkyoz7i5OZPoGxqPX5D3NfsFkhMFY2y55rjbHYnTRB8p4MXWHv8e20IZVTq RAmztNBNhi7/+H0f9FiqMma6P+by99U3JJ7aTlh3yTawWAx8CCXCbu4nDb0ebFfT2LZ/JzDn6c0Vw P4MmkAsghfIQLLx2JktOtQ==; In-Reply-To: <87r0jqw8u9.fsf@localhost> (message from Ihor Radchenko on Wed, 13 Dec 2023 13:06:06 +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:276126 Archived-At: > From: Ihor Radchenko > Cc: Stefan Monnier , dmitry@gutov.dev, > 66117@debbugs.gnu.org > Date: Wed, 13 Dec 2023 13:06:06 +0000 > > Eli Zaretskii writes: > > > Btw, the title of this bug is about find-buffer-visiting, and AFAIR I > > proposed to have a primitive written in C that replaces > > find-buffer-visiting without a need to actually switch to each buffer > > (which is what triggers the costly rebinding of buffer-local variables > > like case-fold-search). So why we are talking about case-fold-search > > instead of solving the original problem? If we want to discuss the > > case-fold-search issue, IMO we should discuss it in a separate bug > > report. > > The bottlenecks now (after applying my patch for `find-buffer-visiting') > are `abbreviate-file-name' and `inhibit-local-variables-p'; not the > `find-buffer-visiting' per se (both are slow because they let-bind > case-fold-search). Then let's see about implementing in C of these two, or their subsets needed by find-buffer-visiting, because case-insensitive operations in C don't need to bind case-fold-search. Another possibility is to rewrite the parts of these two functions that need case-insensitive matching in a way that doesn't need to bind case-fold-search. For example, case-insensitive match against "abcd" using string-match can be replaced by a case-sensitive match against "[aA][bB][cC][dD]" or by a call to compare-strings. > AFAIU, it is very hard to rewrite them in C, as I explained in > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=66117#157 The only explanation I see there is that they "recursively call other Elisp functions". Is there any other reason? My point is that by trying to speed-up let-binding of case-fold-search and similar variables you are trying to solve a much more general problem, and a much harder one at that. IME, if an idea for a solution leads to a more general and harder-to-solve problem than the original, then the idea should be dropped, and one should look for alternative ideas.