Subject: Re: paging like crazy
To: Jukka Marin <jmarin@pyy.jmp.fi>
From: Greg A. Woods <woods@weird.com>
List: current-users
Date: 09/01/2001 02:03:31
[ On Saturday, September 1, 2001 at 08:25:39 (+0300), Jukka Marin wrote: ]
> Subject: paging like crazy
>
> Isn't there REALLY a way to limit the amount of RAM used by the disk buffer
> cache?

I've noticed a slight difference improvement since adding the following
to my config:

## The static buffer cache is defined by two kernel parameters:  NBUF
## BUFCACHE, and BUFPAGES.
## 
## NBUF defines the number of buffer headers, i.e. the number of files
## that may have a buffer cache entry.  Each buffer header includes
## space for an I/O buffer of MAXBSIZE (which defaults to 65536) so
## take care not to allocate too many.
## 
## The size of the actual buffer data cache is defined by the kernel
## parameter BUFPAGES.  This size is given in 4kB pages.  If the
## parameter BUFCACHE is set then BUFPAGES is automatically calculated
## as the specified percentage of total available RAM.
## 
## By default the number of pages available for the buffer cache is
## calculated as 10% of available RAM if there's 2MB or less RAM, else
## 5% of the available RAM.
## 
options         NBUF=1200       # buffer headers
options         BUFCACHE=10     # use up to 10% of RAM

The boot now says:

	using 1200 buffers containing 19600 KB of memory

beforehand it said:

	using 2478 buffers containing 9912 KB of memory

Note that with fewer NBUF headers there's probably actually less kernel
memory being used, and while I've nearly doubled the amount of memory
that can be used by BUFPAGES, the total memory used by the static buffer
cache is actually a lot less (if I understand the calculations and
parameters properly).

Now Mozilla's a bit quicker to get going again if I leave it alone for a
while, or if I've done big file operations.

However I didn't really find it all that bad beforehand either.  Sure
sometimes Netscape or Mozilla would take a while to page in (on the
order of 5-10 seconds, not bad for a 24 to 64MB process!), but my next
biggest interactive processes (emacs) would normally be front&centre all
the time (maybe because I load the time package and have the current
time displayed in my mode line, which means emacs must wake up to do
that).

I've got 192MB of RAM in this machine, and it's running with a 300MHz P-II.

It helps a lot too if you've got lots of swap spindles.  I've got 4
UltraFAST+wide (40MB/s) drives with a 500MB swap partition on each, so
when this system does page, it pages FAST!

Of course I don't run X11 directly on this machine -- it's a server, not
a workstation.  I run my X11 on X terminals and a diskless sparcstation.


> After a full backup, _everything_ has been paged to disk and a 900 MHz
> Athlon with 384 MB RAM is much slower than a 50 MHz 486 with 16 MB and
> an older version of NetBSD.

Well, what do you expect?!?!?!  You're asking the system to do a *lot*
of I/O before it can do anything else.  You also more or less asked to
have everything paged out because you weren't demanding that the paged
out processes run actively while the backup was running.  The system is
simply doing its best to do what you've asked it to do, given the
resources you've given it, and the configurations you've assigned.  If
you have to page in 300 MB of stuff from a single spindle you'd best be
prepared to sip your coffee patiently while it does its best to do so!

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>     <woods@robohack.ca>
Planix, Inc. <woods@planix.com>;   Secrets of the Weird <woods@weird.com>