From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#41423: 27.0.91; eshell file completion in tramp dir is slow (3 minutes) [regression on pretest] Date: Sat, 29 Aug 2020 14:38:45 +0200 Message-ID: <87mu2d7hka.fsf@gmx.de> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33401"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: rrandresf@gmail.com, Tim Vaughan , 41423@debbugs.gnu.org, Stefan Monnier To: Gregory Heytings Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 29 14:40:34 2020 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 1kC09q-0008aP-9H for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 29 Aug 2020 14:40:34 +0200 Original-Received: from localhost ([::1]:52712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kC09o-00086b-0t for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 29 Aug 2020 08:40:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kC09K-00086T-4l for bug-gnu-emacs@gnu.org; Sat, 29 Aug 2020 08:40:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36465) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kC09J-00041m-Qf for bug-gnu-emacs@gnu.org; Sat, 29 Aug 2020 08:40:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kC09J-0004P0-NP for bug-gnu-emacs@gnu.org; Sat, 29 Aug 2020 08:40:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 29 Aug 2020 12:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41423 X-GNU-PR-Package: emacs Original-Received: via spool by 41423-submit@debbugs.gnu.org id=B41423.159870474516849 (code B ref 41423); Sat, 29 Aug 2020 12:40:01 +0000 Original-Received: (at 41423) by debbugs.gnu.org; 29 Aug 2020 12:39:05 +0000 Original-Received: from localhost ([127.0.0.1]:48011 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kC08P-0004Ng-37 for submit@debbugs.gnu.org; Sat, 29 Aug 2020 08:39:05 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:41647) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kC08J-0004N6-Uu for 41423@debbugs.gnu.org; Sat, 29 Aug 2020 08:39:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1598704727; bh=35OnjKQ+4o66ozTQuhxDtrbMl0UyDnphmT9A78wFNHk=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=VazCDg1ja/arGtaIcba56hBhd628vhMGnKwbUfFpwYUIWWwqMUZXdLIHYpl603c4D VC6CK6hB4zgQqj5WU2rxv5pO8ks0EU2OgQBMdvzd8dq8tpfqjRIHHfaqpsmKyW8I+L b9iPTKKe2kSCtLaKZEq1Q9mnD4Fr/GzJ7MyyiXEk= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from gandalf.gmx.de ([212.86.51.69]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MtfNl-1kSHhA0W9X-00vC5r; Sat, 29 Aug 2020 14:38:47 +0200 In-Reply-To: (Gregory Heytings's message of "Fri, 28 Aug 2020 23:15:12 +0000") X-Provags-ID: V03:K1:Sg19DI6xoAjNCpklD2knphGiTPUtuFPlT56/uMpIoVcKtsr4kyz ZI15HWn71DN4+0bidzqembtdO//JLeliP4/+57okbixvoOOymx/7ol6htjLQyd8uIqrFeid pk/LwiIFUd2zTjI6WIZu42LZ5nlD/F0ZlBuYpt0N5L15PA7vqa3v9I4qvQcHEJgtUMhevlv NZJqsqmezaD41aLSUH1Mw== X-UI-Out-Filterresults: notjunk:1;V03:K0:tWrZs+v2FHg=:TRFbbu2NJKxdvEaDdjOgDw f43/7IhoxZ8SMwjStrYVKHFCDiImBktPH84ynUnHEZ6hu35oMfVFisq9IMcYefsfGLJ8dJ+6o tcgCsAcGNEhpjgiaQEBX6f3I3y47k9npFuzcmZdKGJU2m65wtOizJODfMh4O4g+etltFLT0aU 0h8ueXT9XG5ghD4MWy3bkIKu+3oIndMjpUAJ0BtUCyL4sWwdD0u4/IBmfNfANAs2oxlEqMZKB ZDToHXSWUdamrawb9XqkWNd9N8+OTHh3JsK48VMUKpD9rQWC9Fa2VLvWrw4HL6eJl/NjRo9hF 82jC0zpq9esiSMw29UIWSX/NmN+DtV00sG23K6whQ9nVAKLZ0d0kp351i+xtUgLXpqR19g8aq aG4zuJg2V6HIrv1JEbwM/UW2s/Nk54MVJW4aOjBYF6x56NI9TDonGbEtH8mvcY2GQGsyUFq4C Na1zKioRUcKAh8dTKqIlIF+nYGkgiOF87eChDWyOa7gbPppLFysCPmOg+zGRDHWDTAe80NH0Y qgVYz5ZK7BRzMSLz35YHzdmiAW/HKnOAENP3kuAagUNIxYdphWWG9k22RkofiWl4eoTGp+y7A 2Vj2mdB4cVSGCfuq0PgefPpGFuWOX2VHurgHL8SqPa4FWOlOFmQPg26IyXFQ3sMV5/gGe/90m IL7ZPsqKBWBsFwbTuIiTp16S5c7s+mAY8C+9tq5od4l4ux1MjprWp8r7xH2P6ek7a2jj6cVvf 4BxouacezmMdY56TxHjNgdlswTeYkWN+sfFBXTuTAC6Fmn+aKptgk322vUcATOxsvwD/qLVr 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" Xref: news.gmane.io gmane.emacs.bugs:186637 Archived-At: --=-=-= Content-Type: text/plain Gregory Heytings writes: Hi, > Apparently my previous last note was not the last one ;-) > > I still don't know how this bug should be fixed (except by using (setq > completion-at-point-functions '(pcomplete t))), but here is a more > detailed explanation of what is happening, at least how I understand > it: > > 1. TAB calls completion-at-point > 2. completion-at-point calls pcomplete-completions-at-point, which > calls pcomplete/cd; this completes the directory name > 3. completion-at-point let-binds completion-in-region-mode-predicate > to a lambda, which contains pcomplete-completion-at-point > 4. completion-at-point calls completion-in-region, which adds > completion-in-region--postch to post-command-hook > 5. post-command-hook calls completion-in-region--postch > 6. completion-in-region--postch funcalls completion-in-region-mode-predicate > 7. this calls pcomplete-completions-at-point a second time, which > again calls pcomplete/cd (and adds a '/' after the directory name (?)) > 8. RET is pressed > 9. post-command-hook still contains completion-in-region--postch: it > is called again > 10. completion-in-region--postch funcalls > completion-in-region-mode-predicate again > 11. this calls pcomplete-completions-at-point a third (!) time > 12. at this point pcomplete-completions-at-point considers (for some > reason, possibly because the last character of the input is '/' (?)) > that it is a command that it must now complete > 13. therefore instead of calling pcomplete/cd a third time, > pcomplete-completions-at-point now calls eshell-complete-commands-list > 14. this loops through all possible command names (on the local or remote host) > 15. if all command names had had a common prefix, that prefix would > have been inserted now, but this is not the case, so the effect of > this loop (apart from a waste of time) is nil > > The fact that default-directory is remote is not important here, the > exact same steps take place when it is local, except that step 15 is > executed much faster. > > At step 15 it is possible to interrupt the loop with C-g. At step 8 > it is possible to remove completion-in-region--postch from > post-command-hook for example by switching buffers with C-x C-b. > > Why such a overly complicated mechanism is used, or what should be > done to avoid this behavior, is beyond my understanding. I don't know the completion machinery, so I'm adding Stefan who might know better. However, the remote case could be improved. Tramp uses caches. They expire after a while (10 seconds per default), but this might be improved. The appended patch disables Tramp cache expiry while being in eshell-complete-commands-list, so completion might be faster once the cache has been filled. Could you pls check? Best regards, Michael. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Transfer-Encoding: quoted-printable *** /tmp/ediff046iSD 2020-08-29 14:36:21.788278641 +0200 =2D-- /usr/local/src/emacs-27/lisp/eshell/em-cmpl.el 2020-08-29 14:22:38.7= 81483169 +0200 *************** *** 399,405 **** (defun eshell-complete-commands-list () "Generate list of applicable, visible commands." ! (let ((filename (pcomplete-arg)) glob-name) (if (file-name-directory filename) (if eshell-force-execution (pcomplete-dirs-or-entries nil #'file-readable-p) =2D-- 399,405 ---- (defun eshell-complete-commands-list () "Generate list of applicable, visible commands." ! (let ((filename (pcomplete-arg)) glob-name remote-file-name-inhibit-ca= che) (if (file-name-directory filename) (if eshell-force-execution (pcomplete-dirs-or-entries nil #'file-readable-p) --=-=-=--