10 Mar 2006 hisham   » (Apprentice)

Once upon a time I published elsewhere (currently offline, sorry) a list of "cool ideas for software that I don't have the time or willingness to implement" (some of them I actually ended up implementing myself). Well, here's another one:

Incremental ldconfig

This one is not a full project, but rather adding a new option to an existing program, ldconfig (part of the Glibc package).

Motivation: when the libraries directory is not in the disk cache, ldconfig takes a long time. In GoboLinux, for instance, it's the longest step when installing a package after downloading and unpacking the tarball (sometimes even surpassing those, when the tarball is small enough). Ldconfig scans the entire libraries directory, opening each file. Here's an excerpt of strace:

lstat64("/System/Links/Libraries/libgettextsrc.so", {st_mode=S_IFLNK|0777, st_size=52, ...}) = 0 stat64("/System/Links/Libraries/libgettextsrc.so", {st_mode=S_IFREG|0755, st_size=191105, ...}) = 0 open("/System/Links/Libraries/libgettextsrc.so", O_RDONLY) = 4 fstat64(4, {st_mode=S_IFREG|0755, st_size=191105, ...}) = 0 old_mmap(NULL, 191105, PROT_READ, MAP_SHARED, 4, 0) = 0x40021000 munmap(0x40021000, 191105) = 0 close(4) = 0 lstat64("/System/Links/Libraries/libSDL_net.so", {st_mode=S_IFLNK|0777, st_size=51, ...}) = 0 stat64("/System/Links/Libraries/libSDL_net.so", {st_mode=S_IFREG|0755, st_size=15415, ...}) = 0 open("/System/Links/Libraries/libSDL_net.so", O_RDONLY) = 4 fstat64(4, {st_mode=S_IFREG|0755, st_size=15415, ...}) = 0 old_mmap(NULL, 15415, PROT_READ, MAP_SHARED, 4, 0) = 0x40021000 munmap(0x40021000, 15415) = 0 close(4) = 0

It repeats for all 2000+ files I have in my /System/Links/Libraries directory.

Instead of rescanning the entire directory, An incremental version of ldconfig would load the cache file, scan the files/directories given in the command line flags, add or replace the relevant entries in the in-memory copy of the cache file and then rewrite it to disk. Assuming this would be implemented as an "-i" flag, the package manager could then run something like

ldconfig -i /usr/lib/libalsa.*

when upgrading ALSA instead of going through every library.

Before writing this, I looked to see if something of this kind was already implemented somewhere. Didn't find it, but I did find others wishing for the same thing.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!