Flashcache


Flashcache is a disk cache component for the Linux kernel, initially developed by Facebook since April 2010, and released as open source in 2011. Since January 2013, there is a fork of Flashcache, named EnhanceIO and developed by sTec, Inc.
Flashcache works by using flash memory, a USB flash drive, SD card, CompactFlash or any kind of portable flash mass storage system as a write-back persistent cache. An internal SSD can also be used for increasing performance.

Overview

Using flash memory for caching allows Linux kernel to service random disk IO with better performance than without the cache. This caching applies to all disk content, not just the page file or system binaries. Flash memory based devices are usually a magnitude faster than spinning HDDs for random IO, but with less advantage or even slower in sequential read/writes. By default, flashcache caches all full blocksize IOs, but can be configured to only cache random IO whilst ignoring sequential IO.
Similar technology exists in Microsoft Windows as ReadyBoost since Windows Vista.

Implementation

Flashcache is built on top of the Linux kernel's device mapper. The data structure of the cache is a set-associative hash table, in which the cache is divided up into a number of fixed-size sets, using linear probing within a set to find blocks. The device mapper layer breaks up all I/O requests into blocksize chunks before passing the requests to the cache layer.
When a write request happens, the corresponding cache block is marked dirty; dirty cache blocks are written lazily to disk in the background. There are a few parameters to control the write-back policy: dirty-threshold, idleness and contiguity with other dirty blocks about to be written back.

Limitations

There are a few limitations, imposed by the implementation of flashcache:
; Atomicity
; TRIM support
; Cache pollution protection
; Alignment
; Write-around read latency impact
; Write-around read cache warm-up phase