| Crates.io | kira_kv_engine |
| lib.rs | kira_kv_engine |
| version | 0.2.1 |
| created_at | 2025-08-11 20:13:58.558044+00 |
| updated_at | 2026-01-17 19:24:56.079795+00 |
| description | KV-storage engine based on minimal perfect hash functions with hybrid indexing (+PGM Index) for Rust |
| homepage | https://github.com/ARyaskov/kira_kv_engine |
| repository | https://github.com/ARyaskov/kira_kv_engine |
| max_upload_size | |
| id | 1790806 |
| size | 137,296 |
KV-storage engine based on Minimal perfect hash functions with hybrid indexing (+PGM Index) for Rust.
Zero collisions. PureO(1)performance.
Built on the BDZ algorithm using 3-hypergraph peeling:
n keys to n unique indicesπ Research: Simple and Space-Efficient Minimal Perfect Hash Functions (Botelho, Pagh, Ziviani, 2007)
For numeric data, we layer in PGM (Piecewise Geometric Model) indexing:
O(log log n) worst-case with O(1) average lookupsπ Research: The PGM-index: a fully-dynamic compressed learned index (Ferragina, Vinciguerra, 2020)
[dependencies]
kira_kv_engine = "*"
use kira_kv_engine::HybridBuilder;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let keys = vec![
1000u64.to_le_bytes().to_vec(),
b"user:123".to_vec(),
b"session:abc".to_vec(),
];
let index = HybridBuilder::new().build_index(keys)?;
println!("{:?}", index.lookup_u64(1000));
println!("{:?}", index.lookup_str("user:123"));
Ok(())
}
Full API reference: API.md.
Run comprehensive benchmarks across algorithms:
cargo run --example million_build --release
kira_kv_engine benchmark
n = 1000000 keys
============================================================
Struct Workload Cache Build ms Build rate Lookup ns Throughput Hit % Miss % B/key
--------------------------------------------------------------------------------------------------------------
MPH positive cold 730.47 1368978 45.68 21890221 100.0 0.0 5.00
MPH positive warm 730.47 1368978 48.63 20564495 100.0 0.0 5.00
MPH negative cold 730.47 1368978 59.90 16693331 70.0 30.0 5.00
MPH negative warm 730.47 1368978 25.44 39308176 70.0 30.0 5.00
MPH zipf cold 730.47 1368978 44.54 22453413 100.0 0.0 5.00
MPH zipf warm 730.47 1368978 32.64 30633332 100.0 0.0 5.00
Struct Workload Cache Build ms Build rate Lookup ns Throughput Hit % Miss % B/key
--------------------------------------------------------------------------------------------------------------
PGM positive cold 17.54 57012543 344.91 2899293 100.0 0.0 48.00
PGM positive warm 17.54 57012543 249.22 4012546 100.0 0.0 48.00
PGM negative cold 17.54 57012543 245.52 4072946 70.0 30.0 48.00
PGM negative warm 17.54 57012543 238.69 4189462 70.0 30.0 48.00
PGM zipf cold 17.54 57012543 265.71 3763490 100.0 0.0 48.00
PGM zipf warm 17.54 57012543 262.75 3805851 100.0 0.0 48.00
Struct Workload Cache Build ms Build rate Lookup ns Throughput Hit % Miss % B/key
--------------------------------------------------------------------------------------------------------------
Hybrid positive cold 424.66 2354848 159.01 6288715 100.0 0.0 22.20
Hybrid positive warm 424.66 2354848 152.59 6553366 100.0 0.0 22.20
Hybrid negative cold 424.66 2354848 154.28 6481581 70.0 30.0 22.20
Hybrid negative warm 424.66 2354848 119.85 8343820 70.0 30.0 22.20
Hybrid zipf cold 424.66 2354848 149.25 6700093 100.0 0.0 22.20
Hybrid zipf warm 424.66 2354848 125.22 7985839 100.0 0.0 22.20
Configuration options are documented in API.md.
Perfect for:
O(1) lookup requirementsNot suitable for:
gamma β 1.25 for datasets > 10M keysparallel feature for build-time speedupWeb Servers:
Databases:
Gaming: