joseluisq/gitnow

Slow startup

petertriho opened this issue · 16 comments

source $__fish_data_dir/completions/git.fish in __gitnow_completions.fish seems to cause my start up to be really slow. After commenting out this line, it starts up just fine

What version are you using?

fish v3.2.0
gitnow v2.8.0

I tried manually sourcing the git completion file and it also takes a while to load.
I seem to get completion with git just fine without sourcing the file though so I'm not sure if it's necessary

Can you share please stats output of this simple test?

In my case this is a test on a Macos

$ fish -v
# fish, version 3.2.0
$  time fish -c "gitnow -v"
# GitNow version 2.8.0
# 
# ________________________________________________________
# Executed in  112.50 millis    fish           external
#   usr time   91.05 millis  179.00 micros   90.87 millis
#   sys time   21.20 millis  470.00 micros   20.73 milli

Also take a look to this thread #23

❯ fish -v
fish, version 3.2.0
❯ time fish -c "gitnow -v"
GitNow version 2.8.0

________________________________________________________
Executed in  583.12 millis    fish           external
   usr time  127.23 millis   93.00 micros  127.14 millis
   sys time   40.46 millis   93.00 micros   40.37 millis

I believe my issue is different to #23, the slow start up is coming from sourcing the git completion file

❯ time fish -c "gitnow -v"
GitNow version 2.8.0

________________________________________________________
Executed in  161.43 millis    fish           external
   usr time   28.20 millis  178.00 micros   28.02 millis
   sys time   38.84 millis    0.00 micros   38.84 millis

With source $__fish_data_dir/completions/git.fish in __gitnow_completions.fish removed

$ fish -v
# fish, version 3.2.0
$  time fish -c "gitnow -v"
# GitNow version 2.8.0
# 
# ________________________________________________________
# Executed in  112.50 millis    fish           external
#   usr time   91.05 millis  179.00 micros   90.87 millis
#   sys time   21.20 millis  470.00 micros   20.73 milli

But in my case this is with Git completions.

Just to confirm Can you share your CPU specs because the other user issue was because I couldn't reproduce his issue due to my CPU specs were higher than his one.

BTW source $__fish_data_dir/completions/git.fish is not faster but it should not be too slow than:

time fish -c "source $__fish_data_dir/completions/git.fish"

________________________________________________________
Executed in  158.19 millis    fish           external
   usr time  126.89 millis  150.00 micros  126.74 millis
   sys time   30.50 millis  371.00 micros   30.13 millis

I have a Intel i7 8700k. This is through WSL2 so that could be the issue but I also have the same issue on a MBP15 2018

Well I can not say so much about using Fish via WSL2 but the slow issue is a bit weird and "probably" because your virtualization environment. Or Fish Git completions need some kind of optimization.

BTW I did the test above in a iMac Core i5 3,4 GHz and using the same fish 3.2.0

And this is a test in my Linux workstation (Intel Core i7 2.5GHz) but using Fish 3.1.2 with latest Gitnow.

$ fish -v
fish, version 3.1.2
$ time fish -c "gitnow -v"
GitNow version 2.8.0
________________________________________________________
Executed in   88,44 millis    fish           external 
   usr time   80,78 millis  1121,00 micros   79,66 millis 
   sys time   10,12 millis  219,00 micros    9,90 millis

BTW as I said the Fish Git completions are not "too fast" (#23 (comment)) but I should not compromise startup.

I got it!

Gitnow with completions

image

Gitnow without completions

gitnow-git-complisions-wsl-2

Yes, Gitnow, Git completions also Fish itself runs very slow in WSL2.
So I will close the issue since there is nothing that Gitnow can do about it.

@joseluisq would it be possible to add variables to skip the config and sourcing git completions? Something like GITNOW_SKIP_KEYBINDINGS and GITNOW_SKIP_GIT_COMPLETIONS. Possibly only sourcing the git completion file on demand?

It could be a new feature to opt-in that via the .gitnow file so I'm open to some PR for.