rust/src/libstd/sync
bors a47c9f870f Auto merge of #44963 - JLockerman:fix_spsc, r=alexcrichton
Improve performance of spsc_queue and stream.

This PR makes two main changes:

1. It switches the `spsc_queue` node caching strategy from keeping a shared
counter of the number of nodes in the cache to keeping a consumer only counter
of the number of node eligible to be cached.
2. It separates the consumer and producers fields of `spsc_queue` and `stream` into
a producer cache line and consumer cache line.

Overall, it speeds up `mpsc` in `spsc` mode by 2-10x.
Variance is higher than I'd like (that 2-10x speedup is on one benchmark), I believe this is due to the drop check in `send` (`fn stream::Queue::send:107`). I think this check can be combined with the sleep detection code into a version which only uses 1 shared variable, and only one atomic access per `send`, but I haven't looked through the select implementation enough to be sure.

The code currently assumes a cache line size of 64 bytes. I added a CacheAligned newtype in `mpsc` which I expect to reuse for `shared`. It doesn't really belong there, it would probably be best put in `core::sync::atomic`, but putting it in `core` would involve making it public, which I thought would require an RFC.

Benchmark runner is [here](3eca46279c/shootout), benchmarks [here](3eca46279c/queue_bench/src/lib.rs (L170-L293)).

Fixes #44512.
2017-10-11 19:32:19 +00:00
..
mpsc Auto merge of #44963 - JLockerman:fix_spsc, r=alexcrichton 2017-10-11 19:32:19 +00:00
barrier.rs Use explicit wrapping_add to prevent potential unexpected behavior on debug builds 2017-08-08 22:58:09 +02:00
condvar.rs Fix condvar.wait(distant future) return immediately on OSX 2017-06-15 21:20:02 +01:00
mod.rs std: Clean out deprecated APIs 2016-07-12 12:51:13 -07:00
mutex.rs Rollup merge of #44775 - MaloJaffre:debug-struct, r=sfackler 2017-10-10 22:43:57 +08:00
once.rs change #![feature(const_fn)] to specific gates 2017-09-16 15:53:02 +00:00
rwlock.rs Refactor to use debug_struct in several Debug impls 2017-10-09 20:09:08 +02:00