Manipulating disk cache (buf) settings

Sven Willenberger sven at dmv.com
Mon May 23 11:49:29 PDT 2005


On Mon, 2005-05-23 at 10:44 -0700, John-Mark Gurney wrote:
> Sven Willenberger wrote this message on Mon, May 23, 2005 at 10:58 -0400:
> > We are running a PostgreSQL server (8.0.3) on a dual opteron system with
> > 8G of RAM. If I interpret top and vfs.hibufspace correctly (which show
> > values of 215MB and 225771520 (which equals 215MB) respectively. My
> > understanding from having searched the archives is that this is the
> > value that is used by the system/kernel in determining how much disk
> > data to cache. 
> 
> This is incorrect...  FreeBSD merged the vm and buf systems a while back,
> so all of memory is used as a disk cache..  The buf cache is still used
> for filesystem meta data (and for pending writes of files, but those buf's
> reference the original page, not local storage)...
> 
> Just as an experiment, on a quiet system do:
> dd if=/dev/zero of=somefile bs=1m count=2048
> and then read it back in:
> dd if=somefile of=/dev/null bs=1m
> and watch systat or iostat and see if any of the file is read...  You'll
> probably see that none of it is...
> 

Yes, confirmed as stated, this is great news then. In essence the
PostgreSQL planner can be told that the effective cache size is *much*
larger than that calculated by using vfs.hibufspace; should result in
some [hopefully] marked performance boosts.

btw:
> dd if=/dev/zero of=zerofile bs=1m count=2048
2048+0 records in
2048+0 records out
2147483648 bytes transferred in 43.381462 secs (49502335 bytes/sec)
> dd if=zerofile of=/dev/null bs=1m
2048+0 records in
2048+0 records out
2147483648 bytes transferred in 5.304807 secs (404818435 bytes/sec)

and that was on a 3GB RAM system so the caching scheme works great.

Sven




More information about the freebsd-stable mailing list