All Projects → kmcallister → seqloq

kmcallister / seqloq

Licence: Apache-2.0, MIT licenses found Licenses found Apache-2.0 LICENSE-APACHE MIT LICENSE-MIT
rwlock with writer priority and optimistic reads

Programming Languages

rust
11053 projects
python
139335 projects - #7 most used programming language

seqloq

Build Status

Seqlocks for Rust, inspired by the Linux kernel's implementation.

Check out the API documentation.

seqloq supports optimistic, lock-free reads of thread-shared data. The reader checks a sequence number before and after reading, and retries if the data structure changed during the read. When the workload consists mainly of reads, this can improve performance vs. a traditional mutex.

Here's a histogram for read latency on a 32-byte data structure, with a few infrequent writes and 200 concurrent readers:

read histogram

The write performance is also competitive:

write histogram

seqloq can also prevent starvation of writers, because writers have absolute priority.

To render your own histograms:

cargo build --release
./target/release/bench
./plot.py

The hard-coded ranges in plot.py will probably need adjustment for your machine.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].