5 ms·
> For this purpose, fetch-and-add would be more efficient. Multiple writer contention is much worse with CAS. Why, out of interest?
by orf 11y ago
> For this purpose, fetch-and-add would be more efficient. Multiple writer contention is much worse with CAS.
Why, out of interest?
- vardump 11y agoWhen there's heavy amount of updates, CAS loop updates will start to fail, so it needs to be retried the more the more there is contention. Fetch-and-add is totally wait-free, much better upper bound. It always succeeds on first try.
- jberryman 11y agoI can confirm. If you're curious I wrote a fast concurrent (single process) queue library for Haskell based around fetch-and-add: https://github.com/jberryman/unagi-chan https://github.com/jberryman/unagi-chan Interested to check out your work! I'd love to be able to extend my library to support IPC in some way.