agressive swap-out/performance tests.

Harvey J. Stein (abel@netvision.net.il)
Mon, 21 Apr 1997 12:05:02 +0300


I have similar problems with swap behavior, and I've been trying to
figure this out how to tune it for a while now. I have the opposite
problem that you have - I have 32mb of RAM & it seems like the system
preserves the disk cache at the expense of large programs. Also, for
the sorts of applications I run (a small number of large applications,
minor disk i/o), I find kernel 1.2.13 to perform much better than
2.0.29!

For example, I have a test script for poping up lots of netscape
windows:

#!/bin/sh -norc

nwindows=$1

~/bin/time netscape &
sleep 10

while [ $nwindows -gt 0 ] ; do
netscape -remote "openFile(/home/hjstein/.netscape/bookmarks.html,new_window)"
sleep 3
let nwindows=nwindows-1
done

sleep 30

netscape -remote "exit"

Note - The sleeps are to give time for each window to come up. Also,
you have to use window auto-placement so that you don't have to
position each window. For fvwm, that's the RandomPlacement command in
.fvwmrc.

Here's what happens when I run it repeatedly:

hjstein@blinky:~$ free
total used free shared buffers cached
Mem: 31064 28812 2252 12988 1500 7816
-/+ buffers: 19496 11568
Swap: 32756 3100 29656

hjstein@blinky:~$ swaptest 5
netscape: window 0x300037d was destroyed.
hjstein@blinky:~$ 8.86user 6.65system 2:41.89elapsed 9%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (11264major+1229minor)pagefaults 128swaps

hjstein@blinky:~$ free
total used free shared buffers cached
Mem: 31064 26160 4904 12208 172 9528
-/+ buffers: 16460 14604
Swap: 32756 6000 26756

hjstein@blinky:~$ swaptest 5
7.57user 2.61system 1:08.42elapsed 14%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (1759major+1151minor)pagefaults 0swaps
netscape: window 0x3000374 was destroyed.

hjstein@blinky:~$ free
total used free shared buffers cached
Mem: 31064 25892 5172 12044 224 9968
-/+ buffers: 15700 15364
Swap: 32756 6824 25932

hjstein@blinky:~$ swaptest 5
7.59user 2.48system 1:02.61elapsed 16%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (1117major+1151minor)pagefaults 0swaps
netscape: window 0x3000374 was destroyed.

hjstein@blinky:~$ free
total used free shared buffers cached
Mem: 31064 25660 5404 11856 408 10284
-/+ buffers: 14968 16096
Swap: 32756 7548 25208

Here's what I find surprising about the above data:

1. The first run took over twice as long elapsed as the other
runs. Visually, the windows seem to take forever to come up.
Auditorily, there's massive disk action. Later runs are close
to the minimum elapsed time, which is 55 seconds given all the
sleeps. So, taking this into account, the 1st run is showing
massive activity and system usage, whereas the latter runs
cause only minor loading.
2. The first run has 10x the number of major pagefaults of later
runs.
3. In the first run it seems like netscape itself is getting
swapped! I find it pretty surprising that the most active
process, and the one which is making all the memory requests, is
actually getting swapped out to make room for itself!
4. The buffer cache dropped to 1/10, but the cache is actually
growing!

What I really don't understand is why the cache doesn't shrink. I'd
think that if the system has the choice between writing swap pages to
disk, or just dropping pages that had been read from disk, then
obviously the latter would at least be much faster in the short term.
I'd understand if it didn't shrink down to zero, but I don't
understand why it sits there occupying 30% of my RAM, while active
processes are getting written to disk.

So, how can I improve the performance here? What I'd like to try is
to tell the kernel to drop disk cache pages that have been read but
unaltered before swapping out processes (say down to a settable
minimum of disk cache). Or, maybe adjust some ratio of the amount of
cache pages read from disk to drop vs the amount of process pages to
swap out.

Thanks,

Harvey J. Stein
Berger Financial Research
abel@netvision.net.il