Subject: Re: more on mysql benchmark
To: Chuck Silvers <chuq@chuq.com>
From: SODA Noriyuki <soda@sra.co.jp>
List: tech-kern
Date: 03/07/2005 12:16:29
>>>>> On Sun, 6 Mar 2005 17:38:09 -0800, Chuck Silvers <chuq@chuq.com> said:

> vm.filemin=5
> vm.filemax=20
> vm.anonmin=80
> vm.anonmax=90
> vm.execmin=5
> vm.execmax=30

> this is probably closer to what various people think is appropriate
> in general anyway.  comments?

I think vm.filemax + vm.anonmax + vm.execmax must be < 100,
otherwise very nasty behaviour may happen.
For example, please think about the following scenario:

- Continuous file access is ongoing.
  And at the same time, anonymous pages take 90%.
- The requrement of anonymous pages is increasing, and it reaches 91%.
- Since the anonymous pages exceed vm.anonmax, the pages are now not
  protected by the vm.anonmax parameter.
- On the other hand, file pages are now becomes protected by vm.filemax,
  because it is currently only using 10% and that's less than vm.filemax.
- So, file pages now becomes to steal anonymous pages.

What we see in this scenario is that anonymous pages lose its physical
memory when the requreiment of the anonymous pages increases.

I actually saw such situation with current default (anonmax=80 and
filemax=50), and file pages actually took 50% of the memory at that
time on the machine which had 128MB RAM.

Having filemax+anonmax+execmax>=100 leaves no memory for page daemon
to adapt memory requirements for various situation, this is really
problematic.

What I think more appropriate is something like:
	vm.{anon,exec,file}{min,max}={{10,80},{1,2},{0,1}}
The rationales of this setting are:
- Leave 17% of memory for page deamon.
  This may be still too small, and perhaps we should *decrease* (not
  increase) anonmax.
- For machines which have large RAM (e.g. 1GB), even 2% of memory
  is enouch for working sets of executable pages.
  For machines which have really small RAM, working sets of executable
  pages are often really really small (since such machine doesn't use
  bloated software like mozilla). For example, what I saw in simon's
  famous gcc benchmark on pc532 is that executable pages only take
  1.5% of free+active+inactive pages.
- vm.file{min,max} must be less than vm.exec{min,max}.

One drawback with the above setting is that sometimes page daemon
abandons too much vnode pages and makes too much free pages, but
I guess that's because genfs_putpages() (or somewhere else?) does
too much job, and I think such too much work should be fixed instead.

BTW, I think it is better to decrease current lower bound of
vm.bufcache from 5% to something like 1% (Note that I'm not talking
about default value but lower bound value here). Because it's often
desirable to use such small value on machines like pc532 which have
smaller RAM.

P.S. (not to chuck, but to other audience)
Please note that above discussion is only talking about default
settings, there are situation that it's better to set vm.file{min,max}
larger values.
--
soda