[Bug 796317] [NEW] long bash startup when ubuntu-dev-tools installed due to slow bash completion code
ilia
796317 at bugs.launchpad.net
Sun Jun 12 19:52:53 UTC 2011
Public bug reported:
Binary package hint: ubuntu-dev-tools
I've noted that sometimes I need to wait relatively long time for bash
to start, especially after system start and login or resume from
suspend, but may also happen after some heavy disk load (e.g. `grep -r
foo /usr`). I've profiled bash startup with strace and found the
following.
/etc/bash_completion.d/pbuilder-dist executes ubuntu-distro-info and debian-distro-info in function _pbuilder-aliases():
...
for distro in $(ubuntu-distro-info --all; debian-distro-info --all) stable testing unstable experimental; do
...
ubuntu-distro-info (as well as debian-distro-info) is a python program and when disk cache is cold (i.e. actual disk read is required for ) its invocation takes __4 seconds__ (on my 1 year old laptop). The problem is not in ubuntu-distro-info, but in the fact that _pbuilder-aliases (and consequently ubuntu-distro-info) is invoked at each interactive bash startup as part of bash_completion load:
...
[ "$have" ] && complete -F _pbuilder-dist -o filenames pbuilder-dist cowbuilder-dist $(_pbuilder-aliases)
...
Expensive python invocation $(ubuntu-distro-info --all; debian-distro-info --all) can be replaced by sed, which is in FS cache since it's used by many other places during bash startup:
$(sed -ns '2,$s/^[^,]*,[^,]*,\([^,]*\),.*/\1/p' /usr/share/ubuntu-dev-tools/ubuntu.csv /usr/share/ubuntu-dev-tools/debian.csv)
Moreover, ubuntu.csv and debian.csv are changed very rarely. There is no reason to parse them on each interactive bash invocation, especially with python. It would be much faster to use the actual list of codenames in /etc/bash_completion.d/pbuilder-dist, e.g.:
...
for distro in \
warty hoary breezy dapper edgy feisty gutsy hardy intrepid jaunty karmic \
lucid maverick natty oneiric \
buzz rex bo hamm slink potato woody sarge etch lenny squeeze wheezy sid \
stable testing unstable experimental
do
...
The list is so rarely changed that it can be even edited manually by the
package maintainer, but you may consider generating it from CVSs when
building a package. And since we talk here about optimizations, the
whole result of _pbuilder-aliases() is as static as the said list, so
there is no need to run 3 nested loops each time -- run them on package
build and paste the result.
** Affects: ubuntu-dev-tools (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of MOTU,
which is subscribed to ubuntu-dev-tools in Ubuntu.
https://bugs.launchpad.net/bugs/796317
Title:
long bash startup when ubuntu-dev-tools installed due to slow bash
completion code
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-dev-tools/+bug/796317/+subscriptions
More information about the universe-bugs
mailing list