Expand description
Cache-line aligned types for high-performance operations.
Modern CPUs have 64-byte cache lines. Proper alignment prevents:
- False sharing in concurrent code
- Cache line splits during loads/stores
- Suboptimal prefetching
§Usage
use moloch_core::aligned::{AlignedHash, AlignedHashArray};
use moloch_core::Hash;
// Single aligned hash (for hot paths)
let some_hash = Hash::ZERO;
let hash = AlignedHash::from(some_hash);
// Batch of aligned hashes (for SIMD operations)
let hashes = [Hash::ZERO; 4];
let mut batch = AlignedHashArray::<8>::default();
for (i, h) in hashes.iter().enumerate() {
batch.set(i, *h);
}Structs§
- Aligned
Hash - A hash aligned to a cache line boundary.
- Aligned
Hash Array - An array of hashes aligned to cache line boundaries.
- Cache
Line Padded - A cache-line padded wrapper to prevent false sharing.
Constants§
- CACHE_
LINE_ SIZE - Cache line size on most modern CPUs (Intel, AMD, ARM).