
They rely on a non-public function and flags which I had to duplicate in Firefox.

So how do you use them? Well, it turns out they’re not documented. Those would have been an excellent choice for our use-case. However, as I dug into Apple’s libraries and kernel, I noticed that some spin locks were indeed available, and they did the spinning in kernel-space where they could make a more informed choice with regards to load and scheduling. os_unfair_lock might be better behaved than OSSpinLock, but it sucked.Īs it turns out os_unfair_lock doesn’t spin on contention, it makes the calling thread sleep right away when it finds a contended lock.įor the memory allocator this behavior was suboptimal and the performance regression unacceptable. Performance in some of our automated tests degraded by as much as 30%.

Improving Firefox Responsiveness on macOS
