Ṛta (ऋत)
Ṛta (ऋत) is a minimal metadata store for durable system state.
The type T
T must satisfy following layout and safety constraints:
- Implements
RTA - Uses
#[repr(C)] - 8 bytes alignment
- Does not implements
Drop - Size must be >0 and multiple of 8
- Implements
Default + Clone + Send + Sync + 'static
Limitations of T
- No non-deterministic feilds
- No interior pointers or self-references
- Changes made in struct layout break compatibility
Example
use ;
const MOD_ID: u8 = 0;
let path = new.unwrap.into_temp_path.to_path_buf;
let rta = new.unwrap;
rta.write.unwrap;
let val = rta.read.unwrap;
assert_eq!;
assert_eq!;
Writes
The [Rta::write()] operation in Rta is designed as a lightweight fire-and-forget metadata update primitive.
This call itself does not wait for disk synchronization on the fast path, allowing extremely low write latency
while still preserving crash-safe durability semantics by handing off durability responsibility to a background
thread.
Guarantees
Following guarantees are provided,
- serialized metadata updates
- crash-safe durability via multiple on-disk copies
- automatic recovery from torn writes using latest valid version
Benchmarks
| Metric | Latency |
|---|---|
| Average | 83 ns |
| P50 | 101 ns |
| P90 | 102 ns |
| P99 | 102 ns |
| P999 | 102 ns |
Notes
- Most writes complete in ~100ns on the uncontended fast path.
- The benchmark primarily measures,
- lock acquisition
- in-memory mutation
- dirty state propagation
- Disk durability is handled asynchronously by a dedicated background thread.
- Tail latency may increase if writes overlap with active durability synchronization.
Reads
The [Rta::read()] operation returns the latest available in-memory metadata state.
The read path is optimistic and does not provide durability guarantees at read time. Instead, reads are served directly from the synchronized in-memory cache, avoiding any disk IO overhead.
Guarantees
Following guarantees are provided,
- lock-safe concurrent access
- latest available in-memory metadata view
- no torn or partially visible updates
- parallel read operations
Notes
- Reads are performed entirely from the in-memory cache.
- No mmap scan or disk synchronization occurs during the read path.
- Read latency generally remains stable even during background durability synchronization.
Concurrency Model
| Operation | Parallelism | Blocks Reads | Blocks Writes |
|---|---|---|---|
| Read | Yes | No | No |
| Write | Limited | No | Sometimes |
Etymology
ऋत (transliterated as Ṛta) is a Vedic concept of cosmic order, truth, and invariance that inspired the design of Ṛta crate.