From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#34343: [PATCH] Make project--find-regexp-in-files work with remote files Date: Thu, 02 Jan 2020 11:48:49 +0100 Message-ID: <87mub6uoa6.fsf@gmx.de> References: <9d65284f-7a64-5e9c-ab02-fbbd1be41689@yandex.ru> <87r2bt1tio.fsf@gmx.de> <2cfd53b2-8202-a321-a853-da0c949b0f15@yandex.ru> <6cf8bfa8-3873-d3db-9139-854359027e8a@yandex.ru> <87h81mqiq5.fsf@gmx.de> <0ff03b20-20d8-b6c0-c876-3fd525586180@yandex.ru> <87mubdps6s.fsf@gmx.de> <87blrsz3tf.fsf@gmx.de> <87blrrmht9.fsf@gmx.de> <87tv5fs6kf.fsf@gmx.de> <7a1e2e22-89d4-b8b9-6cd4-e6947436138c@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="178320"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: =?UTF-8?Q?Felici=C3=A1n_?= =?UTF-8?Q?N=C3=A9meth?= , 34343@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 02 11:49:39 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1imy2s-000kEO-UA for geb-bug-gnu-emacs@m.gmane.org; Thu, 02 Jan 2020 11:49:39 +0100 Original-Received: from localhost ([::1]:39554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1imy2p-0000zD-Jx for geb-bug-gnu-emacs@m.gmane.org; Thu, 02 Jan 2020 05:49:36 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39453) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1imy2J-0000yt-DU for bug-gnu-emacs@gnu.org; Thu, 02 Jan 2020 05:49:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1imy2I-0000Pl-69 for bug-gnu-emacs@gnu.org; Thu, 02 Jan 2020 05:49:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60533) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1imy2H-0000Pg-Vh for bug-gnu-emacs@gnu.org; Thu, 02 Jan 2020 05:49:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1imy2H-0007Jk-SZ for bug-gnu-emacs@gnu.org; Thu, 02 Jan 2020 05:49:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Jan 2020 10:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34343 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 34343-submit@debbugs.gnu.org id=B34343.157796214028120 (code B ref 34343); Thu, 02 Jan 2020 10:49:01 +0000 Original-Received: (at 34343) by debbugs.gnu.org; 2 Jan 2020 10:49:00 +0000 Original-Received: from localhost ([127.0.0.1]:38273 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1imy2F-0007JU-Q7 for submit@debbugs.gnu.org; Thu, 02 Jan 2020 05:49:00 -0500 Original-Received: from mout.gmx.net ([212.227.15.15]:43841) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1imy2E-0007JD-2K for 34343@debbugs.gnu.org; Thu, 02 Jan 2020 05:48:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1577962131; bh=dnuP1pg4AeL22S8cMY3xsx7lyKLYQkDcSaMgKNBUKM8=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=Cpxf8jPFRD8ld7/7dBGxRyiPhUJ7FodOj8B9J8sNTP7zZ9WSqzEk1z0UN+T/yMYLl weKahA6O4b8kDTYkmyg2oOVFj7gQq/1IDRdmIi7ZnRtVThlbY1P0LL8slkUbJlM/l0 REIq+2m7Ovt97IaDqesM3BhuuGhQ9RfNxwmzT940= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from detlef.gmx.de ([212.91.242.204]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N1wlv-1jjuQ73gcb-012DA7; Thu, 02 Jan 2020 11:48:51 +0100 In-Reply-To: <7a1e2e22-89d4-b8b9-6cd4-e6947436138c@yandex.ru> (Dmitry Gutov's message of "Thu, 2 Jan 2020 04:22:16 +0300") X-Provags-ID: V03:K1:EOv4O6RHoj8zujI6dlDve9SYWQSPvysm1yNfQX8t7plTPXJ75lV WF9WEN0Z0D17OnTYDefpMLhsh7zAwQfLunvePzloqAMgs6Rpse3DIjYPKE9ftl6VVyZSNd5 f14w8q+OxCx9RqFIpSR8JfxbtXXPMjV4laXBJbnQ5a6+Z0qCuhTQooulPE1ufiSqt93RNn3 4XOumMRh/FfxWBR8ut/YQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:hZdHDUBnbcc=://3gopdlDkZyIkdNvxXNxP x10W2iEqBA0tbrarlWR/c4QADAx8m4G2QqFVzuahlWO/xIs2zAFr7IckrxQtJ/fAbMSpNOMBD o9TeZtRVoL5rgODzASAEAr1/N1+Q8KFtU6uWqmVf/znvLGgFevQxKgWrhJye+WIl+LxGAANhj +7RQl4z6dJhWbFZpryFeIF4m0JtleFbV5ZnIhWJkD5Ytp2QGuz424pf8sKKGlXX7tbwYflyEL lltLjlNdNfrh60+kE3z1c3mBrX9M9N56yfM3RbBHYINu7/0U/zITHPfiKOBcf5LNumDDqQKJi 1voiIOFjxv9qiHBmdGrAJTIIpTqjzvMFIEZOLQUNLEVBR2QkoCOKv5lrL0EItr0JjFfbXKg+/ MV33h0k/aTnDpbRaHwo4U7NlT9gx3uJLdyKuYpzJfbOUURr6H3N97oNYrAlLQ0pEhyfgPCdOL mGYbjT6VokgApv2LIu/UXvgGmQOCL2B3lRuwi9Y3y3jtsoxzgjc5ps6CVhC4dqLZCjPbEtT/3 vPxZ61rWb3sGGc9DZJVkVWKHXwX44EzRE7G4PYRhsi2N6x2k+4ysOOVTiDim1MIdj6yaSCEuY 5V9hCVnpQmumJLlNhgu796ZMRu7sxdcQEoqIkVVOVghJH6qUT+2qjum7rLHu2CleVgb1OSZXU ACfHLg8fH2hpSEZBEJuKXab2WIpYqjMrBFeqqxpDuf1IUVjQJdfRAxIcmgCO+PdaFv2PDKt6X V0743LmDYRQLcEZpQBNv8RG7VXLtpRVHpYzrYXaQt6gGt0On6XAdWPXMkqXk0Nd11mTbohJs X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:174065 Archived-At: Dmitry Gutov writes: > Hi Michael, Hi Dmitry, > > On 01.01.2020 14:29, Michael Albinus wrote: >> I've played a little bit with this. Even if there is no remote file name >> involved, file-local-name is slow due to the file-remote-p call and the >> file name handler mechanery. See: > > This is unfortunate. But there's a bigger problem: file-local-name is > even slower when the file name actually *is* remote. > >> Refactoring the code, and applying `file-local-name' just to the cases >> where it is needed, shows an elapsed time similar to the initial one. > > If you take a look at xref-matches-in-files, you will find that is > exactly what I did. > > But check this out: > > ELISP> (benchmark-run-compiled > nil > (dotimes (i 10000) (file-local-name (format "/tmp/%d" i)))) > > (0.01541569 0 0.0) > > ELISP> (benchmark-run-compiled > nil > (dotimes (_i 10000) (file-local-name (format "/ssh:abc@def.com:/")))) > (3.229403787 28 1.9053286330000034) > > And that is for just 10'000 files, not for 1'000'000. I've started with --8<---------------cut here---------------start------------->8--- (benchmark-run-compiled nil (dotimes (i 10000) (file-local-name (format "/ssh:abc@def.com:/%d" i)))) (4.222947337 31 1.384718521) --8<---------------cut here---------------end--------------->8--- Then I have removed everything from tramp-handle-file-remote-p which isn't necessary for the 'localname case, and I came to --8<---------------cut here---------------start------------->8--- (benchmark-run-compiled nil (dotimes (i 10000) (file-local-name (format "/ssh:abc@def.com:/%d" i)))) (3.876818843 28 1.3257780540000006) --8<---------------cut here---------------end--------------->8--- Better, but not significantly. And tramp-handle-file-remote-p wasn't usable for other cases anymore. So I fear we cannot do much better as it is. > And with longer file names, the process takes even longer (twice as > long in my real-world example). I cannot confirm "twice as long". I've tried --8<---------------cut here---------------start------------->8--- (benchmark-run-compiled nil (dotimes (i 10000) (file-local-name (format "/ssh:abc@def.com:/a/b/c/d/e/f/g/h/i/j/k/l/m%d" i)))) (4.185161814 30 1.425226717000001) --8<---------------cut here---------------end--------------->8--- The difference is likely because tramp-file-name-regexp has been applied to a longer string. If I simplify tramp-file-name-regexp, we get --8<---------------cut here---------------start------------->8--- (setq tramp-file-name-regexp "\\`/[^/:]+:[^/:]*:") "\\`/[^/:]+:[^/:]*:" (benchmark-run-compiled nil (dotimes (i 10000) (file-local-name (format "/ssh:abc@def.com:/a/b/c/d/e/f/g/h/i/j/k/l/m%d" i)))) (3.510464452 30 1.4363330669999996) --8<---------------cut here---------------end--------------->8--- Better, but with the penalty that the other parts of a remote file name aren't detected any longer, and tramp-handle-file-remote-p still works only for the 'localname part. Both not acceptable. So I fear we must live with the status. Yes, file-local-name is slow for remote files, and yes, it doesn't matter for single invocations. Bulk invocation, as you have it, will show an additional performance penalty, even if there is no remote execution of any command. Best regards, Michael.