24 releases

0.4.6 Aug 20, 2024
0.4.5 Aug 5, 2023
0.4.3 Jul 10, 2023
0.3.0 Oct 3, 2022
0.0.1 Jun 3, 2018

#289 in Database interfaces

Download history 214/week @ 2024-09-11 221/week @ 2024-09-18 178/week @ 2024-09-25 117/week @ 2024-10-02 116/week @ 2024-10-09 76/week @ 2024-10-16 76/week @ 2024-10-23 120/week @ 2024-10-30 177/week @ 2024-11-06 187/week @ 2024-11-13 77/week @ 2024-11-20 85/week @ 2024-11-27 157/week @ 2024-12-04 225/week @ 2024-12-11 121/week @ 2024-12-18 27/week @ 2024-12-25

544 downloads per month
Used in 15 crates (2 directly)

MIT/Apache

12KB
220 lines

pagetable

Wait-free 4-level page table that maps from a u64 key to an &AtomicU64 value. Page fan-out is 2^16. If a key doesn't exist, intermediate pages are atomically created while traversing down the levels, and the value is initialized to 0.

This is a somewhat specialized data structure, but it is useful for maintaining metadata in concurrent systems that need to track many items that have an associated logical ID that is allocated from a dense keyspace, like databases that would like to keep track of where a page lives based on its 64-bit ID, despite it being rewritten in random places during defragmentation.

API

#[derive(Default)]
pub struct PageTable { .. }

pub fn get(&self, key: u64) -> &AtomicU64 { .. }

Example

let pt = PageTable::default();

for i in 0..100_000_000 {
    pt.get(i).fetch_add(1, Ordering::SeqCst);
}

for i in 0..100_000_000 {
    let value = pt.get(i).load(Ordering::SeqCst);
    assert_eq!(value, 1);
}

No runtime deps