How does disk caching work?
Jim C. Nasby
jim at nasby.net
Sun Apr 18 19:20:53 PDT 2004
On Sat, Apr 17, 2004 at 09:41:19AM +0200, Uwe Doering wrote:
> The disk i/o buffers you refer to (the 'Buf' column in 'top') are the
> actual interface between the VM system and the disk device drivers. For
> file and directory data, sets of VM pages get referred by and assigned
> to disk i/o buffers. There they are dealt with by a kernel daemon
> process that does the actual synchronization between VM and disks.
> That's where the soft updates algorithm is implemented, for instance.
> In case of file and directory data, once the data has been written out
> to disk (if the memory pages were "dirty") the respective disk i/o
> buffer gets released immediately and can be recycled for other purposes,
> since it just referred to memory pages that continue to exist within the
> VM system.
> Meta data (inodes etc.) is a different matter, though. There is no VM
> representation for this, so for disk i/o they have to be cached in extra
> memory allocated for this purpose. A disk i/o buffer then refers to
> this memory range and tries to keep it around for as long as possible.
> A classical cache algorithm like LRU recycles these buffers and memory
> allocations eventually.
> As usual, the actual implementation is even more complex, but I think
> you got a picture of how it works.
Yes, much clearer now, thanks!
A few questions if I may...
What's a good way to tune amount of space dedicated to IO buffers?
What impact will vm_min|max_cache have on system performance? Is there
any advantage to setting it fairly high?
The machine I'm tuning is a dual Opteron box with 4G of ram, a mirror
and a 6 disk RAID10. It's running PostgreSQL.
Jim C. Nasby, Database Consultant jim at nasby.net
Member: Triangle Fraternity, Sports Car Club of America
Give your computer some brain candy! www.distributed.net Team #1828
Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"
More information about the freebsd-performance