Subject: trying to understand 'sysctl vm'
To: None <current-users@netbsd.org>
From: Arto Selonen <arto@selonen.org>
List: current-users
Date: 10/07/2004 11:43:04
Hi!

After going through the 'Bad response' thread I've been looking at
'sysctl vm' parameters and trying to tune them for better memory
management. However, there are issues that I don't understand,
and specifically there is behaviour that I'm observing and which
differs from what I expected/wanted.

I have a system with 1GB of memory, and only a single large app
(squid) running on it. So, most of the memory should go to anon
pages, and "rest" for file cache.

Here is a typical memory usage, based on 'top' and 'vmstat -s'
numbers (the system runs 2.0H from ~20040928):

	- top showing:
		- ~470 MB active
		- ~240 MB inactive
		- ~  3 MB wired
		- ~  6 MB exec
		- ~330 MB file
		- ~  1 MB free
		- ~  1 MB swap
		- ~350 MB squid
		- ~270 MB pagedaemon & friends
	- vmstat -s showing:
		- ~64% anon
		- ~ 1% cached exec
		- ~33% file

I had set the following sysctl variables (which were in effect during
previous reboot):

	vm.anon{min,max} = 10,90
	vm.exec{min,max} =  5,20
	vm.file{min,max} =  5,30

I had also used kernel option BUFCACHE set to 10, although I have not
found documentation that would explain how it relates to the above
vm.{anon,exec,file}{min,max} variables.

My (wrong?) understanding was that if file cache usage was above
the specified max, and others remained below their max values, then
memory from file cache would be used if more memory was needed for them.

However, I'm observing a situation where the file cache keeps on
increasing (from ~325MB -> ~340 MB), and at the same time swap
usage increasing (parts of squid paging out?). It is as if there
was an upper limit of 65% for anon, but no 30% limit for file cache.
Why would that be? How to avoid going to swap, when there seems to be lots
of file cache "available"?

After seeing this, I further reduced vm.filemax down from 30 to 25
(using just sysctl), but the file cache kept on growing, presumably with
the expense of anon pages. Also, I have not noticed any change in
memory usage of any other process (besides file cache, swap, squid
and pagedaemon).

I don't claim that my parameters are correct, or that I have understood
their effect, but I would like to. Hopefully, these issues will be
explained in more detail in http://www.netbsd.org/Documentation/tune/
(where it would ne nice to see real world examples of VM tuning
*with* explanations on the rationale for reaching the numbers). :)

What am I missing/misunderstanding here?


Artsi
-- 
#######======------  http://www.selonen.org/arto/  --------========########
Everstinkuja 5 B 35                               Don't mind doing it.
FIN-02600 Espoo        arto@selonen.org         Don't mind not doing it.
Finland              tel +358 50 560 4826     Don't know anything about it.