2

I'm currently considering breaking down one of my libraries in some 20 Debian sub-projects. Each part is already pretty much a standalone bit in the existing large library.

What I'm wondering is the impact at runtime. Will my software be impacted by the fact that they'll have to load more libraries? I think it won't because right now it has to generate all the entry points for a very large number of functions when with smaller libraries many parts will probably end up hidden (i.e. library A needs library B, so A needs to setup the pointers to access B. However, a program P needs A but it won't directly access B, so it saves the time of initializing B's pointers, which it does now since A and B are together in the shared library.)

Of course there are pros and cons to all of that. Many Debian projects is many packages to maintain. Not a small task when I have just one now for that large library. At the same time, I am thinking that much of my code could be reused in other projects if only those smaller parts where made into separate packages.

So my main worry at this point is: will there be a noticeable change in starting my process P when I have 20 smaller libraries instead of one large one?

  • Whatever you do, don't try to turn apt into npm. – whatsisname May 10 at 16:22
5

For something like this to matter, you would be talking about a process that spawns a lot... Well, in that case, these libraries would be loaded to begin with. If it is something that only lives once, then a detail like startup time(where linking potentially could matter) isn't going to make much of a difference. In practice I think the cases where this could matter are also the cases where you benefit from the dynamic links.

$ ldd php
linux-vdso.so.1 (0x00007ffc395f2000)
libargon2.so.1 => /lib/x86_64-linux-gnu/libargon2.so.1 (0x00007fc3a99cc000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fc3a99b1000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fc3a9995000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fc3a9921000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc3a97d3000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fc3a97cd000)
libxml2.so.2 => /lib/x86_64-linux-gnu/libxml2.so.2 (0x00007fc3a9623000)
libssl.so.1.1 => /lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007fc3a9593000)
libcrypto.so.1.1 => /lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007fc3a92c5000)
libsodium.so.23 => /lib/x86_64-linux-gnu/libsodium.so.23 (0x00007fc3a926f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc3a9084000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc3a9063000)
/lib64/ld-linux-x86-64.so.2 (0x00007fc3a9ed7000)
libicuuc.so.63 => /lib/x86_64-linux-gnu/libicuuc.so.63 (0x00007fc3a8e92000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fc3a8e6b000)
libicudata.so.63 => /lib/x86_64-linux-gnu/libicudata.so.63 (0x00007fc3a747b000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fc3a729a000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fc3a7280000)

These are the dynamic links for the current version of php. The standard way the php binary works is that is that a process is created to compute a script, and then dies. It links to 19 libraries. So if this detail were to matter, it would be noticed and optimized for already, a lot of work has gone to optimizing this stuff. There is no process that gets to live and die as frequently as php, really. There is no measurable time difference between a statically compiled version of php and the dynamic one. In this case a good chunk of them are common system stuff anyway, so they are going to be already loaded and it just doesn't make much sense to compile it statically.

Anyway, my point is, even if it matters, 20 is not that number. Having 20 linked libraries is really common.

Here is an answer from stackoverflow, https://stackoverflow.com/questions/4667882/is-a-statically-linked-executable-faster-than-a-dynamically-linked-executable -- The answer seems Windows focused, Linux is of course far ahead of the game with how the concept of a proc is applied. I would be surprised if you could find a benchmark where this makes a difference(in favor of static libs), without trying to find a limit for this explicitly. I wager, the project itself would become unmanageable before the dynamic link count starts to matter.

Sorry I can't find any hard numbers, but to even just test something like this it would require some setup where you would be testing a case that wouldn't be a reasonable case in practice.

ffmpeg links to ~200 libraries and there is no significant startup time for it. It could to link more too if I compile it myself with more codecs, this is just the distro version.

Whatever the point is where you can start to notice a slowdown, is a number you wouldn't reasonably need.

$ ldd ffmpeg
linux-vdso.so.1 (0x00007ffed4b16000)
libavdevice.so.58 => /lib/x86_64-linux-gnu/libavdevice.so.58 (0x00007f55b0634000)
libavfilter.so.7 => /lib/x86_64-linux-gnu/libavfilter.so.7 (0x00007f55b0311000)
libavformat.so.58 => /lib/x86_64-linux-gnu/libavformat.so.58 (0x00007f55b00ac000)
libavcodec.so.58 => /lib/x86_64-linux-gnu/libavcodec.so.58 (0x00007f55aeb68000)
libavresample.so.4 => /lib/x86_64-linux-gnu/libavresample.so.4 (0x00007f55aeb45000)
libpostproc.so.55 => /lib/x86_64-linux-gnu/libpostproc.so.55 (0x00007f55aeb26000)
libswresample.so.3 => /lib/x86_64-linux-gnu/libswresample.so.3 (0x00007f55aeb03000)
libswscale.so.5 => /lib/x86_64-linux-gnu/libswscale.so.5 (0x00007f55aea6e000)
libavutil.so.56 => /lib/x86_64-linux-gnu/libavutil.so.56 (0x00007f55ae9ee000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f55ae8a0000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f55ae87f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f55ae694000)
libraw1394.so.11 => /lib/x86_64-linux-gnu/libraw1394.so.11 (0x00007f55ae483000)
libavc1394.so.0 => /lib/x86_64-linux-gnu/libavc1394.so.0 (0x00007f55ae27e000)
librom1394.so.0 => /lib/x86_64-linux-gnu/librom1394.so.0 (0x00007f55ae079000)
libiec61883.so.0 => /lib/x86_64-linux-gnu/libiec61883.so.0 (0x00007f55ae06b000)
libjack.so.0 => /lib/x86_64-linux-gnu/libjack.so.0 (0x00007f55ae022000)
libdrm.so.2 => /lib/x86_64-linux-gnu/libdrm.so.2 (0x00007f55ae00f000)
libopenal.so.1 => /lib/x86_64-linux-gnu/libopenal.so.1 (0x00007f55adf25000)
libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f55adefc000)
libxcb-shm.so.0 => /lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007f55adef7000)
libxcb-shape.so.0 => /lib/x86_64-linux-gnu/libxcb-shape.so.0 (0x00007f55adef2000)
libxcb-xfixes.so.0 => /lib/x86_64-linux-gnu/libxcb-xfixes.so.0 (0x00007f55adee8000)
libcdio_paranoia.so.2 => /lib/x86_64-linux-gnu/libcdio_paranoia.so.2 (0x00007f55adede000)
libcdio_cdda.so.2 => /lib/x86_64-linux-gnu/libcdio_cdda.so.2 (0x00007f55aded2000)
libdc1394.so.22 => /lib/x86_64-linux-gnu/libdc1394.so.22 (0x00007f55adc5c000)
libasound.so.2 => /lib/x86_64-linux-gnu/libasound.so.2 (0x00007f55adb62000)
libcaca.so.0 => /lib/x86_64-linux-gnu/libcaca.so.0 (0x00007f55ada97000)
libGL.so.1 => /lib/x86_64-linux-gnu/libGL.so.1 (0x00007f55ada03000)
libpulse.so.0 => /lib/x86_64-linux-gnu/libpulse.so.0 (0x00007f55ad9b2000)
libSDL2-2.0.so.0 => /lib/x86_64-linux-gnu/libSDL2-2.0.so.0 (0x00007f55ad869000)
libsndio.so.7.0 => /lib/x86_64-linux-gnu/libsndio.so.7.0 (0x00007f55ad858000)
libXv.so.1 => /lib/x86_64-linux-gnu/libXv.so.1 (0x00007f55ad653000)
libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007f55ad519000)
libXext.so.6 => /lib/x86_64-linux-gnu/libXext.so.6 (0x00007f55ad307000)
libbs2b.so.0 => /lib/x86_64-linux-gnu/libbs2b.so.0 (0x00007f55ad0ff000)
liblilv-0.so.0 => /lib/x86_64-linux-gnu/liblilv-0.so.0 (0x00007f55ad0e6000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f55ad0e0000)
librubberband.so.2 => /lib/x86_64-linux-gnu/librubberband.so.2 (0x00007f55acea8000)
libmysofa.so.0 => /lib/x86_64-linux-gnu/libmysofa.so.0 (0x00007f55acc9a000)
libflite_cmu_us_awb.so.1 => /lib/x86_64-linux-gnu/libflite_cmu_us_awb.so.1 (0x00007f55ac8a3000)
libflite_cmu_us_kal.so.1 => /lib/x86_64-linux-gnu/libflite_cmu_us_kal.so.1 (0x00007f55ac73d000)
libflite_cmu_us_kal16.so.1 => /lib/x86_64-linux-gnu/libflite_cmu_us_kal16.so.1 (0x00007f55ac361000)
libflite_cmu_us_rms.so.1 => /lib/x86_64-linux-gnu/libflite_cmu_us_rms.so.1 (0x00007f55abec6000)
libflite_cmu_us_slt.so.1 => /lib/x86_64-linux-gnu/libflite_cmu_us_slt.so.1 (0x00007f55abace000)
libflite.so.1 => /lib/x86_64-linux-gnu/libflite.so.1 (0x00007f55aba95000)
libfribidi.so.0 => /lib/x86_64-linux-gnu/libfribidi.so.0 (0x00007f55aba78000)
libva.so.2 => /lib/x86_64-linux-gnu/libva.so.2 (0x00007f55aba53000)
libass.so.9 => /lib/x86_64-linux-gnu/libass.so.9 (0x00007f55ab81e000)
libvidstab.so.1.1 => /lib/x86_64-linux-gnu/libvidstab.so.1.1 (0x00007f55ab80a000)
libzmq.so.5 => /lib/x86_64-linux-gnu/libzmq.so.5 (0x00007f55ab76a000)
libfontconfig.so.1 => /lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f55ab724000)
libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f55ab669000)
libxml2.so.2 => /lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f55ab4c1000)
libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007f55ab4ac000)
libgme.so.0 => /lib/x86_64-linux-gnu/libgme.so.0 (0x00007f55ab260000)
libopenmpt.so.0 => /lib/x86_64-linux-gnu/libopenmpt.so.0 (0x00007f55ab073000)
libchromaprint.so.1 => /lib/x86_64-linux-gnu/libchromaprint.so.1 (0x00007f55ab05d000)
libbluray.so.2 => /lib/x86_64-linux-gnu/libbluray.so.2 (0x00007f55ab00e000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f55aaff2000)
libgnutls.so.30 => /lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007f55aae4d000)
libssh-gcrypt.so.4 => /lib/x86_64-linux-gnu/libssh-gcrypt.so.4 (0x00007f55aadcc000)
libvpx.so.5 => /lib/x86_64-linux-gnu/libvpx.so.5 (0x00007f55aa97d000)
libwebpmux.so.3 => /lib/x86_64-linux-gnu/libwebpmux.so.3 (0x00007f55aa773000)
libwebp.so.6 => /lib/x86_64-linux-gnu/libwebp.so.6 (0x00007f55aa50a000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f55aa4e3000)
libcrystalhd.so.3 => /lib/x86_64-linux-gnu/libcrystalhd.so.3 (0x00007f55aa2c6000)
libopencore-amrwb.so.0 => /lib/x86_64-linux-gnu/libopencore-amrwb.so.0 (0x00007f55aa0b2000)
librsvg-2.so.2 => /lib/x86_64-linux-gnu/librsvg-2.so.2 (0x00007f55a9b86000)
libgobject-2.0.so.0 => /lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f55a9b2a000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f55a9a09000)
libcairo.so.2 => /lib/x86_64-linux-gnu/libcairo.so.2 (0x00007f55a98e9000)
libzvbi.so.0 => /lib/x86_64-linux-gnu/libzvbi.so.0 (0x00007f55a9859000)
libsnappy.so.1 => /lib/x86_64-linux-gnu/libsnappy.so.1 (0x00007f55a9651000)
libaom.so.0 => /lib/x86_64-linux-gnu/libaom.so.0 (0x00007f55a91a3000)
libcodec2.so.0.8.1 => /lib/x86_64-linux-gnu/libcodec2.so.0.8.1 (0x00007f55a913e000)
libgsm.so.1 => /lib/x86_64-linux-gnu/libgsm.so.1 (0x00007f55a912f000)
libmp3lame.so.0 => /lib/x86_64-linux-gnu/libmp3lame.so.0 (0x00007f55a8eb8000)
libopencore-amrnb.so.0 => /lib/x86_64-linux-gnu/libopencore-amrnb.so.0 (0x00007f55a8c8b000)
libopenjp2.so.7 => /lib/x86_64-linux-gnu/libopenjp2.so.7 (0x00007f55a8c35000)
libopus.so.0 => /lib/x86_64-linux-gnu/libopus.so.0 (0x00007f55a8bd9000)
libshine.so.3 => /lib/x86_64-linux-gnu/libshine.so.3 (0x00007f55a89ce000)
libspeex.so.1 => /lib/x86_64-linux-gnu/libspeex.so.1 (0x00007f55a87b4000)
libtheoraenc.so.1 => /lib/x86_64-linux-gnu/libtheoraenc.so.1 (0x00007f55a8777000)
libtheoradec.so.1 => /lib/x86_64-linux-gnu/libtheoradec.so.1 (0x00007f55a8755000)
libtwolame.so.0 => /lib/x86_64-linux-gnu/libtwolame.so.0 (0x00007f55a8532000)
libvo-amrwbenc.so.0 => /lib/x86_64-linux-gnu/libvo-amrwbenc.so.0 (0x00007f55a8318000)
libvorbis.so.0 => /lib/x86_64-linux-gnu/libvorbis.so.0 (0x00007f55a82eb000)
libvorbisenc.so.2 => /lib/x86_64-linux-gnu/libvorbisenc.so.2 (0x00007f55a8240000)
libwavpack.so.1 => /lib/x86_64-linux-gnu/libwavpack.so.1 (0x00007f55a8214000)
libx264.so.155 => /lib/x86_64-linux-gnu/libx264.so.155 (0x00007f55a7f54000)
libx265.so.165 => /lib/x86_64-linux-gnu/libx265.so.165 (0x00007f55a7006000)
libxvidcore.so.4 => /lib/x86_64-linux-gnu/libxvidcore.so.4 (0x00007f55a6cf5000)
libsoxr.so.0 => /lib/x86_64-linux-gnu/libsoxr.so.0 (0x00007f55a6a92000)
libva-drm.so.2 => /lib/x86_64-linux-gnu/libva-drm.so.2 (0x00007f55a6a8d000)
libva-x11.so.2 => /lib/x86_64-linux-gnu/libva-x11.so.2 (0x00007f55a6a83000)
libvdpau.so.1 => /lib/x86_64-linux-gnu/libvdpau.so.1 (0x00007f55a6a7d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f55b06c5000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f55a6a72000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f55a6891000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f55a6877000)
libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f55a6671000)
libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f55a646b000)
libcdio.so.18 => /lib/x86_64-linux-gnu/libcdio.so.18 (0x00007f55a6243000)
libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007f55a602a000)
libslang.so.2 => /lib/x86_64-linux-gnu/libslang.so.2 (0x00007f55a5b38000)
libncursesw.so.6 => /lib/x86_64-linux-gnu/libncursesw.so.6 (0x00007f55a5afd000)
libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f55a5acf000)
libGLX.so.0 => /lib/x86_64-linux-gnu/libGLX.so.0 (0x00007f55a5a9b000)
libGLdispatch.so.0 => /lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007f55a59de000)
libpulsecommon-12.2.so => /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-12.2.so (0x00007f55a595e000)
libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f55a590d000)
libXcursor.so.1 => /lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007f55a5902000)
libXinerama.so.1 => /lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007f55a58fd000)
libXi.so.6 => /lib/x86_64-linux-gnu/libXi.so.6 (0x00007f55a56ed000)
libXrandr.so.2 => /lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007f55a54e2000)
libXss.so.1 => /lib/x86_64-linux-gnu/libXss.so.1 (0x00007f55a54dd000)
libXxf86vm.so.1 => /lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007f55a52d5000)
libwayland-egl.so.1 => /lib/x86_64-linux-gnu/libwayland-egl.so.1 (0x00007f55a52d0000)
libwayland-client.so.0 => /lib/x86_64-linux-gnu/libwayland-client.so.0 (0x00007f55a52bf000)
libwayland-cursor.so.0 => /lib/x86_64-linux-gnu/libwayland-cursor.so.0 (0x00007f55a52b6000)
libxkbcommon.so.0 => /lib/x86_64-linux-gnu/libxkbcommon.so.0 (0x00007f55a5275000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f55a525b000)
libserd-0.so.0 => /lib/x86_64-linux-gnu/libserd-0.so.0 (0x00007f55a5043000)
libsord-0.so.0 => /lib/x86_64-linux-gnu/libsord-0.so.0 (0x00007f55a4e38000)
libsratom-0.so.0 => /lib/x86_64-linux-gnu/libsratom-0.so.0 (0x00007f55a4c2e000)
libsamplerate.so.0 => /lib/x86_64-linux-gnu/libsamplerate.so.0 (0x00007f55a48c2000)
libfftw3.so.3 => /lib/x86_64-linux-gnu/libfftw3.so.3 (0x00007f55a46bd000)
libflite_usenglish.so.1 => /lib/x86_64-linux-gnu/libflite_usenglish.so.1 (0x00007f55a4690000)
libflite_cmulex.so.1 => /lib/x86_64-linux-gnu/libflite_cmulex.so.1 (0x00007f55a45f9000)
libharfbuzz.so.0 => /lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007f55a4500000)
libgomp.so.1 => /lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f55a44c7000)
libsodium.so.23 => /lib/x86_64-linux-gnu/libsodium.so.23 (0x00007f55a4471000)
libpgm-5.2.so.0 => /lib/x86_64-linux-gnu/libpgm-5.2.so.0 (0x00007f55a4421000)
libnorm.so.1 => /lib/x86_64-linux-gnu/libnorm.so.1 (0x00007f55a42c9000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f55a428c000)
libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f55a4283000)
libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f55a424c000)
libicuuc.so.63 => /lib/x86_64-linux-gnu/libicuuc.so.63 (0x00007f55a407d000)
libmpg123.so.0 => /lib/x86_64-linux-gnu/libmpg123.so.0 (0x00007f55a3e1c000)
libvorbisfile.so.3 => /lib/x86_64-linux-gnu/libvorbisfile.so.3 (0x00007f55a3e11000)
libp11-kit.so.0 => /lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f55a3ce2000)
libidn2.so.0 => /lib/x86_64-linux-gnu/libidn2.so.0 (0x00007f55a3cc3000)
libunistring.so.2 => /lib/x86_64-linux-gnu/libunistring.so.2 (0x00007f55a3b43000)
libtasn1.so.6 => /lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f55a392e000)
libnettle.so.6 => /lib/x86_64-linux-gnu/libnettle.so.6 (0x00007f55a38f6000)
libhogweed.so.4 => /lib/x86_64-linux-gnu/libhogweed.so.4 (0x00007f55a38be000)
libgmp.so.10 => /lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f55a383d000)
libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f55a3720000)
libgssapi_krb5.so.2 => /lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f55a36d3000)
libgdk_pixbuf-2.0.so.0 => /lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x00007f55a36ab000)
libgio-2.0.so.0 => /lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007f55a34e2000)
libpangocairo-1.0.so.0 => /lib/x86_64-linux-gnu/libpangocairo-1.0.so.0 (0x00007f55a34d2000)
libpangoft2-1.0.so.0 => /lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 (0x00007f55a34b9000)
libpango-1.0.so.0 => /lib/x86_64-linux-gnu/libpango-1.0.so.0 (0x00007f55a346e000)
libcroco-0.6.so.3 => /lib/x86_64-linux-gnu/libcroco-0.6.so.3 (0x00007f55a3430000)
libffi.so.6 => /lib/x86_64-linux-gnu/libffi.so.6 (0x00007f55a3424000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f55a33b0000)
libpixman-1.so.0 => /lib/x86_64-linux-gnu/libpixman-1.so.0 (0x00007f55a330a000)
libxcb-render.so.0 => /lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007f55a32fb000)
libXrender.so.1 => /lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f55a30f1000)
libogg.so.0 => /lib/x86_64-linux-gnu/libogg.so.0 (0x00007f55a2ee6000)
libnuma.so.1 => /lib/x86_64-linux-gnu/libnuma.so.1 (0x00007f55a2ed9000)
libXfixes.so.3 => /lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f55a2cd3000)
libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007f55a2cad000)
libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007f55a2c0d000)
libwrap.so.0 => /lib/x86_64-linux-gnu/libwrap.so.0 (0x00007f55a2c01000)
libsndfile.so.1 => /lib/x86_64-linux-gnu/libsndfile.so.1 (0x00007f55a2b85000)
libasyncns.so.0 => /lib/x86_64-linux-gnu/libasyncns.so.0 (0x00007f55a297f000)
libgraphite2.so.3 => /lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007f55a2952000)
libicudata.so.63 => /lib/x86_64-linux-gnu/libicudata.so.63 (0x00007f55a0f60000)
libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f55a0f3d000)
libkrb5.so.3 => /lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f55a0e62000)
libk5crypto.so.3 => /lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f55a0e2e000)
libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f55a0e28000)
libkrb5support.so.0 => /lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f55a0e18000)
libgmodule-2.0.so.0 => /lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f55a0e12000)
libmount.so.1 => /lib/x86_64-linux-gnu/libmount.so.1 (0x00007f55a0db6000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f55a0d8c000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f55a0d71000)
libthai.so.0 => /lib/x86_64-linux-gnu/libthai.so.0 (0x00007f55a0d64000)
liblz4.so.1 => /lib/x86_64-linux-gnu/liblz4.so.1 (0x00007f55a0d35000)
libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007f55a0d1a000)
libFLAC.so.8 => /lib/x86_64-linux-gnu/libFLAC.so.8 (0x00007f55a0aa3000)
libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f55a0a9c000)
libblkid.so.1 => /lib/x86_64-linux-gnu/libblkid.so.1 (0x00007f55a0a45000)
libdatrie.so.1 => /lib/x86_64-linux-gnu/libdatrie.so.1 (0x00007f55a0a3c000)

Edit: Needless to say, dynamic linking outperforms the static binaries as soon as the proc exists multiple times(or another proc that uses that lib exists). I really can't find a proc where something like the startup time matters that only lives once. Even browsers and user space apps run multiple procs these days. The stuff that exists once and just dies is mainly stuff like gnu tools, and even then they share a lot of stuff and are small enough to not link to any distinct library. ffmpeg would be my best candidate since hte libs it uses aren't that common, and it uses well over a hundred libs. Even there it doesn't matter, though.

  • Cool. I just tried ldd /usr/bin/ffmpeg and the first time there was like a 1 second delay before I got the list (140 for Ubuntu 16.04). The second time, though, it was done before I could catch the next display frame... so 1/60th of second... (okay, it was just eyeballed...) In my case, I have a CGI. This is very similar to PHP. Although the CGI itself is very small, it will load all of my libraries and I'm already at some 47. So adding another 20 is like 67, maybe 100 once the project is more complete... However, as you point out, once loaded a first time, it's in memory and it goes fast. – Alexis Wilke May 9 at 17:18
  • 1
    That is testing the file system and ldd, though. I think a more representative comparison would be "time ffmpeg" and just let it run the simple main. Which again wouldn't be entirely correct, because you'd be timing whatever goes in main as well. So a better test would be LD_DEBUG=statistics /bin/ffmpeg, which should give you the time it takes to load all these libraries. There are some benchmarks here, chatsubo-labs.blogspot.com/2014/01/… -- I would say the warm start comparison would be the real world case as to see the timings of these. – Lacey May 9 at 18:08
  • Wow! That LD_DEBUG is great. I see a cold start of ffmpeg is 3,101,424,080 and a hot start is only 90,654,111 cycles. Quite a difference! – Alexis Wilke May 9 at 18:36
  • Just for reference, I am running an i5 that is over 3 years old, and it took less than 1/10th of that time for the cold startup, and less than 1/3 for the warm one. You are running an OS from 2016 and even the simple "ldd /bin/ffmpeg" takes a full second, and that should be only a little more than reading the binary(such queries happen basically instantly for me). Anyway my point is, most servers and most peoples systems run faster than my system. I imagine with a modern system and where you aren't going to be loading hundreds of libraries, it is going to be truly negligible. – Lacey May 9 at 19:15
  • 1
    Yep! And there your timings can be done on your real program too. So that should be pretty representative of a real use case. Glad I could be of use! ^__^ – Lacey May 9 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.