-
-
Notifications
You must be signed in to change notification settings - Fork 26k
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
Loading kubectl plugin is slow #6843
Comments
I'm using kubectl plugin and every morning start terminal it's been hang up about 5 minute.
|
@lbolla I don't think, it is completely fixed or something else is wrong with my setup? That is on every new tab in Iterm. But on existing tab, it's not taking much. |
Avoid it by doing lazy load. function kubectl() {
if ! type __start_kubectl >/dev/null 2>&1; then
source <(command kubectl completion zsh)
fi
command kubectl "$@"
} as mentioned here |
Do you have custom zsh cache settings? kubectl speedup works by caching a file in $ZSH_CACHE_DIR and skipping |
@lbolla I don't have any custom zsh cache settings. yes I do have the cached file in $ZSH_CACHE_DIR |
Experienced the same on Fedora, the cache doesn't help because the slow part here is execution of function Upstream issue: kubernetes/kubernetes#59078 |
...and if I understand correctly, the lazy loading trick doesn't help either because sourcing the cached |
any news on improvements here?
|
I am having the same problem in Mac OSX Catalina 10.15.7 since yesterday when I updated via The debug startup freezes for some seconds in the following lines:
|
Anyone interested in submitting a PR for this? |
Running the speed test from https://blog.mattclemente.com/2020/06/26/oh-my-zsh-slow-to-load/#how-to-test-your-shell-load-time, ➜ ~ for plugin ($plugins); do
timer=$(($(date +%s%N)/1000000))
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
fi
now=$(($(date +%s%N)/1000000))
elapsed=$(($now-$timer))
echo $elapsed ms":" $plugin
done
22 ms: git
17 ms: fzf
7 ms: tmux
239 ms: kubectl
2 ms: docker |
I tried this on my Mac (using
After investigating I noticed that the zsh plugin for kubectl uses a cache:
which was two years old and using the old kubectl completion logic.
I took this opportunity to empty that cache for other plugins 😄 |
Oh and you need to use kubectl 1.22 or higher for the faster zsh completion logic. |
Thank you very much @marckhouzam!! It works 🥳 ➜ ~ ls -l ${ZSH_CACHE_DIR}/kubectl_completion
-rw-r--r-- 1 eric users 459559 Mar 6 2021 /home/eric/.oh-my-zsh/cache/kubectl_completion
➜ ~ kubectl version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.3", GitCommit:"c92036820499fedefec0f847e2054d824aea6cd1", GitTreeState:"archive", BuildDate:"2021-10-28T06:55:39Z", GoVersion:"go1.17.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.2", GitCommit:"8b5a19147530eaac9476b0ab82980b4088bbc1b2", GitTreeState:"clean", BuildDate:"2021-09-15T21:32:41Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/amd64"}
➜ ~ for plugin ($plugins); do
timer=$(($(date +%s%N)/1000000))
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
fi
now=$(($(date +%s%N)/1000000))
elapsed=$(($now-$timer))
echo $elapsed ms":" $plugin
done
37 ms: git
25 ms: fzf
3 ms: tmux
4 ms: kubectl
1 ms: docker
➜ ~ |
This was fixed in 658eb01 |
The main reason is that it regenerates the completion script over and over, with
kubectl completion zsh
.The text was updated successfully, but these errors were encountered: