| Crates.io | lake |
| lib.rs | lake |
| version | 0.2.0 |
| created_at | 2025-07-26 04:58:43.419964+00 |
| updated_at | 2025-07-28 15:22:44.779443+00 |
| description | Lake is a high-octane memory pool with direct access, checkpoints, rollback, and zero-allocation droplets. No GC. No overhead. Just you and the bytes β total control. Allocate like a cyber-samurai. |
| homepage | |
| repository | https://github.com/TachyonConcepts/lake |
| max_upload_size | |
| id | 1768824 |
| size | 1,383,218 |
A fast, zero-cost, and deeply controllable memory system β not just an allocator, but a memory lake.
Lake is a linear memory management system designed for extreme performance, zero-cost abstractions, and full control. Inspired by bump allocators β but not limited by them β Lake offers a rich API for precise and predictable memory handling.
Unlike traditional arenas or bump allocators, Lake is built for high-performance, real-time, and system-level workloads where memory layout and allocation offsets matter. It enables:
Whether you're building a high-frequency trading engine, a zero-copy deserialization layer, or a custom HTTP server handling millions of requests per second β Lake gives you the tools without getting in your way.
This is not a GC, not a toy arena, and not another abstraction.
This is your memory β and youβre in charge.
Lake aims to be developer-friendly, but at its core, it is a low-level memory management tool.
While most APIs are safe and ergonomic, incorrect usage can lead to panics or undefined behavior (UB) β especially when bypassing safe abstractions or misusing droplets and snapshots.
If you treat Lake with care β using the API correctly and understanding its semantics β you'll be rewarded with:
But misuse it β and your service might panic, crash, or worse.
β οΈ Respect the lake. Know where you're swimming.
| Crate | Avg time (ns) | 95% interval |
|---|---|---|
| lake | 2_229.48 | 2_220.35 β 2_241.00 |
| mimalloc | 5_660.63 | 5_610.67 β 5_739.64 |
| box_heap | 2_371_303.85 | 2_364_276.32 β 2_378_224.65 |
| heapless_vec | 5_104_258.91 | 5_074_069.63 β 5_136_300.93 |
| bump-scope | 8_064_223.05 | 7_936_244.90 β 8_233_482.12 |
| bumpalo | 8_424_838.02 | 8_392_666.31 β 8_459_892.26 |
| scoped-arena | 19_889_320.26 | 19_716_379.07 β 20_112_506.23 |
| typed-arena | 20_121_930.44 | 19_938_222.96 β 20_332_554.67 |
| vec_box | 36_881_416.34 | 36_304_472.75 β 37_555_579.94 |
.mark() , .reset_to_mark(), .move_mark() for checkpoint-style rewinding..reset() or Drop for full rewind of the arena.thread_lake_init();
with_lake!(|lake| {
let d = lake.alloc::<256>().unwrap();
// ...
});
Lightweight, global-free access to arena memory per thread.
.mark() β save current offset (push).reset_to_mark() β rewind to last mark (pop).move_mark() β update last mark to current position.snapshot() β returns a lightweight LakeSnapshot.rewind(snapshot) β restores exact state[u8; N], optionally leakable into 'static slice..process() closures.
process(f) for dynamic data: Create a DropletDyn from a closure-generated buffer (e.g. serialize-once, write-once patterns)..is_valid() to check droplet liveness.let static_ref: &'static [u8; 128] = unsafe { droplet.leak() };
.alloc<N>(), .process(), .alloc_struct<T>(), .alloc_slice<T>().split(len) β ideal for:
.reset(), .mark(), and .clear() work per-view..set_zeroing(true) to wipe memory on reuse β useful for:
sandbox() to enter a scope β all allocations are virtual until committed..commit() β keep the changes (offset += delta)Drop β rollback automatically if not committedthread_lake_init()with_lake! { ... } macro to access the thread's private Lakealloc, droplets, sandbox, mark, etc.align_up(offset, align) β Minimal overhead alignment helper for struct and slice placement
alloc_struct<T> and alloc_slice<T> for correct in-place layout'static lifetime by leaking them in a Box, wrapped in a transparent type to preserve Send/Sync correctness.static CONFIG: &mut MyConfig = FBC!(MyConfig::new());
FBCWrap<T> β Transparent wrapper used by FBC!, safe for multithreaded use via Send + Sync