Overview
The Filesystem store provides persistent local storage by storing data on the filesystem. This store is designed for local persistent storage where restarts preserve state, making it ideal for standalone deployments or worker nodes that need durable local caching.Use Cases
- Local development environments: Fast, persistent storage for development and testing
- Worker node caching: Persistent cache on worker machines to survive restarts
- Standalone deployments: Single-machine installations without cloud storage
- Fast local tier: Primary storage in fast-slow configurations with network-backed slow tier
Performance Characteristics
- Read performance: Depends on disk I/O capabilities (SSD recommended)
- Write performance: Controlled by
max_concurrent_writesto prevent disk saturation - Durability: Data survives restarts as long as filesystem integrity holds
- Startup time: Content path is scanned on bootup; files not matching criteria are deleted
Configuration
Path on the system where to store the actual content. This is where the bulk of the data will be placed.On service bootup this folder will be scanned and all files will be added to the cache. Files that don’t match the criteria will be deleted.Supports shell expansion (e.g.,
~/.cache/nativelink).A temporary location where files being uploaded or deleted will be placed while content cannot be guaranteed to be accurate.Important: This location must be on the same block device as
content_path so atomic moves can happen (move without copy).All files in this folder are deleted on every startup.Policy used to evict items out of the store. Failure to set this value will cause items to never be removed from the store causing unbounded disk usage.See Eviction Policy for configuration options.
Buffer size to use when reading files in bytes. Generally this should be left to the default value except for testing.Default: 32KB (32768 bytes)
The block size of the filesystem for the running machine. This value is used to determine an entry’s actual size on disk consumed.For example, on a 4KB block size filesystem, a 1-byte file actually consumes 4KB on disk.Default: 4096 bytes (4KB)
Maximum number of concurrent write operations allowed.Each write involves streaming data to a temp file and calling
sync_all(), which can saturate disk I/O when many writes happen simultaneously. Limiting concurrency prevents disk saturation from blocking the async runtime.A value of 0 means unlimited (no concurrency limit).Default: 0 (unlimited)Eviction Policy
The eviction policy uses LRU (Least Recently Used) algorithm. Any time an entry is accessed, it updates the timestamp. Inserts and updates execute the eviction policy, removing expired entries and/or the oldest entries until the store size becomes smaller thanmax_bytes.
Maximum number of bytes before eviction takes place.Default: 0 (never evict based on size)
When eviction starts based on hitting
max_bytes, continue until max_bytes - evict_bytes is met to create a low watermark. This stops operations from thrashing when the store is close to the limit.Default: 0Maximum number of seconds for an entry to live since it was last accessed before it is evicted.Default: 0 (never evict based on time)
Maximum number of entries in the store before eviction takes place.Default: 0 (never evict based on count)
Configuration Examples
Basic Filesystem Store
With Shell Expansion
Advanced Configuration with Concurrency Control
With Time-Based Eviction
Implementation Details
File Organization
The filesystem store organizes files into two categories:- Digest-based files: Stored in the
d/subdirectory - String-based keys: Stored in the
s/subdirectory
Atomic Operations
Files are first written totemp_path and then atomically moved to content_path. This ensures that:
- Partial writes are never visible to readers
- The temp path must be on the same filesystem/block device as content path
- Moves are atomic operations without data copying
Startup Behavior
On startup, the filesystem store:- Scans the
content_pathdirectory - Adds all valid files to the cache
- Deletes files that don’t match the expected criteria
- Clears all files from
temp_path
Best Practices
Ensure temp and content paths are on the same filesystem: This requirement is critical for atomic move operations to work correctly.