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
Bash completion slows down bash login sessions #3889
Comments
Thanks for reporting; this looks to be related to changes that were made in the completion script in https://github.com/docker/cli (#3752). Let me transfer this ticket to the CLI issue tracker (I know some improvements were made after that, but not sure if they can be included in the 20.10 version) |
Did a quick comparison; # on docker 20.10;
time $(docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "compose"}}{{.Path}}{{end}}{{end}}')
real 0m1.034s
user 0m0.130s
sys 0m0.094s
# on docker 23.0.0-dev
time $(docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "compose"}}{{.Path}}{{end}}{{end}}')
real 0m0.196s
user 0m0.136s
sys 0m0.048s |
That's a big improvement, but 0.20 s is still pretty long. If every completion file took that long time, the result would be unbearable. Could the call to |
💀 $ docker --version
Docker version 20.10.21, build baeda1f
$ hyperfine --warmup=1 /usr/local/etc/bash_completion.d/docker
Benchmark 1: /usr/local/etc/bash_completion.d/docker
Time (mean ± σ): 342.8 ms ± 18.5 ms [User: 161.4 ms, System: 124.2 ms]
Range (min … max): 308.6 ms … 371.8 ms 10 runs |
☠️ $ docker --version
Docker version 23.0.5, build bc4487a
📁~/
$ hyperfine --warmup=1 /usr/local/etc/bash_completion.d/docker
Benchmark 1: /usr/local/etc/bash_completion.d/docker
Time (mean ± σ): 223.4 ms ± 13.0 ms [User: 247.5 ms, System: 200.1 ms]
Range (min … max): 206.1 ms … 238.9 ms 13 runs |
The setting of Why is it done during initialization of every single session instead of only as needed? If Regardless, this should be removed. |
Fixes issue docker#3889 by only loading docker plugins path when needed: if it is fast enough than it shouldn't be a problem to do this on demand; OTOH if it is slow then we shouldn't do this during *every* bash session initialization, regardless if docker completion will be needed or not.
I offered a PR #4505 to move that plugins path reading to where it should be. |
Fixes issue docker#3889 by only loading docker plugins path when needed: if it is fast enough than it shouldn't be a problem to do this on demand; OTOH if it is slow then we shouldn't do this during *every* bash session initialization, regardless if docker completion will be needed or not. Signed-off-by: Oded Arbel <oded@geek.co.il>
Fixes issue docker#3889 by only loading docker plugins path when needed: if it is fast enough than it shouldn't be a problem to do this on demand; OTOH if it is slow then we shouldn't do this during *every* bash session initialization, regardless if docker completion will be needed or not. Signed-off-by: Oded Arbel <oded@geek.co.il>
Fixes issue docker#3889 by only loading docker plugins path when needed: if it is fast enough than it shouldn't be a problem to do this on demand; OTOH if it is slow then we shouldn't do this during *every* bash session initialization, regardless if docker completion will be needed or not. Signed-off-by: Oded Arbel <oded@geek.co.il> (cherry picked from commit 1da67be) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Fixes issue docker#3889 by only loading docker plugins path when needed: if it is fast enough than it shouldn't be a problem to do this on demand; OTOH if it is slow then we shouldn't do this during *every* bash session initialization, regardless if docker completion will be needed or not. Signed-off-by: Oded Arbel <oded@geek.co.il> (cherry picked from commit 1da67be) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Fixes issue docker#3889 by only loading docker plugins path when needed: if it is fast enough than it shouldn't be a problem to do this on demand; OTOH if it is slow then we shouldn't do this during *every* bash session initialization, regardless if docker completion will be needed or not. Signed-off-by: Oded Arbel <oded@geek.co.il> (cherry picked from commit 1da67be) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Expected behavior
bash_completion.d/docker
should be fast to execute. It probably should not make anydocker
calls until actually needed.Actual behavior
Executing the bash completion script causes a noticeable pause when opening new bash sessions.
The slowest part is a call to
docker
:This seems to be:
Information
Output of
/Applications/Docker.app/Contents/MacOS/com.docker.diagnose check
N/A
Steps to reproduce the behavior
Open a new bash login session.
To visually see what is taking up time:
The text was updated successfully, but these errors were encountered: