Ultra-fast, embedded key-value database for Rust with sub-microsecond latency.
📚 Documentation | 📊 Benchmarks | 💬 Issues
Features
- Sub-Microsecond Latency: <200ns GET, <600ns INSERT operations
- Lock-Free Concurrency: Built on DashMap and Crossbeam SkipList
- io_uring Support (Linux): Kernel-bypass I/O for maximum throughput with minimal syscalls
- Flexible Storage: Memory-only or persistent modes with async I/O
- JSON Patch Support: RFC 6902 compliant partial updates for JSON values
- Atomic Counters: Thread-safe increment/decrement operations
- Write Buffering: Sharded buffers with batched writes to reduce contention
- CLOCK Cache: Second-chance eviction algorithm
- Statistics: Real-time performance monitoring
- Free Space Management: Dual RB-tree structure for O(log n) allocation
- Zero Fragmentation: Automatic coalescing prevents disk fragmentation
ACID Properties and Durability
FeOxDB provides ACI properties with relaxed durability:
- Atomicity: ✅ Individual operations are atomic via Arc-wrapped records
- Consistency: ✅ Timestamp-based conflict resolution ensures consistency
- Isolation: ✅ Lock-free reads and sharded writes provide operation isolation
- Durability: ⚠️ Write-behind logging with bounded data loss window
Durability Trade-offs
FeOxDB trades full durability for extreme performance:
- Write-behind buffering: Flushes every 100ms or when buffers fill (1024 entries or 16MB per shard)
- Worst-case data loss:
- Time window:
100ms + 16MB / 4KB_random_write_QD1_throughput - Data at risk:
16MB × num_shards (num_shards = num_cpus / 2)(e.g., 64MB for 4 shards, 128MB for 8 shards) - Workers write in parallel, so time doesn't multiply with shards
- Example (50MB/s 4KB random QD1): 420ms window, up to 64MB at risk (4 shards)
- Example (200MB/s 4KB random QD1): 180ms window, up to 64MB at risk (4 shards)
- Time window:
- Memory-only mode: No durability, maximum performance
- Explicit flush: Call
store.flush()to synchronously write all buffered data (blocks until fsync completes)
FAQ:
Q: Would the durability tradeoff for extreme performance worth it?
- For KV stores, there are more use cases that can accept this slightly relaxed durability model than not. of course this isn't the case for a main DB, but KV stores often handle derived data, caches, or state that can be rebuilt.
That said, for cases needing stronger durability, you can call
store.flush()after critical operations - gives you fsync-level guarantees. The philosophy is: make the fast path really fast for those who need it, but provide escape hatches for stronger guarantees when needed.
Q: What kind of applications would need this performance? Why these latency numbers matter?
-
The real value isn't just raw speed - it's efficiency. When operations complete in 200ns instead of blocking for microseconds/milliseconds on fsync, you avoid thread pool exhaustion and connection queueing. Each sync operation blocks that thread until disk confirms - tying up memory, connection slots, and causing tail latency spikes.
With FeOxDB's write-behind approach:
- Operations return immediately, threads stay available
- Background workers batch writes, amortizing sync costs across many operations
- Same hardware can handle 100x more concurrent requests
- Lower cloud bills from needing fewer instances
For desktop apps, this means your KV store doesn't tie up threads that the UI needs. For servers, it means handling more users without scaling up. The durability tradeoff makes sense when you realize most KV workloads are derived data that can be rebuilt. Why block threads and exhaust IOPS for fsync-level durability on data that doesn't need it?
Quick Start
Installation
[]
= "0.1.0"
Basic Usage
use FeoxStore;
Persistent Storage
use FeoxStore;
Advanced Configuration
use FeoxStore;
Concurrent Access
use FeoxStore;
use Arc;
use thread;
Range Queries
use FeoxStore;
JSON Patch Operations (RFC 6902)
FeOxDB supports partial updates to JSON documents using the standard JSON Patch format:
use FeoxStore;
Supported JSON Patch operations:
add: Add a new field or array elementremove: Remove a field or array elementreplace: Replace an existing valuemove: Move a value from one path to anothercopy: Copy a value from one path to anothertest: Test that a value at a path equals a specified value
Atomic Counter Operations
use FeoxStore;
Performance
Benchmarks
Run the included benchmarks:
# Performance test
# Deterministic test
# Criterion benchmarks
Results
Typical performance on M3 Max:
| Operation | Latency | Throughput | Notes |
|---|---|---|---|
| GET | ~200-260ns | 2.1M ops/sec | DashMap lookup + stats |
| INSERT | ~700ns | 850K ops/sec | Memory allocation + indexing |
| DELETE | ~290ns | 1.1M ops/sec | Removal from indexes |
| Mixed (80/20 R/W) | ~290ns | 3.1M ops/sec | Real-world workload |
Throughput
Based on Criterion benchmarks:
- GET: 8.2M - 10.5M ops/sec (varies by batch size)
- INSERT: 730K - 1.1M ops/sec (varies by value size)
- Mixed workload (80/20): 3.1M ops/sec
Architecture
FeOxDB uses a lock-free, multi-tier architecture optimized for modern multi-core CPUs:
Lock-Free Design
The entire hot path is lock-free, ensuring consistent sub-microsecond latency:
- DashMap: Sharded hash table with lock-free reads and fine-grained locking for writes
- Crossbeam SkipList: Fully lock-free ordered index for range queries
- Atomic Operations: All metadata updates use atomic primitives
- RCU-style Access: Read-Copy-Update pattern for zero-cost reads
Async Write-Behind Logging
Writes are decoupled from disk I/O for maximum throughput:
-
Sharded Write Buffers
- Multiple buffers with thread-consistent assignment
- Reduces contention between threads
- Cache-friendly access patterns
-
Batched Flushing
- Writes accumulated and flushed in batches
- Optimal disk utilization with large sequential writes
- Configurable flush intervals
-
io_uring Integration (Linux)
- Kernel-bypass I/O with submission/completion queues
- Zero-copy operations where possible
- Async I/O without thread pool overhead
-
Write Coalescing
- Multiple updates to same key automatically merged
- Reduces write amplification
- Improves SSD lifespan
Storage Tiers
-
In-Memory Layer
- Primary storage in DashMap
- O(1) lookups with ~100ns latency
- Automatic memory management
-
Write Buffer Layer
- Sharded buffers for concurrent writes
- Lock-free MPSC queues
- Backpressure handling
-
Persistent Storage
- Sector-aligned writes (4KB blocks)
- Write-ahead logging for durability
- Crash recovery support
-
Cache Layer
- CLOCK eviction algorithm
- Keeps hot data in memory after disk write
- Transparent cache management
API Documentation
Full API documentation is available:
Key types:
FeoxStore- Main database interfaceStoreBuilder- Configuration builderFeoxError- Error typesStatistics- Performance metrics
Examples
See the examples/ directory for more:
performance_test.rs- Benchmark tooldeterministic_test.rs- Reproducible performance test
Contributing
Contributions are welcome! See CONTRIBUTING.md for more information.
License
Copyright 2025 Mehran Toosi
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
See LICENSE for the full license text.