From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus Newsgroups: gmane.emacs.devel Subject: Performance issue in project.el Date: Sun, 27 Jun 2021 23:21:23 +0200 Message-ID: <20210627212123.xciejcjxrv2rxsra@Ergus> References: <20210627212123.xciejcjxrv2rxsra.ref@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="4557"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jun 27 23:22:32 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lxcEZ-00013V-J2 for ged-emacs-devel@m.gmane-mx.org; Sun, 27 Jun 2021 23:22:31 +0200 Original-Received: from localhost ([::1]:38042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lxcEY-0000B0-Kp for ged-emacs-devel@m.gmane-mx.org; Sun, 27 Jun 2021 17:22:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lxcDm-0007wi-6M for emacs-devel@gnu.org; Sun, 27 Jun 2021 17:21:43 -0400 Original-Received: from sonic307-2.consmr.mail.bf2.yahoo.com ([74.6.134.41]:34306) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lxcDi-0002WE-1v for emacs-devel@gnu.org; Sun, 27 Jun 2021 17:21:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1624828894; bh=CQmXRFYoDWxQhm/oyCVIjJRfL5BUrui+f0nh+oNMPi4=; h=Date:From:To:Subject:References:From:Subject:Reply-To; b=iq4sLstPtIaXrptJcl/CNB0XieOnJYDdMLzLOqaPMcK0Rs54BLFiN1IJ0yGo6VegREZVzh9ebcETVuk9btIo3SQL0xw7MVvKYPR7t2HPnQ4UzSPqlRQW4MOeWXtpmlaLrEjLrKjUQqmqD8dG6CVCwuLJ6rQLvEpO7eB2nFhb9ypJQlGY47ZvrtZhmPAHn4UJQAtSdmXx5iRGx3tPUCR1NLMAb3xrR//sowXAiuwTA1VKCpffRJ8gIB/ZDjfPWNBi3YIaOX0vnoB0AGO2vFzakadCNbAXio+xTZcpaUlf2TtJUPvHuIlJOrlrgJeS5I9iQAsXFUg9QuhFexbxJAIOZQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1624828894; bh=9XufP7DqwOszwAUwzeDigW8Zwu1Kp30KMFz+Oa3ZoW5=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=dPBLA7CbWmFEw3uHLBePaCQYGfwukkmsT/NiKEiLuIAFgJIA0y01zKiR2oLsBT39QvgaKccD9N/yb1lTsXNPwIdbqi2mfN8eqYGpNRi5r8cjtBymdSnDUgmIWJmkaeoMVFTk5xZhUKSq7epyK26c/5gjCf8slP6h+oBkG+vcG+kzYjDIoAqjkHXD906I2r73BoP8oemWodTgzpWIwAQMZcKMGjTfSkkImJGRAVGcQ/3aQQOwgmsR5P9mH9IQ9+r9uouE7kJXs7ITdUVt3LpYhdQCkRbORmLAsYGsWkbbePh8yfKB4gsktx0skKPKc1du9VIMDrC16sGpGHqFTRc+Lw== X-YMail-OSG: XX_4x_0VM1nlzNDstq9Rc0F8o2O5xu9G9qwvGtlOdpYCzkfqW_xZeijujDO8FUc tee49EQODJs6deeiQkOgSgG90VYicaMENtBd.hQcWEX5up92aVHb.FnqHwGaa.lOJb_jrvrAplrb qwS.JWFBGTUovgTm3QvJCy3qmqpayxj85OtRCsT6TfVtujZmslpJWt_jAbgG1Hx8nNlHZre4z5oO J3_weAgKY35DW7TQn.Y_sz1cS8O8HqdYEipsxulzWpsDD0lGYf8EMj6HntJFIvHospdpCKVcGkwx oGA8l_isL5laLJVDq8gkr2eYVjzILuBlh_gC2H6dJ5F303SrXQlh.wN_yECd4K432BpzTjRAlrlz MKmlOJuRSu6iCvXzSHix.VtaFlMVPK02x5WFj_df_rMLwNiZAsNpvvLkFJPlgvueRV5c1dLrF1Zp nMlKnfsCFbz1Wk299FKT8UdjS.Ee_n2kvhJdMTYXuhhO69xMdzePMEBeu7wVK4pCydw9YoYYw7Wt Ty0Ssg1zD_Id6pnTTn1vewl50KuglmyJbooxDBM75sSPts6VSFBZ3WLjQKB4WvWaKw_DwkED9_jl lWNVOdmJCHqOaSpOCU6bc5VAGt5D_GeaDqsCP5EKJGTFmT1W748nTWo6h9mcFvN1N.CiamAgfmJC _NFxHYnaAtKaODuWnvA4LfdyZB_feLJoZ8u0KTt0Ens_pvCe8OULzJVuKJ3JD9Zgz4JtYA4TMhoW MR1k1tVcpPQGK28zOdsadB1fbk9Q1are9c01miVpNx72utmb4SQSEtYh75NQ.NAdNRuwxUGwLlWJ 8Vax.zRROOFkOzqZoCA015mgsAqYOsdHzWBheBjiQq X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.bf2.yahoo.com with HTTP; Sun, 27 Jun 2021 21:21:34 +0000 Original-Received: by kubenode543.mail-prod1.omega.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 91796d7bd383dc2246cb31f1f1f881c2; Sun, 27 Jun 2021 21:21:31 +0000 (UTC) Content-Disposition: inline X-Mailer: WebService/1.1.18469 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Received-SPF: pass client-ip=74.6.134.41; envelope-from=spacibba@aol.com; helo=sonic307-2.consmr.mail.bf2.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:271058 Archived-At: Hi: Using tramp I tried to use project.el with a command like project-switch-to-buffer and it took like 10 minutes to complete. I ran a profiler and I found that most of the time was taken by: project-current called in a loop for all the opened buffers it calls project--find-in-directory that calls project-find-functions and there is going all the time. I had global-tags-try-project-root (a function from an external package tat call gnu global program... something like gtags). And I optimized that function to use a cache and avoid calling the program for every buffer creating a cache for it. Something like: ``` (defvar global-tags--dbpath-cache (make-hash-table)) (cl-defun global-tags--get-dbpath (&optional (dir default-directory)) "Filepath for database from DIR." (pcase (gethash dir global-tags--dbpath-cache) ('empty nil) ('nil (puthash dir 'empty global-tags--dbpath-cache) (when-let* === BLA === (when (file-exists-p dbpath) (puthash dir dbpath global-tags--dbpath-cache)))) (code code))) ```` Now the time is half than before but still very slow to use the command (around 3-5 minutes to complete) and running again the profiler I get this: 5637 89% - command-execute 5549 88% - byte-code 5549 88% - project--read-project-buffer 5549 88% - let* 5336 85% - read-buffer 5323 84% - ivy-completing-read 5323 84% - ivy-read 4941 78% - ivy--reset-state 4941 78% - ivy--buffer-list 4941 78% - internal-complete-buffer 4941 78% - # 4941 78% - and 4941 78% - equal 4941 78% - save-current-buffer 4941 78% - project-current 4941 78% - project--find-in-directory 4548 72% - project-try-vc 4537 72% - vc-responsible-backend 4478 71% - # 4478 71% - vc-call-backend 4478 71% - apply 1470 23% + vc-svn-responsible-p 1142 18% + vc-bzr-responsible-p 970 15% + vc-hg-responsible-p 390 6% + vc-git-responsible-p 156 2% + vc-cvs-responsible-p 126 2% + vc-rcs-responsible-p 108 1% + vc-sccs-responsible-p 98 1% + vc-src-responsible-p 57 0% + tramp-file-name-handler 11 0% + vc-file-getprop 393 6% + global-tags-try-project-root 375 5% + read-from-minibuffer 13 0% + if 213 3% + project-current 88 1% + funcall-interactively 572 9% + ... 51 0% + timer-event-handler 8 0% + redisplay_internal (C function) As you can see most of the time is still taken by project-current and I can't really understand why: 1) Are so many samples 4548 seems a very high number for only 25 opened buffers. 2) why project-try-vc still takes so much...? Specially for unfrequent vc systems in our days like svn or bzr that I am not using. 3) If vc-handled-backends has these value by default: '(RCS CVS SVN SCCS SRC Bzr Git Hg Mtn) why is there some time taken by vc-hg-responsible-p that is latter than git in the list? 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. Best, Ergus