kanidm / concread

Concurrently Readable Data Structures for Rust
Mozilla Public License 2.0
343 stars 15 forks source link

Remove mutual exclusion from the read side of all CowCell variants #113

Closed adamreichold closed 8 months ago

adamreichold commented 8 months ago

The read side basically needs an updatable Arc and there is a crate for that, arc-swap. And since we still have mutual exclusion for the write side, we do not even need a compare-and-swap/read-copy-update loop in the commit operation.

This is basically a continuation of #111 trying to lighten the read side further by avoiding mutual exclusion entirely. Furthermore, I noticed that I did not apply the same treatment to the publicly accessible CowCell which this PR also does. Finally, I think the fact that EbrCell basically already works like this internally lends some credibility to the approach.

Firstyear commented 8 months ago

Yes, EBR cell does work in a similar way, but it uses a generational garbage collection, so there can be issues if you have long running read transactions.

This is otherwise amazing, I didn't know about arc swap. Thank you!