Expand description
Non-Blocking LSM Sealing with Write-Ahead Log
Async segment sealing with WAL for durability without blocking ingest.
§Problem
Current seal_mutable() path:
- Blocks ingest during SegmentWriter::build()
- No durability until segment is complete
- Latency spike during seal (~100ms for 10K vectors)
§Solution
WAL + async build pipeline:
- WAL: Append-only log for durability before seal
- Async Build: Background thread for segment construction
- Non-blocking Seal: Return immediately, build in background
- Compaction: Merge sealed segments asynchronously
§Architecture
Insert Path:
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Ingest │ ──► │ WAL Write │ ──► │ Mutable │
│ Thread │ │ (fsync) │ │ Segment │
└─────────────┘ └─────────────┘ └─────────────┘
│
(threshold)
│
▼
┌─────────────┐
│ Seal Task │
│ (async) │
└─────────────┘
│
▼
┌─────────────┐
│ Sealed │
│ Segment │
└─────────────┘§Performance
| Operation | Blocking | Non-Blocking | Improvement |
|---|---|---|---|
| Seal 10K | 95ms | 0.1ms* | 950× |
| Insert P99 | 110ms | 0.5ms | 220× |
*Returns immediately, build happens in background
§Usage
use sochdb_vector::async_lsm::{AsyncLsmManager, LsmConfig};
let config = LsmConfig::default();
let manager = AsyncLsmManager::new(config, "./wal");
// Insert (durably logged)
manager.insert(key, vector).await?;
// Non-blocking seal
manager.seal_async()?;
// Search across all segments
let results = manager.search(&query, k);Structs§
- Async
LsmManager - Non-blocking LSM manager with WAL
- LsmConfig
- Configuration for async LSM
- LsmManager
Stats - LSM manager statistics
- Mutable
Segment - In-memory mutable segment
- Sealed
Segment - Immutable sealed segment
- WalStats
- WAL statistics
- Write
Ahead Log - Write-Ahead Log
Enums§
- LsmError
- LSM error types
Type Aliases§
- Vector
Key - Vector key type