Theseus icon indicating copy to clipboard operation
Theseus copied to clipboard

Improve mutex performance

Open tsoutsman opened this issue 3 years ago • 0 comments

#576 provides a simple mutex implementation; ideally, we'd use a more performant one. Currently, raw_mutex only has a fast path (mutex is unlocked) and a slow path (mutex is locked - block current task). We should also have a middle path, which spins for a bit, hoping the mutex is unlocked soon.

Some useful links:

  • How Linux does it: https://0xax.gitbooks.io/linux-insides/content/SyncPrim/linux-sync-4.html
  • Another possible implementation: https://arxiv.org/pdf/1906.00490.pdf
  • The concept of a backoff could be useful in some capacity: https://docs.rs/crossbeam/latest/crossbeam/utils/struct.Backoff.html

tsoutsman avatar Jul 26 '22 01:07 tsoutsman