Tweaking Disk Cache/Buffers and fsync
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
but very little consolidated or comprehensive explanations.
I have a NAS box with 1GB of memory, but rarely see over ~40MB of
during file transfers. When writing a large file to the NAS, I see the
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
during the disk write process.
Therefore, I would like to (1) increase the memory utilization, so that a
file write (500MB) will buffer entirely to memory for fastest transfer
and (2) then take as long as needed to write the dirty buffers to the disk,
the transfer is concluded.
For part (1), I looked at the following sysctl settings, but I don't fully
understand the interactions:
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
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().
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
to periodically run a sync, or is it controlled by init?
Yes, this increases vulnerability when the data is in buffer before
to disk, but in my application, this is reasonable.
More information about the freebsd-performance