What is Adaptive Replacement Cache (ARC)?
In a traditional file system, the "Read Cache" uses a simple logic: Least Recently Used (LRU). If the cache is full and new data comes in, the "oldest" data is kicked out.
The Adaptive Replacement Cache (ARC) in ZFS is much smarter. It doesn't just look at how recently you used data; it looks at how frequently you used it, and it constantly adjusts its strategy based on your specific workload.
Instead of one big bucket, the ARC manages four distinct lists to decide what stays in your precious RAM:
Most Recently Used (MRU): Data that was accessed once. This is "new" data that might be useful again soon.
Most Frequently Used (MFU): Data that has been accessed multiple times. This is your "hot" data (like database indexes or frequently used system files).
Ghost MRU: A list of metadata for entries recently evicted from the MRU.
Ghost MFU: A list of metadata for entries recently evicted from the MFU.
The "Ghost" lists are the genius of the ARC. They don't store actual data (so they take up almost no RAM), but they remember what used to be in the cache.
If a "Ghost MRU" hit occurs: ZFS realizes it is evicting recent data too fast. It automatically expands the MRU portion of your RAM and shrinks the MFU.
If a "Ghost MFU" hit occurs: ZFS realizes it is evicting frequently used data too fast. It expands the MFU portion of your RAM.
This allows the ARC to self-tune. If you start a massive file backup (recent data), the MRU grows. If you switch to running a database (frequent data), the MFU grows.
A major weakness of standard LRU caches is a Full System Scan (like an antivirus scan or a large grep). A scan touches every file once, which would normally flush all your "hot" database data out of the cache to make room for files you'll never touch again.
The ARC solves this: Since the files in a scan are only accessed once, they stay in the MRU. They never make it into the MFU. Your "hot" data in the MFU remains protected and stays in RAM, even while a massive scan is happening in the background.
If your RAM is full, the ARC can't grow any further. This is where the L2ARC (Level 2 ARC) comes in.
The Spillway: When data is about to be evicted from the RAM-based ARC, ZFS can "spill" it onto a fast SSD (the L2ARC) instead of deleting it entirely.
The Trade-off: While much slower than RAM, the L2ARC is still significantly faster than spinning disks. It allows you to have terabytes of "warm" cache for a fraction of the cost of RAM.
| Feature | Standard (LRU) Cache | ZFS ARC |
| Primary Logic | Recency only (Time). | Recency AND Frequency. |
| Scan Protection | None (Scans wipe the cache). | Built-in (Protects MFU data). |
| Self-Tuning | Static/Manual. | Dynamic (Uses Ghost lists to adapt). |
| Efficiency | Simple, but wasteful. | Highly optimized for complex workloads. |
The ARC is the reason ZFS is famous for its performance. By using the "Ghost" lists to track what should have been in the cache, ZFS creates a system that learns your behavior and optimizes itself in real-time. It is the most advanced read-cache algorithm available in any file system today.