austinjones / postage-rs

The feature-rich, portable async channel library
MIT License
252 stars 9 forks source link

Add loom tests #37

Open arthurprs opened 3 years ago

arthurprs commented 3 years ago

Loom https://github.com/tokio-rs/loom

This can be a significant amount of work but in my experience it is MUCH more effective catching concurrency bugs compared to stress tests.

Eg. https://github.com/tokio-rs/tokio/blob/master/tokio/src/sync/tests/loom_broadcast.rs

austinjones commented 3 years ago

This is a great idea! Thanks for the suggestion 💯

austinjones commented 3 years ago

Hmm, there is an obstacle here. I use the atomic crate a lot for atomic enums. Unfortunately, it doesn't support loom. I think I'll need to write my own enum wrapper in order to implement this.

arthurprs commented 3 years ago

Yeah, it's a very invasive test suite. There's also the crossbeam-queue data structures.

Tokio uses a trick that imports all primitives from a loom module, then swaps its contents based on a cfg flag https://github.com/tokio-rs/tokio/blob/master/tokio/src/loom/mod.rs but that breaks as soon as you have a single external crate :weary: