# 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?
| 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
```rust
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, `&self` API
- **ðïļ 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
| Linux x86_64 | â
|
| macOS x86_64 / ARM64 | â
|
| Windows x86_64 | â
|
| MSRV: Rust 1.70.0 | â
|
## License
Dual licensed under [MIT](../LICENSE-MIT) or [Apache-2.0](../LICENSE-APACHE).
Copyright (c) 2026 Deendayal Kumawat.