Donate

Categories

Advert

XHTML

Valid XHTML 1.0 Transitional

Shared Objects and Big Applications

Some time ago I wrote a little utility named memlockd [1]. Memlockd will lock files into memory which allows significantly faster access when the system pages heavily, in my simulated tests I have found that having the programs and shared objects needed for logging in locked in memory can make it possible to login without a timeout when there is heavy paging, this can make the difference between recovering a system with some processes that are out of control and having to reboot it (often without discovering the root cause).

As always happens some people use my software in ways that I never planned. One guy is using it to try and make OpenOffice.org load faster. I’m not sure that this is a good idea. In a typical installation when configured for the purpose that I intended it (system recovery from a rabbit process) memlockd will take a bit less than 10M of RAM on an i386 platform (that is for bash, login, sshd, getty, busybox, and all necessary shared objects and a few data files. Since RHEL 4 Red Hat distributions have whinged at boot time if there was less than 256M of RAM available, installation of a Red Hat based system on anything less than 128M of RAM has been impossible for some years, and Debian systems perform very poorly with less than about 128M of RAM when you run apt-get. I initially designed memlockd to run on my SE Linux Play Machine which has 128M of RAM in it’s current incarnation. Locking 7.5% of RAM on the system may impact performance, but as a large part of that RAM is used for things like libc and bash which tend to be partially paged in at all times this shouldn’t be a noticeable impact. But locking 100M or more of OpenOffice seems more likely to have the potential to hurt performance, I often run OpenOffice on a machine with 512M of RAM and the biggest desktop machine I use has 1.5G of RAM – for me it wouldn’t make sense to lock OpenOffice into memory.

But it could be that there is some unusual aspect of his system that makes running memlockd with OpenOffice likely to give worthy benefits in performance without significantly hurting performance for other programs, for example it could have 4G of RAM and a really slow disk. It is also a possibility that the usage of the system makes OpenOffice so much more important than other programs that any decrease in performance in other areas is not relevant. In any case I’m happy to help people use my software to do unusual things so I’ll support this use.

I’ve been asked why memlockd doesn’t seem to give much benefit when starting up OpenOffice when run with “+/opt/openoffice.org3/program/soffice.bin” in the config file, where the + means to lock all shared objects that ldd reports that the binary needs.

for n in `ldd /usr/lib/openoffice/program/soffice.bin|sed -e s/^.*=..// -e s/\ .*// | sort -u` ; do readlink -f $n ; done | sort -u > ldd.txt

I used the above command to get a list of all shared objects that ldd reports for the soffice.bin program. On my system (Debian/Lenny i386) it reports 77 shared objects loaded. When memlockd locks all those ps reports that the RSS is 51944K.

cat /proc/1234/maps|sed -e s/^.*\ //|sort -u > /tmp/map.txt

Then I used the above command to get a list of the files that are memory mapped by OpenOffice when running OpenOffice calc where 1234 is the PID of the soffice.bin process (I expect that the numbers will be similar for writer, impress, etc – I just happened to have a spreadsheet open). It reports 172 memory mapped files which include 9 files related to fonts and 64 shared objects under /usr/lib/openoffice/program which are not found by ldd among other things. It’s quite common for a large application to use dlopen(3) at run-time to map shared objects instead of linking against them. Running memlockd with this list gave an RSS of 118644K, which is more likely to give a useful performance boost to OpenOffice load times.

5 comments to Shared Objects and Big Applications

  • There’s also a “pagein” program that comes with OpenOffice. You can run it once at the start of your session and get a faster first startup of the morning, but still give the OS permission to page out parts of OO if necessary.

  • etbe

    Don: That sounds like a better solution to the problem.

  • pagein does not seem to work. It only seems to cache the file specified and none of it’s dependencies. Where can I find more documentation on it? It appears to be another version of memlockd.

  • mic

    Let me add another (mis)use of memlockd :-) : I have 6GB of ram and will try to use memlockd to lock entire root filesystem (about 1GB) in the memory. If this works I hope to eliminate slow linux desktop response after copying several big files.

  • etbe

    http://etbe.coker.com.au/2010/03/08/storage-vs-ram-size/

    mic: Your comment inspired my above post.

    Rob: Maybe if you check out /proc/PID/maps you can see the shared objects that are dynamically loaded and add them to the configuration.