Skip to main content

Crate dualcache_ff

Crate dualcache_ff 

Source
Expand description

§DualCache-FF (Fast and Furious)

A highly opinionated, absolutely wait-free concurrent cache in Rust, optimized for extreme read-to-write ratios and scan-resistance. Built for high-performance and no_std embedded target environments.

§🧠 Key Concepts & Features

  • Wait-Free Read Path & QSBR: All reads are completely non-blocking and wait-free. Memory reclamation is handled via Quiet State Based Reclamation (QSBR), allowing readers to instantly access cached nodes without locks, mutexes, or atomic reference counting overhead.
  • Three-Tier Promotion System:
    • T1 (Hot Cache): A high-speed AtomicPtr slot array mapping to Cache indices for instant lookup.
    • T2 (Secondary Filter): A larger slot array for capturing secondary heat patterns.
    • Cache (Main Storage): The source of truth using an open-addressed index (Linear Probing).
  • Asynchronous Daemon & Batched Telemetry: Cache admissions and evictions are handled exclusively by an asynchronous background daemon. Read/write telemetry is buffered locally in Thread-Local Storage (TLS) and periodically flushed to the daemon via a custom lock-free LossyQueue.
  • Avg-based Clock Eviction: A revolution-shielded circular clock evicts items whose access rank falls below the global average, instantly adapting to shifting workload heat distributions.
  • no_std / Bare-Metal Fallback: Out-of-the-box support for resource-constrained environments via StaticDualCache, using atomic spinlocks to eliminate background threads and achieve zero idle power.

Structs§

CachePadded
Cache-line-aligned wrapper to prevent false sharing between worker slots. Uses #[repr(C, align(N))] directly:
Config
Daemon
DefaultSpawner
DefaultTls
DualCacheFF
StaticDualCache
A synchronous, wait-free read / spin-locked write cache interface. Serves as the standard no_std fallback when background Daemon processing is undesirable.
WorkerState
Per-worker QSBR state — cache-line padded to prevent false sharing between workers checking in/out simultaneously.