PulseMap
A CPU cache-line hash table with zero-cost eviction.
π‘ Use PulseMap anywhere youβd use HashMap but canβt afford unbounded memory growth.
What is PulseMap?
PulseMap is a bounded, concurrent hash table where every bucket fits in exactly one 64-byte CPU cache line. Unlike HashMap which grows forever until you run out of memory, PulseMap has a fixed capacity and automatically evicts the least-useful entries when full.
Key insight: By packing metadata (state, H2 fingerprint, frequency counter, recency bits) into the same cache line as the data slots, eviction decisions cost zero additional cache misses.
Why PulseMap?
| Problem | HashMap | Redis | PulseMap |
|---|---|---|---|
| Memory growth | β Unbounded β OOM | β Bounded | β Bounded |
| Lookup latency | ~10ns | ~100ΞΌs (network) | ~5ns |
| Eviction | β None | β LRU | β LFU+LRU hybrid |
| Thread safety | β Mutex<HashMap> | β Single-threaded | β Per-bucket locks |
| GC pauses | N/A | N/A | Zero |
| Cache efficiency | β Random | N/A | β 1 cache line/bucket |
Quick Example
#![allow(unused)]
fn main() {
use pulse_map::ConcurrentPulseMap;
use std::sync::Arc;
use std::thread;
// Create a thread-safe map with auto-resize
let map = Arc::new(ConcurrentPulseMap::<String, u64>::with_auto_resize(256));
// Concurrent writes from 4 threads
let handles: Vec<_> = (0..4).map(|t| {
let m = map.clone();
thread::spawn(move || {
for i in 0..1000 {
m.insert(format!("key_{}", t * 1000 + i), i as u64);
}
})
}).collect();
for h in handles { h.join().unwrap(); }
// Read back
assert!(map.get(&"key_0".to_string()).is_some());
println!("Entries: {}, Evictions: {}", map.len(), map.eviction_count());
}
Features
- ποΈ Cache-Line Architecture β 64-byte buckets with 4 slots each
- β‘ Zero-Cost Eviction β LFU+LRU metadata embedded in bucket
- π Thread-Safe β Per-bucket spinlocks,
&selfAPI - ποΈ 16-Shard Concurrency β ShardedPulseMap: 2.4β3.1x faster than global lock
- β±οΈ Per-Entry TTL β Individual expiry per key, or global default
- π Bounded Memory β Fixed capacity, no unbounded growth
- π Auto-Resize β Optional dynamic growth at 75% load
- π C FFI Bindings β Use from C, or build your own language bridge
- π§ no_std Compatible β Core data structures work without allocator
Supported Platforms
| Platform | Status |
|---|---|
| Linux x86_64 | β |
| macOS x86_64 / ARM64 | β |
| Windows x86_64 | β |
| MSRV: Rust 1.70.0 | β |
License
Dual licensed under MIT or Apache-2.0.
Copyright (c) 2026 Deendayal Kumawat.