[Bash-completion-devel] Bug#733815: Modules completion takes a very long time
auil at usp.br
auil at usp.br
Wed Jan 1 02:10:30 UTC 2014
Thanks for your message.
> I find it useful
> to have modprobe default to listing only modules that are NOT loaded
> yet.
For the default use, when loading a module, this is the case. The
command modprobe has also an "-r" option to unload the module,
and in this case it would complete to the already loaded modules.
To fix the slowness issue you can just remove the "-L" option from command "ls".
I try this and it works. I try also your code and works too.
I can't say how long it would take to complete on debian following
a bunch of symlinks
There are just 2 symlinks. But they point to the kernel (compilated) source
directory, which has a size of 5 GB. Hence, listing this directory twice takes
a lot of time.
<blockquote>
but on my system, it takes about a tenth of a second
to come up with a list of 376 possible modules on my system, so unless
there is something odd about the list on debian, it might be faster..?
</blockquote>
In my system I have 2542 modules:
$ _clean_n_sort_mods | wc -l
2543
The number 2543 is because this function also matches an emtpy line at
the beginning. This is the performance of the function
$ time _clean_n_sort_mods >/dev/null
real 0m0.130s
user 0m0.085s
sys 0m0.042s
Note that when I use this
function _clean_n_sort_mods {
find /lib/modules/$(uname -r) -type f -name \*.ko | sed 's|.*/||g;s|[.]ko$||'
}
I get
$ time _clean_n_sort_mods >/dev/null
real 0m0.021s
user 0m0.024s
sys 0m0.009s
For the second function I get
$ time _loaded_mods > /dev/null
real 0m0.011s
user 0m0.001s
sys 0m0.011s
Note that this function uses 3 commands (lsmod, tail and sed).
When I use this
function _loaded_mods {
awk '{print $1}' /proc/modules
}
I get
$ time _loaded_mods > /dev/null
real 0m0.002s
user 0m0.001s
sys 0m0.001s
In the function _newmods you can replace the pipe "sort | uniq -u" by the single command "sort -u".
Regards,
FA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/bash-completion-devel/attachments/20140101/2e11de70/attachment-0003.html>
More information about the Bash-completion-devel
mailing list