-
-
Notifications
You must be signed in to change notification settings - Fork 579
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-find-other-file is slow #1147
Comments
I'm doing this by passing (defun eqyiel/projectile-current-project-files ()
"Return a list of files for the current project."
(let ((files (and projectile-enable-caching
(gethash (projectile-project-root) projectile-projects-cache))))
;; nothing is cached
(unless files
(when projectile-enable-caching
(message "Empty cache. Projectile is initializing cache..."))
(setq files
(split-string
(shell-command-to-string
(concat
"fd '' --hidden "
(directory-file-name (projectile-project-root))))))
;; cache the resulting list of files
(when projectile-enable-caching
(projectile-cache-project (projectile-project-root) files)))
(projectile-sort-files files)))
(advice-add
'projectile-current-project-files
:override
'eqyiel/projectile-current-project-files) |
A better elisp hacker than me can probably find a better way to do this (maybe use a temp buffer than pipe the result to a string and split it). |
I completely agree. There's a lot of extra processing that happens that most users probably don't need. I was thinking for a while of adding some flag that simply drops all the all the extra processing and just shows whatever PRs in this direction would be welcomed. |
Btw, from a very basic profiling session it seems the bottleneck is here:
Removing this relative-name conversion will make everything much faster, but I guess we added it because not all external commands were returning relative paths. Guess we can remove it and see who'll complain. :-) |
And yeah - the general problem is that Projectile can't assume git everywhere, but it should probably optimize aggressively for git. |
External tools should return relative paths by default. This conversion was just one giant performance bottleneck.
Please see this comment: e3007ae#r31366629 |
Expected behavior
projectile-find-other-file
returns in under0.1s
.Actual behavior
projectile-find-other-file
returns in0.99s
.Steps to reproduce the problem
Run it in a repo with 22k files.
Environment & Version information
Projectile version information
Newest git.
Emacs version
25.5.2
Operating system
Linux.
Discussion
In my repo,
projectile-current-project-files
takes on average0.86s
, so it's not surprising thatprojectile-find-other-file
takes0.99s
. Note also thatprojectile-get-repo-files
takes only0.17s
so a considerable speed up could be gained if that one was used.But an even greater speedup can be gained if we make e.g.
git ls-files
do the filtering for us. In that case it takes only0.02s
to get a result.I post here an example code, I don't know if it's good enough for Projectile to rely only on Git for this:
The text was updated successfully, but these errors were encountered: