Tweaking Disk Cache/Buffers and fsync

Stephen Moore swmspam at swmoore.net
Wed Apr 16 05:07:08 UTC 2008


There's a lot of discussion on the sysctl settings for vfs disk
cache/buffers,

but very little consolidated or comprehensive explanations.

 

I have a NAS box with 1GB of memory, but rarely see over ~40MB of
utilization

during file transfers. When writing a large file to the NAS, I see the
transfer

rate throttle and pause in regular intervals. This indicates to me the dirty

buffers are flushing and writing to the disk, and the file transfer is
interrupted

during the disk write process.  

 

Therefore, I would like to (1) increase the memory utilization, so that a
large

file write (500MB) will buffer entirely to memory for fastest transfer
speeds,

and (2) then take as long as needed to write the dirty buffers to the disk,
after

the transfer is concluded.

 

For part (1), I looked at the following sysctl settings, but I don't fully

understand the interactions:

 

vfs.maxbufspace

vfs.lobufspace

vfs.hibufspace

vfs.hidirtybuffers

vfs.hirunningspace

 

also /boot/loader.conf kern.nbuf

 

I understand some rules: hirunningspace should be between 1MB to 4MB.

lobufspace should be 25% to 75% of hibufspace. 

 

What I don't understand is the relationship between maxbufspace and
hibufspace,

and what are good values.

 

I also don't understand hidirtybuffers.

 

For part (2), I need to slow down the occurrence of sync() or fsync().
Ideally,

a sync would not occur for 300 seconds, which is about 10 times as long as

(apparently) the default setting. (obviously, if the buffer space is full, a

sync would need to occur to make more room.) I've seen references of a
daemon

to periodically run a sync, or is it controlled by init?

 

Yes, this increases vulnerability when the data is in buffer before
committed

to disk, but in my application, this is reasonable.

 



More information about the freebsd-performance mailing list