Subject: Re: Speeding up "pstat -T"
To: Simon Burge <simonb@wasabisystems.com>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 10/02/2003 17:37:51
On Thu, Oct 02, 2003 at 11:22:44PM +1000, Simon Burge wrote:
> My server ran out of open files today, so I tried "pstat -T".  On
> this box it wanted to allocated a 40-odd MB chunk of memory, copy the
> complete vnode table to userland and not even use it.
> 
> The default return values for sysctls that return arrays when they don't
> pass any storage is to return the size of the array needed, plus some
> slop.  "pstat -T" wants an exact count.  What the following patch does is
> adds a optional flag to the kern.vnode sysctl that will perform an exact
> count instead of an estimate.  On an 550MHz i386 with 256k vnode limit,
> this drops the process size from over 43MB to 112kB, and the run time
> for 20 calls to "pstat -T" from over 13 seconds to just under a second.
> 
> Anyone see problems with this?

KISS!

Make pstat not fetch the nvodes if it only wants to know the number.
Either:
1) report KINFO_VNODESLOP too many (no one will notice)
2) subtract 10
3) move KINFO_VNODESLOP to a visible header file
4) add a sysctl for numvnodes

There is the separate issue of fixing sysctl so it doesn't have to lock
down the user buffer.

I also wonder whether the limit on the number of open files has passed
its 'best before' date and should be scrubbed.
The per-process 'hard' limit should be a fixed number.... say 1024.

	David

-- 
David Laight: david@l8s.co.uk