comments on KDE performance tips

Andrew Morton kde-optimize@mail.kde.org
Thu, 16 Jan 2003 21:34:01 -0800


Waldo Bastian <bastian@kde.org> wrote:
>
> I think it is possible to let the linker tell the kernel that the whole thing 
> should be read, but that's a suboptimal solution in that you read a lot of 
> stuff you rather not read. The best solution is to read what you need in one 
> go, and nothing of the stuff that you don't need. Such solution would mean 
> that you put all the stuff that you need (at startup) in one continguous part 
> of your lib and then the (runtime) linker should tell the kernel that it must 
> read all that in.

The cost of reading all the blocks in a file is negligibly higher than
reading (say) half of them.

For example, this script:

	#!/bin/sh
	PROG=$(which $1)
	for lib in $(ldd $PROG | cut -d ' ' -f 3)
	do
	        cat $lib > /dev/null
	done
	$*

when used as

	./launch.sh konqueror

speeds up the initial launch of konqueror by maybe 2x (didn't bother benching
it too hard, but the difference is quite plain).

And it's reading all the debug info and other ELF gunk.  Clearly, performing
an MADV_WILLNEED against the entire executable/library as soon as it is
mapped will speed things up significantly.  It's saving a ton of seeks.

As the amount of memory and disk bandwidth continue to increase, and the
latency of disk seeks and rotation fails to keep up, demand paging just makes
less and less sense.