Skip to content

Unbounded spinning in WakerSet #656

Open
@matklad

Description

@matklad

WakerSet contains a spin lock which never falls back to OS-provided blocking facilities:

while self.flag.fetch_or(LOCKED, Ordering::Acquire) & LOCKED != 0 {
backoff.snooze();

I think this might lead to a pretty bad behavior in pathological cases, due to priority inversion.

Not sure what's the best solution here is though: std::sync::Mutex is not the fastest one in town, parking_lot is an external dependency.

See also https://matklad.github.io/2020/01/02/spinlocks-considered-harmful.html and https://probablydance.com/2019/12/30/measuring-mutexes-spinlocks-and-how-bad-the-linux-scheduler-really-is/.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions