-
-
Notifications
You must be signed in to change notification settings - Fork 583
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
Consider replacing shell-command-to-string
invocations with direct call-process
invocations
#1044
Comments
Actually, I was able to get something working that optionally skips shell-command-to-string if emacs can find the relevant binary itself. (defun projectile-call-process-to-string (program &rest args)
(with-temp-buffer
(apply 'call-process program nil (current-buffer) nil args)
(buffer-string)))
(defun projectile-shell-command-to-string (command)
(cl-destructuring-bind
(the-command . args) (split-string command " ")
(let ((binary-path (eshell-search-path the-command)))
(if binary-path
(apply 'projectile-call-process-to-string binary-path args)
(shell-command-to-string command)))))
(defun projectile-files-via-ext-command (command)
"Get a list of relative file names in the project root by executing COMMAND."
(split-string (projectile-shell-command-to-string command) "\0" t)) This will obviously only work if This change makes things MUCH MUCH faster for me. The downside to this approach is that it means that projectile will need to depend on eshell. An alternative approach could be to simply include the eshell search path function in projectile itself. The function is pretty short:
|
This change makes it so that a direct `call-process` invocation is used when it is possible to determine what binary should be used for the command. This avoids the cost of shell startup time that is incurred when `shell-command-to-string` is invoked instead.
This change makes it so that a direct `call-process` invocation is used when it is possible to determine what binary should be used for the command. This avoids the cost of shell startup time that is incurred when `shell-command-to-string` is invoked instead.
This change makes it so that a direct `call-process` invocation is used when it is possible to determine what binary should be used for the command. This avoids the cost of shell startup time that is incurred when `shell-command-to-string` is invoked instead.
This change makes it so that a direct `call-process` invocation is used when it is possible to determine what binary should be used for the command. This avoids the cost of shell startup time that is incurred when `shell-command-to-string` is invoked instead.
This change makes it so that a direct `call-process` invocation is used when it is possible to determine what binary should be used for the command. This avoids the cost of shell startup time that is incurred when `shell-command-to-string` is invoked instead.
Should this be reopened? |
@patbl yeah, I think so. I think it would probably be possible to replace all external calls with call-process calls |
I switched to |
Projectile makes extensive use of the
shell-command-to-string
elisp function when it uses the'alien
indexing method. The advantage of this is, I presume, that the appropriate binary will automatically be detected based on the users shell configuration.However, for people with non-trivial shell startup times there is a somewhat steep performance penalty to this approach. I have an extensive zsh configuration, but I have made an effort to keep it as lean as possible, and I still see a significant performance penalty to
shell-command-to-string
.I used this measure-time macro to investigate this
Unfortunately, because of the way that git works, we need to invoke the git-ls-files command directly. (supplying the ls-files argument doesnt work.
This is an order of magnitude difference, and because projectile actually invokes MULTIPLE shell commands for each emacs command, this penalty is paid several times.
I realize that rearchitechting this would be somewhat difficult, but would you be open to a change to use
call-process
when the path to git subcommands is explicitly specified?Projectile version information
Emacs version
E.g. 25.1
Operating system
OSX Yosemite
The text was updated successfully, but these errors were encountered: