Open cmnord opened 4 years ago
Hi,
You mean the rust STM library? The haskell original has some examples, especially in the book I Parallel and Concurrent programming in haskell.
The branch datastructures implements some datastructures on top of the primitive operations. You can look at that branch for examples on how to use TVar
and Transaction
I never published it, because I didn't finish writing a concurrent Map with it. Also for practical cases you propably want to combine STM with immutable datastructures from the crate im, rather than relying on recursively defined STM datastructures.
I did some benchmarks a while ago in this repo on how queues compare to their std counterparts in high contention producer-consumer scenarios.
test bench_std_channel ... bench: 69,467 ns/iter (+/- 3,874)
test bench_std_sync_channel_1 ... bench: 5,016,061 ns/iter (+/- 557,420)
test bench_std_sync_channel_200 ... bench: 348,172 ns/iter (+/- 52,110)
test bench_stm_bqueue_1 ... bench: 6,920,528 ns/iter (+/- 734,555)
test bench_stm_bqueue_200 ... bench: 2,521,554 ns/iter (+/- 73,592)
test bench_stm_queue ... bench: 1,447,575 ns/iter (+/- 363,972)
Ah, thanks for sharing. The stm-datastructures repo is very helpful. I don't know Haskell so I was interested in looking at examples in Rust.
It looks like the stm-datastructures
repo and the rust-stm
datastructures
branch contain the same datastructures -- which one is better to look at?
rust-stm
is newer. I decided to change the split from stm
and stm-datastructures
into stm-core
(minimal implementation) and stm
(core and additional helpers).
Note, that none of it is actually published on crates.io, because the design is in a very early stage for now. I want do do one with procedural macros and also figure out, which datastructures are actually necessary and which are better served by im, but didn't do it yet.
If you try it, I would really like to hear about your experiences with stm, because I wrote it as an exercise and have never really used it.
Hi there,
Interesting project! Does the Haskell STM library you're using have examples and/or benchmarks? It would be helpful to look at more examples to get a sense of the interface, and benchmarks to see the performance.