Skip to main content

Crate rta

Crate rta 

Source
Expand description

Ṛ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

§Requirements for type T

The type T must not,

  • Have any non-deterministic feilds
  • Have interior pointers or self-references
  • Have changes made to the layout after Rta::init()

§Write

The Rta::write is designed as a lightweight fire and forget metadata update premitive. The call itself does not wait for the filesystem durability, allowing sub-mirco second write latency.

Apps requireing stronger durability can explicitly wait or block on the returned frozen_core::ack::AckTicket using either the asynchronous await interface or the internal blocking wait() api.

Every write guarantees,

  • Serialized object updates
  • Crash-safe durability using multiple on-disk copies
  • Automatic recovery from torn or interrupted writes by selecting the newest valid version during initialization

Observed measurements for latency (both single and multi-threaded) on 1,048,576 operations,

MetricSingle TX (µs)Multi TX (µs)
P500.18300.4590
P900.27500.7330
P991216.51101.0090
Mean38.08998.7255
Max28606.463021790.7190

Observed measurements for latency (both single and multi-threaded) on 4,096 operations, where every write waits for filesystem durability,

MetricSingle TX (ms)Multi TX (ms)
P501.18991.2820
P901.29022.8078
P991.51655.2634
Mean1.18851.7603
Max31.391730.1793

§Read

The Rta::read is a wait-free fast-path read which reads the most recently updated T directly from the underlying memory mapping.

A successful read reflects the latest published write, but does not imply that the object has been durably persisted to the filesystem. To guarantee durability, wait on the ticket returned by Rta::write.

Observed measurements for latency (both single and multi threaded) on 1,048,576 individual ops,

MetricSingle TX (µs)Multi TX (µs)
P500.00000.0910
P900.09100.1830
P990.09200.8210
MEAN0.02050.1362
MAX38.07905013.5030

§Example

use rta::{RTA, Rta, RtaCfg};

#[repr(C)]
#[repr(align(8))]
#[derive(Debug, Clone, Default, RTA)]
struct Config {
    value: u64,
}

let dir = tempfile::tempdir().expect("failed to create temp directory");
let rta = Rta::<Config>::new(RtaCfg {
    module_id: 0,
    copies_on_disk: 4,
    path: dir.path().join("config.rta"),
})
.expect("failed to create RTA");

let ticket = unsafe {
    rta.write(|cfg| {
        cfg.value = 0x2A;
    })
}
.expect("write failed");

ticket.wait().expect("durability failed");

let cfg = unsafe { rta.read() };
assert_eq!(cfg.value, 0x2A);

Structs§

Rta
Ṛta (ऋत) is a minimal metadata store for durable system state
RtaCfg
Configuration used when creating an Rta instance

Traits§

RTA
Derive the rta::RTA trait for the struct T

Derive Macros§

RTA
Procedural macro implementation for #[derive(RTA)] Derives the rta::RTA trait for a struct T