Mac OS X Internals: A Systems Approach
4.14. The BootCache Optimization
Mac OS X uses a boot-time optimization called BootCacheeffectively a smart read-ahead schemethat monitors the pattern of incoming read requests to a block device and sorts the pattern into a play list, which is then used to cluster reads into a private cache. Each play-list entry represents a disk region to be cached and is specified as a { block address, length } pair. This "boot cache" is thereafter used to satisfy incoming read requests if possible. The scheme also measures the cache-hit rate. The request pattern is stored in a history list to allow the scheme to be adaptive. If the hit rate is too low, the caching is disabled. BootCache is only supported on the root device. It requires at least 128MB of physical RAM to be automatically enabled. The BootCache kernel extension (BootCache.kext) registers a callback named mountroot_post_hook() with the kernel to request notification of the mounting of the root file system. The kernel extension has the OSBundleRequired property set to Local-Root, which marks it as a requirement for mounting root on a local volume. Therefore, before a local root file system is mounted, the kernel will ensure that the BootCache kernel extension is loaded. BootCache's loadable read pattern is sorted and stored in the /var/db/BootCache.playlist file. Once this pattern is loaded, the cache comes into effect. When a recorded read pattern is fetched, the cache is disabled and the associated memory is freed. The entire process is invisible from the user and requires no action on the latter's part. A user-level control utility called BootCacheControl can be used to start or stop the cache, manipulate play lists, and view cache statistics. $ sudo BootCacheControl -f /var/db/BootCache.playlist print 512-byte blocks 143360 4096 2932736 4096 3416064 4096 ... 122967457792 512 prefetch 122967576576 4096 122967666688 4096 122967826432 4096 122968137728 4096 94562816 blocks $ sudo BootCacheControl statistics block size 512 initiated reads 2823 blocks read 176412 ... extents in cache 1887 extent lookups 4867 extent hits 4557 extent hit ratio 93.63% hits not fulfilled 0 blocks requested 167305 blocks hit 158456 blocks discarded by write 0 block hit ratio 94.71% ...
|
Категории