]> git.ipfire.org Git - thirdparty/kmod.git/commit
depmod: Stop opening modules.modinfo once per module
authorLucas De Marchi <lucas.demarchi@intel.com>
Thu, 10 Feb 2022 02:07:03 +0000 (18:07 -0800)
committerLucas De Marchi <lucas.demarchi@intel.com>
Sat, 12 Feb 2022 06:06:34 +0000 (22:06 -0800)
commit0246e06340df292b5dda4bc00e24cc9ae894e881
treef91f4fa438fbc3bba8a27085378ffe862575cf84
parent7a0f593de3bef04b8f8d35e51f76995d0493d007
depmod: Stop opening modules.modinfo once per module

Since the addition of modules.aliases.bin, depmod has to open that
index multiple times and parse it over and over again:

$ sudo strace -e openat  ./tools/depmod 2>&1 | grep modules.builtin.modinfo  | wc -l
299
$ time sudo  ./tools/depmod
real    0m7.814s
user    0m7.571s
sys     0m0.237s

Rework the logic in depmod so it does everything: open, read and parse. The
format is very straightforward and we don't need to keep it in a data structure
since we only want to add the result to a index. New output:

$ sudo strace -e openat  ./tools/depmod 2>&1 | grep modules.builtin.modinfo  | wc -l
1
$ time sudo  ./tools/depmod
real    0m7.663s
user    0m7.516s
sys     0m0.139s

Indexes still match:

$ cmp /tmp/modules.builtin.alias.bin.new
/tmp/modules.builtin.alias.bin.old; echo $?
0

Fix: https://github.com/kmod-project/kmod/issues/11
tools/depmod.c