i'm just wondering why in all linux boxs , lsb_release take longer time to print few infos about distro,
anyone could enlighten me about this fact ? please.
Asked
Active
Viewed 172 times
1
Yunus
- 1,634
- 2
- 13
- 19
-
Have a look by yourself. /usr/bin/lsb_release is a python program, you can edit it with vi – Rui F Ribeiro Jan 11 '16 at 13:20
-
does that mean a python program execution is normally slower ? beacause i don't know about python language :) – Yunus Jan 11 '16 at 13:34
1 Answers
4
Printing a few bytes isn't the difficult part. The difficult part is finding what bytes should be printed. To do that, lsb_release needs to analyze many system files. You can see where it's spending time in I/O by tracing its system calls:
strace -f -tt -T -o lsb_release.strace lsb_release
On my machine, about 1/3 of the time is spent executing the command
dpkg-query -f '${Version} ${Provides}\n' -W lsb-core lsb-cxx lsb-graphics lsb-desktop lsb-languages lsb-multimedia lsb-printing lsb-security
which parses the database of installed packages. There isn't another significant I/O consumer.
Since this is a Python script, you can also use the Python profiler to get an idea of where it's spending time:
python -m cProfile
This isn't very revealing to me, the biggest time consumers are related to the initialization of the script (it does use quite a few libraries) and to the invocation of the dpkg subprocess.
Gilles 'SO- stop being evil'
- 807,993
- 194
- 1,674
- 2,175