[Bash-completion-devel] After adding bash-completion to .bashrc loading prompt is slow
Ville Skyttä
ville.skytta at iki.fi
Tue Apr 5 16:47:53 UTC 2011
On 04/05/2011 09:36 AM, David Paleino wrote:
> real 0m10.734s
> user 0m0.752s
> sys 0m0.224s
Ouch :(. But on the other hand, with numbers like that, real
improvements should be easily noticeable/measurable.
> The latest fixes by Ville, while theoretically, didn't give me a speed-up (at
> all, but I tried only once, thus I suspect it's more-or-less the same):
For my tests, I ran them each 5+ times and compared the times I thought
were representative. The savings were consistent on both boxes when
comparing the representative numbers, but the slower box had quite a bit
of variance in its results across runs both before and after the
changes; no idea why.
> I'll check which third-party completion is being so slow for me (and eventually
> report bugs where appropriate).
Just a thought, I haven't actually checked how bash behaves under the
hood: if loading the completions on your system is heavily I/O bound,
and the changes I made (have foo || return) just help with the CPU
pressure, the savings won't be that noticeable.
Can you find out whether the loading process is CPU or I/O bound on your
system?
FWIW both the systems I tested with have their filesystems mounted with
noatime (one has ext4, the other ext3). That might be worth trying out
if you don't already have it.
> While we should really fix this upstream
I agree.
> (can't tell how though),
What I'm going to experiment with next is getting a list of all commands
available on the system at start of bash_completion, and making have()
look up from that list instead of doing the "type" for them.
> For
> Debian-based systems I'm thinking at some post-installation hook, which checks
> what's been installed in $PATH, and makes appropriate links to $BASH_COMP_DIR.
> I'll need to think this better though.
I don't know if Debian has a concept of package triggers, but that
mechanism works pretty well for rpm based systems in this case. E.g.
"when you install package foo, we know/assume it will contain these
commands, symlink their completions to BASH_COMPLETION_DIR" and
similarly for package removals.
Here's the current Fedora specfile for reference:
http://pkgs.fedoraproject.org/gitweb/?p=bash-completion.git;a=blob;f=bash-completion.spec
More information about the Bash-completion-devel
mailing list