Sunday, February 2, 2014

Solaris Caches

Three caches are system generic - old buffer cache, page cache and DNLC.  The others are file system specific.

Old buffer cache is used by the block device interface to cache disk blocks. This cache is of fixed size.  With the introduction of page cache, Solaris merge the buffer cache into page cache to create the unified buffer cache,.  Solaris uses buffer cache to store UFS inode and metadata only.

Page cache was introduced during a virtual memory rewrite for SunOS 4 in 1985 and added to SVR4.  It caches virtual memory pages as well as memory mapped file pages.  It is more efficient than buffer cache which requires translating file offset to disk offset for each look up.  The cache size is dynamic and releases when application needs more pages.  Page size is used by many file systems e.g. UFS and NFS.  ZFS does not use page cache.  Dirty pages are written by fsflush daemon which periodically scan the whole cache.  Tthe page scanner (pageout daemon) also write dirty page to disk to free up pages.  Both are kernel threads and not processes but appear as PID 2 and 3 respectively.

There are 2 kernel drivers for page cache.  segmap maps file to process memory.  segvn caches file system read and write pages.

DNLC (Directory Name Lookup Cache) maps directory entries to vnode.  It was developed in early 1980.  This improve performance for open call.

No comments: