Dependencies - define what you need, and nothing else
By user12613883 on Jul 15, 2004
I recently attended Usenix, where Bryan explained how DTrace had been used to uncover some excessive system load brought on by the behavior of one application. A member of the audience asked whether the application was uncovering a poorly implemented part of the system. Bryan responded that in such cases the system will always be analyzed to determine whether it could do better. But there comes a point, that if an application requests an expensive service, that's what it will get. Perhaps the application should be reexamined to see if it needs the service in the first place?
This observation is very applicable to the runtime linking environment.
Over the years we've spent countless hours pruning the cost of
Think about the work the runtime linker has to do to load an object. It has to find the object (sometimes through a plethora of LD_LIBRARY_PATH components), load the object, and relocate it. The runtime linker then repeats this process for any dependencies of the loaded object. That's a lot of work. So why do so many applications load dependencies they don't need?
Perhaps it's sloppyness, too much
% ldd -u -r app ... unused object=/lib/libmd5.so.1
Note the use of the -r option. We want to force
The -u option uncovers totally unused objects, but there can still be wasteful references. For example, the same application reveals that a number of objects have wasteful dependencies:
% ldd -U -r app ... unreferenced object=/usr/openwin/lib/libX11.so.4; unused dependency of app unreferenced object=/usr/openwin/lib/libXt.so.4; unused dependency of app unreferenced object=/lib/libw.so.1; unused dependency of app
To reduce system overhead, only record those dependencies you need, and nothing else. As part of building the core OS, we run scripts that perform actions such as ldd(1) -U in an attempt to prevent unnecessary dependency loading from creeping in.
Note, you can also observe unused object processing using the runtime
linkers debugging capabilities (LD_DEBUG=unused). Or, you
can uncover unused objects during a link-edit using the same debugging
technique (LD_OPTIONS=-Dunused). Another way of pruning unwanted
dependencies is to use the
-z ignore option of