From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#49264: 28.0.50; project.el+tramp performance issue Date: Wed, 30 Jun 2021 02:01:36 +0200 Message-ID: <20210630000136.o2uqaa3ldxxtn5go@Ergus> References: <87fsx13aiz.fsf.ref@aol.com> <87fsx13aiz.fsf@aol.com> <72c1b336-ae02-36c0-db40-f608bafecdf3@yandex.ru> Reply-To: Ergus Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6085"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 49264@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 30 02:02:13 2021 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 1lyNgB-0001Ry-43 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Jun 2021 02:02:11 +0200 Original-Received: from localhost ([::1]:35442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyNg9-00072a-Ks for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Jun 2021 20:02:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyNg2-00072K-FD for bug-gnu-emacs@gnu.org; Tue, 29 Jun 2021 20:02:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44423) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyNg2-0006T5-7g for bug-gnu-emacs@gnu.org; Tue, 29 Jun 2021 20:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lyNg2-0002UF-20 for bug-gnu-emacs@gnu.org; Tue, 29 Jun 2021 20:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ergus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Jun 2021 00:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49264 X-GNU-PR-Package: emacs Original-Received: via spool by 49264-submit@debbugs.gnu.org id=B49264.16250113189549 (code B ref 49264); Wed, 30 Jun 2021 00:02:02 +0000 Original-Received: (at 49264) by debbugs.gnu.org; 30 Jun 2021 00:01:58 +0000 Original-Received: from localhost ([127.0.0.1]:55969 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyNfy-0002Tw-Dj for submit@debbugs.gnu.org; Tue, 29 Jun 2021 20:01:58 -0400 Original-Received: from sonic313-14.consmr.mail.bf2.yahoo.com ([74.6.133.124]:43913) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyNfv-0002TX-Oh for 49264@debbugs.gnu.org; Tue, 29 Jun 2021 20:01:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1625011309; bh=EqRW6YirdOg81X5igmaWIywu4/rACWUoRm+vlng+3sE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject:Reply-To; b=kA/0IduXXOmJdTvm2DzTUyKsHjOD0CxVA09snzlTOXOfV3C1zeji/8RUhHJ6TVFuFHCsW/kAx8BBbItwZkpPlijDXNMUM4dU+ph+ZmD041b4e8SUcYq3fFmQ1tMlcV0ucIl7xoLad4j8KYwVKbrwsy4RYoRfLIev9WU4NtsgTu2pxZQgxmjPP2/d5manDtwy8mpmld7wQAa7qZlCrGrXDuwen9B7KZQKpGEM+LMu74Pie45k645B4JLiJz6ZaExqKB35YvtGimOxApn+AptFVJALA5L+o9LSvSrl9C0/rxF96FZyId3ngVYxrzN9iVrsAeQNwYrzwyKp4uptKugcmg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1625011309; bh=8ZqG1CAmQP0mDkAegwHMcFcwIkN+VqelIsffoCszDRg=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=ahCHQG2FX09dU+EBJLP6+lUqd66edEVnDyOgRv2ZDSkken7sP+TQ9/ly8odU7i1OYQOBBbzA9lgQGOBwdgY8HY6ugiX0GXQb9huawq4omuUVCW/bHJ3QHXzgLXN7gjV362SCWjK4TqaQsZy6EapO+7fLsjrxxDIh2EL9H00rrDPhlWyCf/Qv8WVm7f6t9javjos+4/ISilwAd9eFAPS33eIM72JA/3PS8pM0hITlsVRN/YHfR8rUyHJHuT99F1mrzSnAawBM/GHnfhUQYN1gmEB4nAAMHerb3ZJNU2celiAlDKFU1yobAr+hwAa2rLvlct2cWaO/WAcknkIVbmV5aA== X-YMail-OSG: HLF4qaYVM1mSPKzIQ9_Oiz00BFK6CmlJad2iUQjJgUlRNyHeangd4xyT0FL8289 rebB4QwqMbHt4EuI3kVR5EoxqDZ.rrBGiIYGLN3G0.W5xYFOwwGDe.IV0L_T2lHvk6JRcPn4iK_2 iR8O1xuXVlWFCtVnsABMVsOQZaDrPvW4Z006FZ8W2OpTQuD9LKaLi2luoR32YM2ryKs17LMhhEYF 5uVOmqFGENkIzbBrPaPo8AgwFdX62G4sADfBu0WDNrdXx5d.0jJqLSUSoEE_ngMuLwlVLtssPM1j cn41kH_UjTfURzuyKXHkF5oaW38waFOTD8UCLF8oBTBWK8kJZh0FakjKoAevOYLh6jD5LEjFrSXD dE.X5FE1E1WoGjsADgcJl6i_gbHbNNtVUMGEd8rljhI8K71KG_HRWs20jpTQTHK0LYBHSpJhG9UH BEJoyXgEHYfMByNOn.o6a1mhF8Y6N4L4YnlZcv9XXmYG_5Oq7bxf.F5nAHW4zy3nU_uSqgpBhkOL FENuRVfLB_snLeXDeIWS_1mTJFdTjtGCpTYLSGgZQWUvCk7Wo49lJQeOmvx7ivgP8r4l3Lp91_nl 5fSZVH67h9nr85NVHszKrYUpSVsIpPMXF0ZhLTZ54f24_1qWWJAtpX0QyovHBwafBeTSpCskPORd PqrwfJLXzGWGJgmulPv7Iq.tHvCIpmnEeVa_N_JUGe1m1HDRpaoYoPpa0kQYQROcmVAyfznzMyFE TR_KlU0Xl9tvhX.qKuqWR9.Qo4UGD.m07psg436_96fEmacZZGFXu85dFaRC.jue6vu0IsPX.nwg 2SBUCTxDjIP28l1gQih_LGnHDO9kjOt0tI9NMZF_37 X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.bf2.yahoo.com with HTTP; Wed, 30 Jun 2021 00:01:49 +0000 Original-Received: by kubenode527.mail-prod1.omega.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 13e9fed445d0719f034e7e6e061c8855; Wed, 30 Jun 2021 00:01:45 +0000 (UTC) Content-Disposition: inline In-Reply-To: <72c1b336-ae02-36c0-db40-f608bafecdf3@yandex.ru> X-Mailer: WebService/1.1.18469 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol 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:209133 Archived-At: On Tue, Jun 29, 2021 at 04:00:02PM +0300, Dmitry Gutov wrote: >Hi! > >Thanks for the report, I'll follow up on this discussion some more >later, but some initial observations: > >On 29.06.2021 01:11, Ergus via Bug reports for GNU Emacs, the Swiss >army knife of text editors wrote: >>As a workaround I removed all the uninteresting handlers from >>vc-handled-backends and I get better times now, but IMHO it is still >>very inefficient (almost a minute for project-switch-to-buffer is >>excessive). And make it practically unusable. > >Could you evaluate (benchmark 1 '(project-current)) in one of your >buffers? That should give us an estimate how long it takes to find the >"current project" on your remote system. > Only with git and mercurial it takes: Elapsed time: 3.018998s (0.109912s in 1 GCs) With the entire list in vc-handled-backends Elapsed time: 8.197923s (0.507396s in 6 GCs) >If I'm right, project-switch-to-buffer should take 25 x (that time). > >If you indeed only have 25 buffers (including hidden ones). > >>In any case: >> >>Maybe (I think I mentioned this before) `project.el` needs a sort of >>cache to speedup some functions like `project-current` that are called >>very frequently inside the project.el code. > >The difficulty here is probably with the large latency to the remote >system. And our current approach calls the "find current project" >logic for each open buffer. > >Even if we add the "current project" cache, it will only take effect >at second and further invocations. Your first project-switch-to-buffer >call will still take 3-5 minutes, which is unacceptable. > >Please get back to us with the requested measurements, and perhaps >other observations (any research initiative is welcome), but if >finding the current vc root for each buffer is unavoidably slow, we'll >finally need to switch to a "project-contains-buffer-p generic" >approach, previously discussed in e.g. "Speed up project-kill-buffers" >thread on emacs-devel. Another (and maybe even simpler) optimization, may be to consider that all the buffers with the same default-directory should have the same vcs and vc root (and probably belong to same project). (I think that all vcs backends only do the search based on default-directory at the end.) So if the association in the cache is for `default-directory` instead of individual file names; then, less files will need to evaluate the search of vc root, and vc-backend only 1/subdir will search the first time. It is a very good trade of IMO. This will reduce the time even the first time we iterate project-current over all opened buffers if multiple files are in the same directory (example: sources in src, includes in include and so on). And I think it will cover 99% of normal use cases. This won't affect nested projects, git-submodules or similar, because those will be in different subdirs.