Expand description
Cache-Line Aligned Key Buffer with Stack Allocation
This module provides zero-allocation key construction for database operations. Every database operation currently allocates a heap string via format!(), which is inefficient for high-throughput scenarios.
§Problem Analysis
let path = format!("{}/{}/{}", table, row_id, col.name); // HEAP ALLOC!Allocation costs:
format!()callsalloc::alloc::alloc()→ ~50-100 cycles- Cache pollution from temporary allocations
- GC pressure in concurrent scenarios
§Solution
Stack-allocated, cache-line aligned key buffers:
- Zero heap allocation
- Cache-line aligned for optimal memory access
- Pre-computed table prefixes for repeated operations
§Performance
Current: T_key ≈ 83ns (allocation + formatting) Proposed: T_key ≈ 15ns (stack buffer + fast formatting) Speedup: 5.5×
Structs§
- Arena
Key - Zero-copy key reference into arena memory
- Arena
KeyHandle - An owned key handle that can be stored in DashMap, SkipMap, etc.
- Batch
KeyGenerator - Batch key generator for bulk operations
- Interned
Table Prefix - Interned table prefix for repeated use
- KeyArena
- Thread-local arena allocator for key buffers
- KeyBuffer
- Fixed-size key buffer - NO HEAP ALLOCATION
Constants§
- MAX_
KEY_ LENGTH - Maximum key length (cache line - length byte)