From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#66117: 30.0.50; `find-buffer-visiting' is slow when opening large number of buffers Date: Wed, 4 Oct 2023 14:46:23 +0300 Message-ID: References: <878r919qfh.fsf@localhost> <72c93fb0-bf3e-3dad-69c0-2147cfa40f57@gutov.dev> <8734yqodqr.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1301"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: 66117@debbugs.gnu.org To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 04 13:47:03 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 1qo0LG-000AZc-7R for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 04 Oct 2023 13:47:03 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qo0L3-0003l3-AI; Wed, 04 Oct 2023 07:46:49 -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 1qo0Ky-0003k1-WE for bug-gnu-emacs@gnu.org; Wed, 04 Oct 2023 07:46:45 -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 1qo0Ky-0003PH-Ms for bug-gnu-emacs@gnu.org; Wed, 04 Oct 2023 07:46:44 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qo0LG-0003Mg-Cu for bug-gnu-emacs@gnu.org; Wed, 04 Oct 2023 07:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Oct 2023 11:47: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.169642001112917 (code B ref 66117); Wed, 04 Oct 2023 11:47:02 +0000 Original-Received: (at 66117) by debbugs.gnu.org; 4 Oct 2023 11:46:51 +0000 Original-Received: from localhost ([127.0.0.1]:41733 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qo0L5-0003MG-5x for submit@debbugs.gnu.org; Wed, 04 Oct 2023 07:46:51 -0400 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:42133) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qo0L2-0003Lz-U1 for 66117@debbugs.gnu.org; Wed, 04 Oct 2023 07:46:49 -0400 Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id CAAD85C042A; Wed, 4 Oct 2023 07:46:25 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 04 Oct 2023 07:46:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1696419985; x=1696506385; bh=P3YKGs4DueVoWq8pykNKR4dc9ZoInZYaSnK aEsLh5Mo=; b=mEp4dWKF5XVZSrcA66kWOara5Hny+s0QL/xaBC5eYUughsJKCH0 Q4lYfPwD59BOsxubeLMtBbQoXIvhTa8LLY/lzVJEbnlA4zkUoJDcK4/sNsHrrWbS 0D8GLS1xaVmREdBt99K8c6SStr+yRvu1m6CFVn3wTr7MWXz/s2hGYWjjGtwY42d9 1sBlViYIHvNkK79WHWpoxfeEZUWRLlXQJbKcMHRch9SJULBJ2zMxlln+oN2fMBiW Emawx61/1m35g2ZEejIm+Lho3gdDP7HhRoBSE5fy+ZK5XtpxYEc2s+ULr617Vobs UITzeVSEC7f+gzlwI3R48KYAs19nToL6kew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1696419985; x=1696506385; bh=P3YKGs4DueVoWq8pykNKR4dc9ZoInZYaSnK aEsLh5Mo=; b=FMOIYNyeexlfArHbHKbcRarNJsXvYWUaT3hTWeU4zdI7IrlhZ3A WkQLq3m/JA9xvKpL3isboZos2Hrf6YZ2VhO6SogqDoqtdmBQeOwu0m43k+0rEMLB Lu3+Xodu5tGIYzKRNGWqxvtprrTweNQlyWVx9n98S6veYwJQu+dtHe+/JmK9sKr0 LgqNlgC6fy4X1+XzjZHYlvqmwpB6LyIKj3wYobAkcMFxuvWuhEQu6aUFr7L+5AaL PCzouFoMCdTS58VDJA3qVYuqoujYrEDn2Ulc9kAQRVgj6W2wMQtaVCmoLQUXQFLK ssqRdflsQeLI7uGB8KJ9Gcf4EtcG3UcxoCA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrgedvgdegvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtje ertddtfeejnecuhfhrohhmpeffmhhithhrhicuifhuthhovhcuoegumhhithhrhiesghhu thhovhdruggvvheqnecuggftrfgrthhtvghrnhepiefgteevheevveffheeltdeukeeiie ekueefgedugfefgefhudelgfefveelvdevnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomhepughmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 4 Oct 2023 07:46:24 -0400 (EDT) Content-Language: en-US In-Reply-To: <8734yqodqr.fsf@localhost> 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:271793 Archived-At: On 04/10/2023 13:58, Ihor Radchenko wrote: > Dmitry Gutov writes: > >>> Would it be possible to implement some kind of caching mechanism to be >>> used by `find-buffer-visiting'? >> I'm guessing you Cc'd me because of an existing comment inside xref.el? >> As you can see I decided not to use this function there, but even >> get-file-buffer wasn't as fast as I would've wanted, so there's a >> quick-and-dirty caching solution for sequential lookups (which assumes >> that the same file would be looked up multiple times in a row). > It looks like my example is quite different from yours. > Do you have a reproducer demonstrating `get-file-buffer' being slow? I retested, and it seems most people here won't be impressed by my example. Anyway: 1. Call (benchmark-run 1 (project-find-regexp "emacs") in an Emacs repo checkout. 2. Change xref--collect-matches to call get-file-buffer instead of xref--find-file-buffer (which does some caching). 'M-x byte-compile-file', (load "xref.elc"), and run the benchmark again. What I get here, is 3.60s vs 5.03. It's a 1.40s difference over ~95000 calls, though (this is how many matches are produced). Which is meaningful for my case, but probably not for yours.