https://github.com/pimaker/putex
Pi's experimental Mutex in Rust
https://github.com/pimaker/putex
Last synced: 11 months ago
JSON representation
Pi's experimental Mutex in Rust
- Host: GitHub
- URL: https://github.com/pimaker/putex
- Owner: PiMaker
- Created: 2020-09-24T19:41:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-25T00:11:39.000Z (over 5 years ago)
- Last Synced: 2025-05-20T13:56:06.064Z (about 1 year ago)
- Language: Rust
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Putex - Pi's custom Mutex
Experimenting with how a Mutex and synchronization primitives (atomics) work.
No real use case, but short and clean Rust code for you to look at :)
### Benchmarking
Two surprises for me: The spinlock variant is *slower* than the one yielding to
the OS scheduler, but, secondly, both Putex variants are faster than a
std::sync::Mutex.
```
test tests::bench_putex_spin ... bench: 473,454 ns/iter (+/- 28,847)
test tests::bench_putex_yield ... bench: 391,341 ns/iter (+/- 63,764)
test tests::bench_std_mutex ... bench: 997,582 ns/iter (+/- 115,092)
```
(tested on an AMD 3960X)
# License
This repository is available in the public domain according to the CC0 license.
Do with it whatever you want, I expressively waive all ownership rights related
to this work. Also, if it makes your computer go kaboom, that's on you.