Commit graph

8 commits

Author SHA1 Message Date
Matt Corallo
10aa4aa42f Fix new compilation warnings in debug_sync module 2022-07-26 20:29:36 +00:00
Matt Corallo
ff20203724 Swap HashSets with custom Hash in debug_sync for HashMaps 2022-07-20 22:08:59 +00:00
Matt Corallo
6f2c008751 Expand lockorder testing to look at mutexes, not specific instances
Our existing lockorder inversion checks look at specific instances
of mutexes rather than the general mutex itself. This changes that
behavior to look at the instruction pointer at which a mutex was
created and treat all mutexes which were created at the same
location as equivalent.

This allows us to detect lockorder inversions which occur across
tests, though it does substantially reduce parallelism during test
runs.
2022-07-20 22:08:59 +00:00
Matt Corallo
ae4ceb71a5 Create a simple FairRwLock to avoid readers starving writers
Because we handle messages (which can take some time, persisting
things to disk or validating cryptographic signatures) with the
top-level read lock, but require the top-level write lock to
connect new peers or handle disconnection, we are particularly
sensitive to writer starvation issues.

Rust's libstd RwLock does not provide any fairness guarantees,
using whatever the OS provides as-is. On Linux, pthreads defaults
to starving writers, which Rust's RwLock exposes to us (without
any configurability).

Here we work around that issue by blocking readers if there are
pending writers, optimizing for readable code over
perfectly-optimized blocking.
2022-05-10 23:40:20 +00:00
Matt Corallo
35c8718185 Use the term "lock" for Mutex/RwLock instead of "mutex" 2022-03-18 18:54:27 +00:00
Matt Corallo
3648784f81 Implement lockorder checking on RwLocks in debug_sync 2022-03-18 18:54:27 +00:00
Matt Corallo
82bbb807ad Refactor debug sync methods into helper functions 2022-03-09 06:23:39 +00:00
Matt Corallo
8f007c7dbb Check lockorders in tests with a trivial lockorder tracker 2022-01-14 15:35:58 +00:00