Skip to content

Repository files navigation

SKL

github Build codecov

docs.rs crates.io rustc

license-apache license-mit

A lock-free thread-safe concurrent ARENA based skiplist implementation which helps develop MVCC memtable for LSM-Tree. Inspired by Dgraph's badger.

Installation

[dependencies]
skl = "0.3"

Example

use skl::Skiplist;
use std::sync::Arc;

fn main() {
    const N: usize = 1000;
    let l = Arc::new(Skiplist::new(1 << 20));
    let wg = Arc::new(());
    for i in 0..N {
        let w = wg.clone();
        let l = l.clone();
        std::thread::spawn(move || {
            l.insert(key(i), new_value(i));
            drop(w);
        });
    }
    while Arc::strong_count(&wg) > 1 {}
    for i in 0..N {
        let w = wg.clone();
        let l = l.clone();
        std::thread::spawn(move || {
            assert_eq!(
                l.get(key(i)).unwrap().as_value_ref(),
                new_value(i).as_value_ref(),
                "broken: {i}"
            );
            drop(w);
        });
    }
}

Tests

  • test:

    cargo test --all-features
  • miri:

    cargo miri test --all-features

Support Platforms

targets status
aarch64-linux-android
aarch64-unknown-linux-gnu
aarch64-unknown-linux-musl
i686-pc-windows-gnu
i686-linux-android
i686-unknown-linux-gnu
mips64-unknown-linux-gnuabi64
powerpc64-unknown-linux-gnu
riscv64gc-unknown-linux-gnu
wasm32-unknown-unknown
wasm32-unknown-emscripten
x86_64-unknown-linux-gnu
x86_64-pc-windows-gnu
x86_64-linux-android

TODO (help wanted)

  • make the crate test cases pass cargo miri
  • make the crate test cases pass cargo loom

License

skl-rs is under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE, LICENSE-MIT for details.

Copyright (c) 2022 Al Liu.

About

A lock-free thread-safe concurrent SkipMap implementation based on ARENA skiplist which helps develop MVCC memtable for LSM-Tree.

Topics

Resources

Stars

67 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

Generated from al8n/template-rs