rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.53k stars 12.61k forks source link

Can we avoid the heap allocation in macOS Mutex/Condvar? #131005

Open RalfJung opened 1 week ago

RalfJung commented 1 week ago

This was brought up over here: our current macOS implementation for Mutex and Condvar use heap allocations. That's unfortunate because it can lead to OOM, and also seems like a slight efficiency hit.

Heap allocations are required because we are using the pthread API on macOS, and pthread Mutexes are not movable. AFAIK, @joboet has been working on alternative implementations that avoid the pthread API (https://github.com/rust-lang/rust/pull/122408). The alternative, suggested by @daira , is to get Apple to guarantee that their pthread mutexes are movable under certain conditions. Given the black box that Apple is, I have no idea if that's even remotely realistic. But anyway it seems worth tracking this somewhere so here we go. :)

joboet commented 4 hours ago

Given the black box that Apple is, I have no idea if that's even remotely realistic.

Not at all realistic. I can't even get Apple to respond to bug reports, let alone feature suggestions.