pagetable

Crates.iopagetable
lib.rspagetable
version0.4.6
sourcesrc
created_at2018-06-03 22:33:54.34477
updated_at2024-08-20 06:14:35.157985
descriptionWait-free 4-level 64-bit pagetable for roughly-contiguous keys.
homepage
repositoryhttps://github.com/komora-io/pagetable
max_upload_size
id68402
size25,629
Tyler Neely (spacejam)

documentation

https://docs.rs/pagetable/

README

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);
}
Commit count: 21

cargo fmt