BootCache

Mac OS X uses a boot-time optimization (effectively a smart read-ahead) that monitors the pattern of incoming read requests to a block device (the boot disk), and sorts the pattern into a "playlist", which is used to cluster reads into a private cache. This "boot cache" is then used for satisfying incoming read requests, if possible. The scheme also measures the cache hit rate, and stores the request pattern into a "history list" for being adaptive in future. If the hit rate is too low, the caching is disabled.

The loadable (sorted) read pattern is stored in /var/db/BootCache.playlist. Once this pattern is loaded, the cache comes into effect. The entire process is invisible from users.

only supported on the root device, requires at least 128 MB of physical RAM before it is enabled (automatically).

System/Library/Extensions/BootCache.kext is the location of the kernel extension implementing the cache
Contents/Resources/BootCacheControl within that directory is the user-level control utility (it lets you load the playlist, among other things).

BootCache is started (via BootCacheControl) in /etc/rc, and a prefetch tag is inserted (unless the system is booting in safe mode ([shift]).
/etc/rc looks for BootCacheControl in the Resources directory of the BootCache.kext bundle, as well as in /usr/sbin, loginwindow.app accesses /usr/sbin/BootCacheControl directly, and does not find it.
Making BootCacheControl available in /usr/sbin, via a symbolic link, reduces the boot time .

/privat/var/db/BootCacheControl.playlist was 47,484 bytes on 9/26/08.


/usr/sbin/BootCacheControl

bootcachecontrol [-vvv] [-b blocksize] [-f playlistfile ] start|stop
Start/stop the cache using <playlistfile>.

bootcachecontrol statistics Print
displays /var/dc/statistics for the currently-active cache.

> bootcachecontrol  statistics print
initiated reads 3758
blocks read  306012
read errors  0; blocks discarded by error 0
batch 0 time              4.342s; batch 1 time              17.093s; batch 2 time              18.078s
blocks read in batch 0:   62033;   blocks read in batch 1:   143238; blocks read in batch 2:   100741
reader thread rate        3872kB/s, 95tps
total strategy calls      8691
non-read strategy calls   1238 bypassed strategy calls   2818
bypasses while active     1623
filled strategy calls     5873
filled during active I/O  5290
active time               58.411s
read/write strategy rate  127/21tps
callers blocked           39
time blocked on extents   88.770s
extents in cache          1978           extent lookups            7453        extent hits               6824
extent hit ratio          91.56%
hits not fulfilled        951
blocks requested          347066
blocks hit                299266
blocks discarded by write 112
block hit ratio           86.26%
leftover blocks           6522
leftover pages            0
block wastage             2.13%
history clusters          14
bootcachecontrol tag
Insert the end-prefetch tag.

bootcachecontrol [-vvv] -f playlistfile
merge playlistfile1 [playlistfile2 ]
Merge playlistfile1... into playlistfile.

bootcachecontrol [-c] -f playlistfile
print the contents of playlistfile.

bootcachecontrol -f playlistfile unprint
Read a playlist from STDIN and write to playlistfile.

bootcachecontrol -f playlistfile
generate [volume] Generate a playlist from standard input data for volume and write to playlistfile. bootcachecontrol -f playlistfile truncate count Truncate playlistfile to count entries.

Deleting /private/var/db/bootCache has been known to fix kernel trap