Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

projectile is still very slow over tramp #1232

Closed
avkoval opened this issue Apr 14, 2018 · 19 comments
Closed

projectile is still very slow over tramp #1232

avkoval opened this issue Apr 14, 2018 · 19 comments

Comments

@avkoval
Copy link

avkoval commented Apr 14, 2018

Expected behavior

Cursor move and other things should not be affected when projectile is enabled.

Actual behavior

Sometimes emacs almost get frozen, sometimes experiences serious slowdowns when any of files are open via tramp.

Steps to reproduce the problem

Use latest emacs, for example emacs-26.1 and then enable projectile and open any file over tramp like /ssh:somehost:

Projectile version information

Projectile 20180324.2226

Emacs version

GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.28)
 of 2018-04-12

Operating system

Linux

Suggestions

I've found nice snippet here:
https://sideshowcoder.com/2017/10/24/projectile-and-tramp/

and it seems it helps in this situation.

@bubak4
Copy link

bubak4 commented Sep 14, 2018

Same here, though the connection is good, I usually turn off projectile when working with remote buffers. Turning projectile off is great speed up.

@bbatsov
Copy link
Owner

bbatsov commented Sep 20, 2018

I'm pretty close to just deleting all of the code for speeding up things over tramp and just adding some check making Projectile there a no-op at this point. We've added a ridiculous amount of special checks and caching for TRAMP and people are still complaining, so it seems it wasn't meant to be.

Did you a least check with the profiler where exactly is the performance bottleneck?

@avkoval
Copy link
Author

avkoval commented Sep 20, 2018

Thanks, I will try your updated code just now :-)

@bubak4
Copy link

bubak4 commented Sep 20, 2018

so it seems it wasn't meant to be.

Hopefully not, but I could understand that. Your projectile package is quite essential in my GNU Emacs usage and I am extremely happy to use it; as well as using tramp for remote file editting.

Did you a least check with the profiler where exactly is the performance bottleneck?

Before any measurement I have upgraded my current installation -- at the time of writing the significant packages have been:

  • Projectile 20180911.540 (latest from MELPA)
  • Helm 20180906.517 (lates from MELPA)
  • GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-09-15, modified by Debian

My projectile config looks like:

(use-package projectile
    :ensure t
    :init
    (progn
        (setq projectile-file-exists-remote-cache-expire nil)
        (setq projectile-mode-line '(:eval (format " Projectile[%s]" (projectile-project-name))))
        (setq projectile-globally-ignored-directories
            (quote
                (".idea" ".eunit" ".git" ".hg" ".svn" ".fslckout" ".bzr" "_darcs" ".tox" "build" "target"))))
    :config
    (progn
        (projectile-mode 1)
        (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
))

I have tried some basic file opening & editting and I must conclude that projectile has not been a bottleneck -- most of the time the problem has been caused by helm and remote work with both packages enabled (helm & projectile) had been much better experience than I remember, so please consider my problems being solved.

screenshot-02-622x652

I did some simillar measurments in the past, but I used older projectile version and and the profiler report looked differently. Everything seems to be ok now. Sorry for false report. Keep up the great work.

@bbatsov
Copy link
Owner

bbatsov commented Sep 21, 2018

Great! Happy to hear this!

@avkoval
Copy link
Author

avkoval commented Sep 21, 2018

Is this already included into projectile-20180921.442?
I have tried to update my packges and then:

  • Login to remote host via tramp
  • Open some directory in dired. And just press Up and Down key a few times.
    Results:

@bbatsov
Copy link
Owner

bbatsov commented Sep 21, 2018

@avkoval Looking at the output that can't be the latest build - the code there is invoked just once and it doesn't use eval at all.

@avkoval
Copy link
Author

avkoval commented Sep 21, 2018

Yes, may be something was wrong on that desktop. I have tried on another one from office now and the problem is gone. Thank you!

@bbatsov
Copy link
Owner

bbatsov commented Sep 21, 2018

You're welcome! It's funny that after a few years I just reverted the code to what it used to be say 5 years ago. :D So much pain came from a very simple change (dynamic modeline updates vs static updates). In hindsight I should have reverted this a long time ago, but it always seemed that we were very close to getting the caching right. Anyways - lesson learned! 😆

@avkoval
Copy link
Author

avkoval commented Sep 22, 2018

My modeline looks pretty wierd now, may be consequence of this change:

@bbatsov
Copy link
Owner

bbatsov commented Sep 22, 2018

That's a small bug that was fixed on master already. There should be a new MELPA build I guess.

@johanatan
Copy link

I am experiencing very slow projectile when tramp is involved. Any recommended way to track it down to some combination of things? I am fairly sure I also have helm. This is a pretty vanilla Spacemacs setup. Any help would be appreciated. Thanks!

@mskorzhinskiy
Copy link

@johanatan I'm not sure if this is fixed in spacemacs by default or not, but in my setup I still using this piece of code:

(defadvice projectile-project-root (around ignore-remote first activate)
    (unless (file-remote-p default-directory) ad-do-it))

I took it from here from user /u/renatofdds: https://www.reddit.com/r/emacs/comments/320cvb/projectile_slows_tramp_mode_to_a_crawl_is_there_a/

Without it my whole emacs start crawling with tramp buffers.

@mpereira
Copy link

Same for me, and I don't even use Spacemacs.

@mpereira
Copy link

Just for the record, one of my current symptom of slowness in TRAMP buffers when projectile-project-root is not adviced, is moving between lines in dired buffers gets super slow. I have captured a profiler report, and the root cause seems to be that tramp-file-name-handler called via projectile-file-exists-p -> expand-file-name -> tramp-file-name-handler, is very slow.

It looks like projectile-project-name is called whenever changing lines in dired buffers.

Adding the advice fixes it.

Full profiler report:

- ...                                                                                    16342  99%
 - evil-repeat-post-hook                                                                 16278  98%
  - if                                                                                   16278  98%
   - progn                                                                               16278  98%
    - let                                                                                16278  98%
     - evil-repeat-type                                                                  16278  98%
      - if                                                                               16278  98%
       - progn                                                                           16278  98%
        - let*                                                                           16278  98%
         - ivy-call                                                                      16260  98%
          - let*                                                                         16260  98%
           - cond                                                                        16260  98%
            - prog1                                                                      15622  94%
             - unwind-protect                                                            15622  94%
              - if                                                                       15622  94%
               - projectile-project-name                                                 15612  94%
                - or                                                                     15612  94%
                 - let                                                                   15612  94%
                  - or                                                                   15612  94%
                   - projectile-project-root                                             15612  94%
                    - apply                                                              15612  94%
                     - ad-Advice-projectile-project-root                                 15612  94%
                      - #<lambda 0x1e9740fde6851051>                                     15612  94%
                       - let                                                             15612  94%
                        - cl-subst                                                       15612  94%
                         - or                                                            15612  94%
                          - let                                                          15612  94%
                           - if                                                          15579  94%
                            - progn                                                      15579  94%
                             - cl-some                                                   15579  94%
                              - #<lambda -0x1cdaa84491f12ff0>                            15579  94%
                               - let*                                                    15579  94%
                                - if                                                     15577  94%
                                 - let                                                   15577  94%
                                  - funcall                                              15577  94%
                                   - projectile-root-top-down                             9054  54%
                                    - projectile-locate-dominating-file                   9053  54%
                                     - let                                                8819  53%
                                      - while                                             8819  53%
                                       - setq                                             8720  52%
                                        - if                                              8720  52%
                                         - funcall                                        8720  52%
                                          - #<lambda 0x153bc972552b2397>                  8720  52%
                                           - cl-find-if                                   8720  52%
                                            - apply                                       8720  52%
                                             - cl-find                                    8720  52%
                                              - apply                                     8720  52%
                                               - cl-position                              8720  52%
                                                - cl--position                            8719  52%
                                                 - #<lambda 0xe7925766ca908ce>            8719  52%
                                                  - projectile-file-exists-p              8718  52%
                                                   - expand-file-name                     4755  28%
                                                    + tramp-file-name-handler             4753  28%
                                                   - let*                                 3926  23%
                                                    - file-remote-p                       3860  23%
                                                     + tramp-file-name-handler            3835  23%
                                                    + if                                    66   0%
                                       + cond                                               99   0%
                                     + setq                                                234   1%
                                   - projectile-root-bottom-up                            3788  22%
                                    - cl-some                                             3788  22%
                                     - #<lambda 0x1507dfe13832bc7f>                       3788  22%
                                      - projectile-locate-dominating-file                 3788  22%
                                       - let                                              3306  20%
                                        - while                                           3306  20%
                                         - setq                                           2649  16%
                                          - if                                            2649  16%
                                           - projectile-file-exists-p                     2647  16%
                                            - let*                                        1704  10%
                                             - file-remote-p                              1692  10%
                                              + tramp-file-name-handler                   1689  10%
                                             + if                                           12   0%
                                            + expand-file-name                             931   5%
                                         + cond                                            657   3%
                                       + setq                                              480   2%
                                   - projectile-root-top-down-recurring                   1970  11%
                                    + cl-some                                             1970  11%
                                   + file-truename                                         762   4%
                           + file-remote-p                                                  33   0%
               + funcall                                                                    10   0%
            + select-window                                                                637   3%
            + save-current-buffer                                                            1   0%
         + lui-insert                                                                       17   0%
         + evil-get-command-property                                                         1   0%
 + format                                                                                   58   0%
 + evil-repeat-pre-hook                                                                      2   0%
 + irc--filter                                                                               2   0%
 + regexp-opt-group                                                                          1   0%
 + minibuffer-inactive-mode                                                                  1   0%
   Automatic GC                                                                              0   0%
+ beacon--post-command                                                                      77   0%
+ command-execute                                                                           60   0%
+ posframe-run-hidehandler                                                                  17   0%
+ redisplay_internal (C function)                                                            5   0%
+ timer-event-handler                                                                        2   0%
+ global-hl-line-maybe-unhighlight                                                           1   0%

@peterbecich
Copy link
Contributor

Can we re-open this issue? I will try to contribute to this issue.

@peterbecich
Copy link
Contributor

This may have yielded an improvement for me: #234 (comment)

@tadd
Copy link

tadd commented Jan 14, 2024

I just found this library a few weeks ago and started using. Thanks for the cool work.

I faced the same problem and confirmed that the same solution #1232 (comment) is still effective, but I modified it a bit with a newer function advice-add.

(advice-add 'projectile-project-root :before-while
  (lambda (&optional dir)
    (not (file-remote-p (or dir default-directory)))))

@peterbecich I doubt your situation. Unfortunately, I found that the advised function projectile-on was removed ~10 years ago. 0e68702

@andrewpeck
Copy link

I just found this library a few weeks ago and started using. Thanks for the cool work.

I faced the same problem and confirmed that the same solution #1232 (comment) is still effective, but I modified it a bit with a newer function advice-add.

(advice-add 'projectile-project-root :before-while
  (lambda (&optional dir)
    (not (file-remote-p (or dir default-directory)))))

@peterbecich I doubt your situation. Unfortunately, I found that the advised function projectile-on was removed ~10 years ago. 0e68702

@tadd thank you so much--- the advice you posted made a huge improvement for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants