https://github.com/friendlymatthew/eytzinger
https://github.com/friendlymatthew/eytzinger
cache-locality eytzinger-binary-search
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/friendlymatthew/eytzinger
- Owner: friendlymatthew
- Created: 2024-07-12T17:50:32.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-07-12T18:54:32.000Z (almost 2 years ago)
- Last Synced: 2025-02-06T08:12:31.915Z (over 1 year ago)
- Topics: cache-locality, eytzinger-binary-search
- Language: Rust
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# eytzinger search
A cache-friendly binary search implementation using the Eytzinger layout.
```rust
fn main() {
let data = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
let eyt = EytzingerVec::from_slice(&data);
let res = eyt.search(8);
assert_eq!(res, 1); // returns the index of element
let res = eyt.search(69);
assert_eq!(res, 0); // returns 0 if not found
}
```
## Prefetching
This implementation makes use of `core_intrinsics::prefetch_read_data` to work across different targets. Temporal
locality is set to `3`, indicating maximum temporal locality.
## Memory Alignment
`AlignedVec` holds the `#[repr(align(64))]` attribute. This ensures the vector is aligned to 64-byte cache lines,
optimizing memory access patterns.
## Literature
* **https://algorithmica.org/en/eytzinger**
* https://arxiv.org/pdf/1509.05053