- The Archil storage system cache is a durable, multi-Availability-Zone caching layer that runs server-side, between your clients and your data source. It’s where your active data is durably stored (a successful
fsync()commits to it) and where it’s metered, and it serves data with sub-millisecond latency. See Architecture for how it fits in. - The client-side cache is an in-memory cache inside each Archil client — one per mount. It holds recently used data so that repeated access is served locally, without even a round-trip to the storage system.
What the client caches
The client maintains several in-memory caches, all populated on demand as your application reads and writes:- File data — the contents of files. This is the bulk of the cache.
- File and directory attributes — metadata such as size, timestamps, and permissions (the result of a
stat). - Directory listings — the entries returned by
readdir(i.e.,ls), so repeated traversals of the same directory don’t round-trip to the server. - Extended attributes — when xattrs are enabled.
Cache size and eviction
The client’s in-memory data cache is bounded by two settings onarchil mount:
--max-cache-mb— the hard ceiling on the client cache size. Default: 1/4 of available RAM or 2048 MiB, whichever is smaller.--target-cache-mb— the size the client aims to keep the cache near, leaving headroom for bursts of new reads. Default: 75% of the maximum.
- Unflushed (dirty) writes — data you’ve written that hasn’t yet been committed to the storage system is always preserved locally, so eviction can never lose your writes.
- Entries still in use — anything an application currently has open is kept until it’s released.
Because the client cache is bounded, reading or pre-fetching more data than
--max-cache-mb can hold will evict earlier entries before you use them. Size the cache for your working set when you plan to keep a large data set hot on a client.Freshness and consistency
Serving reads from the client cache is what lets a client avoid contacting the storage system on every operation, which also means a client can serve stale data after another client changes a file. By default:- Opening a file checks it with the storage system, so reads after
opensee every write that reached the disk before it. - Attributes that
statreturns are cached for up to 30 seconds. - Directory listings, and the names learned from them, are cached for up to five minutes. Tune this per directory or for the whole mount with
archil set-cache-expiry.
Warming the client cache
By default the client cache fills lazily as data is read, so the first read of any file on a client pays the fetch latency. When you know which files you’ll need — loading a model, starting a database, or running a batch job over a known set of inputs — you can warm them ahead of time so the first read is already local. There are two ways to warm the client cache:archil prefetch <MOUNTPOINT> <PATH>...— pre-fetch files or directories (recursively) into the cache of an already-mounted disk. The command queues the work and returns immediately; fetching continues in the background.archil mount --pre-fetch <PATHS>— warm a comma-separated set of paths automatically as soon as the disk is mounted.
Pre-fetched data shares the client cache with normal reads, so it counts against
--max-cache-mb and is subject to the same eviction described above.mount --read-ahead <BYTES>, or pass 0 to disable it.
Warming the storage system cache with the API
On a miss in the storage system cache, the first read of a file waits on the backing data source. To take that wait out of the first read when you know which files a job will need, call Prefetch File Ranges before the job starts. It warms the files into the storage system cache, so later reads from any client, serverless exec, or sandbox are served from the cache. It needs no mounted client, so you can call it from a scheduler or control service before the work starts. Each range names one file by its path relative to the disk root, with an optionaloffset and length in bytes. A
range without them warms the whole file. A request can name up to 1,000 ranges.
bytesRequestedis the size of the range, andbytesWarmedis the part being fetched from the data source; the rest was already cached. The response can return before the fetch finishes.- A path that does not exist reports
found: false. - Ranges must name files. A directory is found but warms nothing, so list its files and pass each one.
- A range that could not be warmed carries
error:retryfor a transient failure worth retrying, orfailed. Other ranges in the request are unaffected.
Refreshing the client cache
To force a client to drop cached entries and re-read from the storage system — for example, when another client has updated files on a--shared or --conditional mount — use archil invalidate-cache. Pass the mount root to refresh everything, or a single file path to refresh just that file. In-flight (dirty) writes are always preserved.