bash_completion
Par Benoît Dejean le vendredi, 20 avril 2007, 11:01 - Lien permanent
I am a big fan of the bash completion feature but i recently discovered it has a cost : my bash heap is 3536KiB.
This looks big because I often run more than 10 shells.
So i tried -norc --noprofile and heap was then 932KiB, more decent. Just for fun, I straced bash and discovered that it was sourcing twice /etc/bash_completion and as there is nothing to prevent it from being reloaded, it really loads and process twice the same completion files. I checked my /etc/bash.rc and ~/.bashrc and they were both . /etc/bash_completion.
I've fixed my ~/.bashrc and bash heap is now 2232KiB. x10 so it actually saves up to 10MiB of memory on my system: yahoo !
Commentaires
10MiB?
bash_completion also slows down the shell startup, which is noticeable when you open a new terminal and want to type straight away.
I've created a subset of /etc/bash_completion in ~ containing only the commands I need most.
bash_completion is broken by design.
It tries to parse itself at run time because it ignores the
complete -o plusdirs
option bash3, it tries to implement that by loading itself twice.
Barf.
Delete that stuff and the slowdown should be mostly gone.
USE zsh!