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

Startup of vim-fish is insanely slow #34

Open
keyboard-clacker opened this issue Apr 5, 2016 · 37 comments
Open

Startup of vim-fish is insanely slow #34

keyboard-clacker opened this issue Apr 5, 2016 · 37 comments

Comments

@keyboard-clacker
Copy link

@keyboard-clacker keyboard-clacker commented Apr 5, 2016

I've been loving using fish, but I've found that the startup time of this plugin is super slow, upwards of 5 seconds sometimes. I've pasted below a bit of the output of my vim --startuptime vim.log test.fish command. Is there any way to improve the performance? I'm not sure if it's just me, but I'd definitely like to use this plugin without the startuptime lag

152.351  000.095  000.095: sourcing /usr/local/Cellar/neovim/0.1.2/share/nvim/runtime/plugin/vimballPlugin.vim
152.531  000.138  000.138: sourcing /usr/local/Cellar/neovim/0.1.2/share/nvim/runtime/plugin/zipPlugin.vim
152.600  002.106: loading plugins
152.606  000.006: inits 3
156.487  003.881: reading ShaDa
157.076  000.589: clearing screen
165.099  001.021  001.021: sourcing /usr/local/Cellar/neovim/0.1.2/share/nvim/runtime/scripts.vim
2122.220  1956.397  1956.397: sourcing /Users/Kyle/.config/nvim/bundle/vim-fish/ftplugin/fish.vim
2122.991  000.027  000.027: sourcing /Users/Kyle/.config/nvim/bundle/vim-fish/indent/fish.vim
2123.407  000.110  000.110: sourcing /Users/Kyle/.config/nvim/bundle/vim-fish/syntax/fish.vim
2123.910  000.191  000.191: sourcing /Users/Kyle/.config/nvim/bundle/vim-airline/autoload/airline/extensions.vim
@pierrebeaucamp
Copy link

@pierrebeaucamp pierrebeaucamp commented Apr 3, 2017

Any update on this? I had to uninstall vim-fish because of it

@keyboard-clacker
Copy link
Author

@keyboard-clacker keyboard-clacker commented Apr 4, 2017

Ditto, still no updates from me. I just uninstalled it @pierrebeaucamp

@ElijahLynn
Copy link

@ElijahLynn ElijahLynn commented Apr 21, 2017

Ubuntu 14.04, Fish 2.4.0, vim-fish 825853f (master)
fast for me: The ftplugin/fish.vim lead is the longest of the loads but still 31ms.

048.776  001.217: loading plugins
048.917  000.141: loading packages
048.937  000.020: inits 3
049.570  000.633: reading viminfo
049.599  000.029: setting raw mode
049.608  000.009: start termcap
049.635  000.027: clearing screen
053.393  001.163  001.163: sourcing /usr/share/vim/vim74/scripts.vim
054.569  000.663  000.663: sourcing /home/elijah/.vim/bundle/vim-fish/syntax/fish.vim
086.425  031.327  031.327: sourcing /home/elijah/.vim/bundle/vim-fish/ftplugin/fish.vim
087.978  000.053  000.053: sourcing /home/elijah/.vim/bundle/vim-fish/indent/fish.vim
088.643  005.802: opening buffers
@ElijahLynn
Copy link

@ElijahLynn ElijahLynn commented Apr 21, 2017

Can you checkout master from source and try? That way we can compare.

@ElijahLynn
Copy link

@ElijahLynn ElijahLynn commented Apr 21, 2017

Also, @pierrebeaucamp are you also using Homebrew and Neovim? Is it easy for you try with normal Vim, not in home brew?

@pierrebeaucamp
Copy link

@pierrebeaucamp pierrebeaucamp commented Apr 24, 2017

I'm using Neovim. I checked out master, but it still takes multiple seconds to load. Longest file to load is ftplugin/fish.vim as well, which takes nearly 2 seconds.

@keyboard-clacker
Copy link
Author

@keyboard-clacker keyboard-clacker commented Apr 24, 2017

This seems to have fixed it for myself in both vim and neovim (sorry @pierrebeaucamp!), thanks for the update @ElijahLynn

@ElijahLynn
Copy link

@ElijahLynn ElijahLynn commented Apr 25, 2017

@kyleholzinger So to confirm, you are using master, Homebrew and Neovim or Vim and the speed is normal now and it appears that using master resolved the issue?

@keyboard-clacker
Copy link
Author

@keyboard-clacker keyboard-clacker commented Apr 25, 2017

@ElijahLynn Yes sir! I'm on master, installed both Vim and NeoVim with homebrew, and startup is all back to normal (at most 100ms or so).

@gmile
Copy link

@gmile gmile commented Apr 30, 2017

I'm running into the slowness issue as well.

I use:

  • neovim 0.1.7
  • fish 2.5.0

Both installed via homebrew.

I ran:

$ nvim --startuptime vim.log .config/fish/config.fish

Click "Details" below to see the log. Note the following line:

2901.355  2805.314  2805.314: sourcing /Users/gmile/.config/nvim/bundle/vim-fish/ftplugin/fish.vim
$ cat vim.log
times in msec
 clock   self+sourced   self:  sourced script
 clock   elapsed:              other lines

000.010  000.010: --- NVIM STARTING ---
000.646  000.636: locale set
001.511  000.865: inits 1
001.529  000.018: window checked
002.118  000.589: parsing arguments
002.122  000.005: expanding arguments
002.181  000.059: inits 2
002.324  000.143: init highlight
003.039  000.317  000.317: sourcing /Users/gmile/.config/nvim/autoload/pathogen.vim
031.817  000.092  000.092: sourcing /Users/gmile/.config/nvim/bundle/apiblueprint.vim/ftdetect/apiblueprint.vim
032.014  000.041  000.041: sourcing /Users/gmile/.config/nvim/bundle/rust.vim/ftdetect/rust.vim
032.268  000.151  000.151: sourcing /Users/gmile/.config/nvim/bundle/vim-elixir/ftdetect/elixir.vim
032.549  000.178  000.178: sourcing /Users/gmile/.config/nvim/bundle/vim-fish/ftdetect/fish.vim
032.764  019.438  018.976: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/filetype.vim
032.970  000.047  000.047: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/ftplugin.vim
033.161  000.040  000.040: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/indent.vim
033.821  000.224  000.224: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/syntax/syncolor.vim
033.957  000.522  000.298: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/syntax/synload.vim
033.996  000.735  000.213: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/syntax/syntax.vim
034.676  000.181  000.181: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/syntax/syncolor.vim
035.079  000.183  000.183: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/syntax/syncolor.vim
041.581  007.486  007.122: sourcing /Users/gmile/.config/nvim/bundle/base16-vim/colors/base16-default-dark.vim
041.667  039.154  011.091: sourcing /Users/gmile/.config/nvim/init.vim
041.675  000.197: sourcing vimrc file(s)
041.976  000.085  000.085: sourcing /Users/gmile/.config/nvim/bundle/apiblueprint.vim/plugin/apiary.vim
042.129  000.102  000.102: sourcing /Users/gmile/.config/nvim/bundle/apiblueprint.vim/plugin/apiblueprint.vim
043.710  001.399  001.399: sourcing /Users/gmile/.config/nvim/bundle/bufexplorer/plugin/bufexplorer.vim
044.782  000.439  000.439: sourcing /Users/gmile/.config/nvim/bundle/ctrlp.vim/autoload/ctrlp/mrufiles.vim
045.039  001.153  000.714: sourcing /Users/gmile/.config/nvim/bundle/ctrlp.vim/plugin/ctrlp.vim
046.422  000.252  000.252: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/autoload/nerdtree.vim
048.782  000.942  000.942: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/path.vim
049.114  000.194  000.194: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/menu_controller.vim
049.369  000.128  000.128: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/menu_item.vim
049.667  000.174  000.174: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/key_map.vim
050.119  000.327  000.327: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/bookmark.vim
050.614  000.366  000.366: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/tree_file_node.vim
051.352  000.609  000.609: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/tree_dir_node.vim
051.804  000.325  000.325: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/opener.vim
052.305  000.375  000.375: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/creator.vim
052.508  000.078  000.078: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/flag_set.vim
052.854  000.222  000.222: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/nerdtree.vim
053.487  000.509  000.509: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/ui.vim
053.649  000.039  000.039: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/event.vim
053.834  000.061  000.061: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/lib/nerdtree/notifier.vim
054.655  000.683  000.683: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/autoload/nerdtree/ui_glue.vim
073.828  000.105  000.105: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/nerdtree_plugin/exec_menuitem.vim
074.550  000.647  000.647: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/nerdtree_plugin/fs_menu.vim
074.818  029.507  023.470: sourcing /Users/gmile/.config/nvim/bundle/nerdtree/plugin/NERD_tree.vim
075.021  000.048  000.048: sourcing /Users/gmile/.config/nvim/bundle/rust.vim/plugin/rust.vim
079.319  004.125  004.125: sourcing /Users/gmile/.config/nvim/bundle/vim-fugitive/plugin/fugitive.vim
080.113  000.219  000.219: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/gzip.vim
080.175  000.013  000.013: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/health.vim
080.282  000.064  000.064: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/man.vim
080.914  000.587  000.587: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/matchit.vim
081.153  000.192  000.192: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/matchparen.vim
081.705  000.496  000.496: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/netrwPlugin.vim
081.850  000.080  000.080: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/rplugin.vim
081.922  000.016  000.016: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/rrhelper.vim
082.106  000.123  000.123: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/shada.vim
082.204  000.035  000.035: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/spellfile.vim
082.439  000.175  000.175: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/tarPlugin.vim
082.610  000.112  000.112: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/tohtml.vim
082.693  000.029  000.029: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/tutor.vim
082.961  000.215  000.215: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/plugin/zipPlugin.vim
083.052  002.603: loading plugins
083.263  000.210: loading packages
083.273  000.010: inits 3
087.346  004.073: reading ShaDa
090.208  002.861: clearing screen
095.523  000.683  000.683: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/scripts.vim
2901.355  2805.314  2805.314: sourcing /Users/gmile/.config/nvim/bundle/vim-fish/ftplugin/fish.vim
2902.246  000.050  000.050: sourcing /Users/gmile/.config/nvim/bundle/vim-fish/indent/fish.vim
2902.771  000.169  000.169: sourcing /Users/gmile/.config/nvim/bundle/vim-fish/syntax/fish.vim
2905.582  000.294  000.294: sourcing /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/autoload/remote/host.vim
2906.201  000.193  000.193: sourcing /Users/gmile/.config/nvim/bundle/ctrlp.vim/autoload/ctrlp/utils.vim
2907.541  010.630: opening buffers
2907.599  000.058: BufEnter autocommands
2907.605  000.006: editing files in windows
2908.033  000.427: VimEnter autocommands
2908.035  000.002: before starting main loop
2913.764  005.729: first screen update
2913.767  000.003: --- NVIM STARTED ---
$
@babakness
Copy link

@babakness babakness commented Jul 26, 2017

Mind blowingly slow for me, wow. Any direction on how to improve the load time?

@gmile
Copy link

@gmile gmile commented Jul 26, 2017

@babakness can you run vim with --startuptime flag like this:

vim --startuptime vim.log some_file.txt

And post here the contents of vim.log?

In my case I have solved the problem after I noticed incorrectly configured fish, specifically the usage of fish_user_paths fish's function.

@babakness
Copy link

@babakness babakness commented Jul 26, 2017

@gmile
Sure, relevant bits here:

065.290  000.046: setting raw mode
065.294  000.004: start termcap
065.313  000.019: clearing screen
074.441  001.215  001.215: sourcing /usr/local/share/vim/vim80/scripts.vim
5024.670  4950.498  4950.498: sourcing /Users/me/.vim/bundle/vim-fish/ftplugin/fish.vim
5025.775  000.068  000.068: sourcing /Users/me/.vim/bundle/vim-fish/indent/fish.vim
5026.555  000.195  000.195: sourcing /Users/me/.vim/bundle/vim-fish/syntax/fish.vim
5027.115  010.826: opening buffers
5027.171  000.056: BufEnter autocommands
5027.176  000.005: editing files in windows
5027.498  000.322: VimEnter autocommands
5027.499  000.001: before starting main loop
5028.096  000.597: first screen update
5028.097  000.001: --- VIM STARTED ---
@babakness
Copy link

@babakness babakness commented Jul 26, 2017

similar issue with nvim. Both installed via brew on mac.

@gmile
Copy link

@gmile gmile commented Jul 26, 2017

@babakness can you run this:

fish -p profile.txt -c 'echo "Hello, world!"'

And post the contents of profile.txt?

@mpcsh
Copy link

@mpcsh mpcsh commented Oct 19, 2017

I'm just starting out with fish and I had this problem too. My config.fish only had the following line:

brew command command-not-found-init > /dev/null 2>&1; and . (brew command-not-found-init)

Removing it caused vim-fish to launch smoothly.

@keyboard-clacker
Copy link
Author

@keyboard-clacker keyboard-clacker commented Oct 19, 2017

Talk about specific lol. That seems unrelated to this plugin, I wanna say...

@keyboard-clacker
Copy link
Author

@keyboard-clacker keyboard-clacker commented Oct 19, 2017

I'm closing this, as I've had my issue solved. Thank you @ElijahLynn !

@dag
Copy link
Owner

@dag dag commented Nov 22, 2017

Reopening because others reported slowness as well, but didn't report it being solved.

I would guess the slowness comes either from executable() having to search all of $PATH, although that should still be pretty much instant, it happens any time you type an unknown command into the shell; or from calling out to fish with system() to get $fish_function_path, which will run all your fish config.

Those of you experiencing slowness: is fish itself similarly slow to start?

@dag dag reopened this Nov 22, 2017
@gmile
Copy link

@gmile gmile commented Nov 22, 2017

Just a 5 cents: it is very likely that people use fish_user_path incorrectly. I've ran into this very problem and solved it by reading more about how to use fish_user_path.

When in need to add something to path, instead of doing this (which I did and which was wrong):

set fish_user_paths $fish_user_paths /new/path

One must do this:

set fish_user_paths /new/path
set fish_user_paths /new/path /another/new/path /and/another/one

fishshell listens for changes to $fish_user_paths variable, and does what has to be done to update $PATH.

I recognized this specifically by running benchmarks built into vim and fish, and inspecting the output. In my case there were tons and tons of fish_user_paths calls. Here's how to benchmark:

  • in vim:
    vim --startuptime vim.log some_file.txt
    
  • in fish:
    fish -p profile.txt -c 'echo "Hello, world!"'
    
@dag
Copy link
Owner

@dag dag commented Nov 22, 2017

Hmm, fish_function_path is not the same as fish_user_paths.

@gmile
Copy link

@gmile gmile commented Nov 22, 2017

@dag good point, I mistyped that! Updated the comment to have fish_function_path removed. Thank you for spotting!

@dag
Copy link
Owner

@dag dag commented Nov 22, 2017

Ah you mean, this might be causing executable() to be slow for people? I thought you were saying it was making the system() call slow, but that you were confusing the issue.

@gmile
Copy link

@gmile gmile commented Nov 22, 2017

Yes, I think it is executable() that's slow for people. It was for me.

@ypresto
Copy link

@ypresto ypresto commented Jan 4, 2018

I found system("fish -c 'echo $fish_function_path'") is slow, but still calling fish -c 'echo $fish_function_path from shell is not slow.

@dag
Copy link
Owner

@dag dag commented Jan 5, 2018

@ypresto Have you tried the suggestion at the bottom of the readme?

Also, have you tried calling that fish -c line from a shell other than fish?

@squattingmonk
Copy link

@squattingmonk squattingmonk commented Jan 7, 2018

I had uninstalled this plugin due to the same issue. However, I had also been noticing that the startup time for fish shell itself was getting longer and longer. I found that I was incorrectly setting fish_user_paths as as @gmile had mentioned. This was causing the variable to bloat over time (tens of thousands of directories long). Removing this and then re-installing the plugin seems to have fixed both issues.

@ypresto
Copy link

@ypresto ypresto commented Jan 9, 2018

@dag Thanks, set shell=sh resolved my issue..!
Moreover, start up time of entire vim got faster!
(echo &shell was /bin/zsh).

@ypresto
Copy link

@ypresto ypresto commented Jan 10, 2018

hmm, I found it is still slow when I put anyenv init code in config.fish:

eval (anyenv init - fish | source)

When I put sleep 5 it tooks 5 secs to open config.fish file with vim.

@chemzqm
Copy link

@chemzqm chemzqm commented Oct 8, 2018

There is job for vim & neovim could be used to avoid the block running system command.

@zdcthomas
Copy link

@zdcthomas zdcthomas commented Jul 17, 2019

I'm definitely still experiencing slowness. After profiling, I was able to narrow down the problem to ftplugin but beyond that, I'm not sure. I've also tried the suggestion of set shell=sh which sped up vim in general but didn't make much of a difference to vim-fish startup time.
As a side note, is this repo still being maintained? I'd love to help with it in any way I can

@jooize
Copy link

@jooize jooize commented May 24, 2020

Takes 3 seconds longer to start Neovim when opening a file of filetype fish with vim-fish enabled. Instant when starting same configuration from Zsh or Bash, so let me see….

In my case it seems to be because my Fish is slow at startup (because of something in my configuration, apparently), and Fish is for some reason called by vim-fish even when I specify set shell=sh in Neovim's init.vim as the top to be sure it has an effect on plugins.

Workaround (with reduced functionality): I commented out every system() and execute in $HOME/.local/share/dein/repos/github.com/dag/vim-fish/*/*, then fought the cache of Dein, somehow eventually successfully.

Solution (for me): Clean up $fish_user_paths and properly set it (if at all). fish-shell/fish-shell#5834 (comment) Edit $XDG_CONFIG_HOME/fish/config.fish and make changes according with comments, then erase all of $fish_user_paths by running set --erase --universal fish_user_paths and then restart Fish.

@blankname
Copy link

@blankname blankname commented May 24, 2020

@jooize

vim-fish always calls fish to get the value of $fish_function_path on startup.

I attempted @chemzqm's suggestion if you'd like to try it out:
blankname/pull/3

If all of the cases of this slowness are traced to misconfiguration of fish, I probably won't merge it.

@jooize
Copy link

@jooize jooize commented May 25, 2020

Is there any chance running the job in the background results in undesired behavior?

@blankname
Copy link

@blankname blankname commented May 25, 2020

If something uses path before the job has finished it won't contain the $fish_function_path directories.

Vim's docs have some things that use path listed:
image

Plugins may also use path.

The worry is that this change might be added complication to solve a problem that's better solved outside of vim through fish configuration fixes.

@jooize
Copy link

@jooize jooize commented May 25, 2020

It seems the reason we're evaluating job_start should be solved without it. Asynchronous startup can be a worthy pursuit, but in this case I agree that it appears worse to make that change.

I actually hadn't fixed my problem with $fish_user_paths, but learned how with some help over at fish-shell/fish-shell#5834 (comment).

Thank you for your time, @blankname.

@lamchau
Copy link

@lamchau lamchau commented Jun 2, 2020

my performance issues ended up being a misconfigured $fish_user_paths in my config.fish.

simple fix for me was to do the following:

  • removed the offending line (e.g. set fish_user_paths $fish_user_paths /some/path)
  • then ran this
echo $fish_user_paths > ~/fish_user_paths.bak
set updated_paths (echo $fish_user_paths | tr " " "\n" | sort -r | uniq)
echo $updated_paths | tr " " "\n" | nl

set --universal fish_user_paths $updated_paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.