| Index: base/synchronization/lock_impl_posix.cc
|
| diff --git a/base/synchronization/lock_impl_posix.cc b/base/synchronization/lock_impl_posix.cc
|
| index e54595b87f10a353647d4a0ee40aa30d2a649780..fe5d21cf0d46a2e717e0baadf4a534eff06e26a3 100644
|
| --- a/base/synchronization/lock_impl_posix.cc
|
| +++ b/base/synchronization/lock_impl_posix.cc
|
| @@ -11,6 +11,10 @@
|
| #include "base/logging.h"
|
| #include "base/synchronization/lock.h"
|
|
|
| +#if defined(OS_MACOSX)
|
| +#include <pthread_spis.h>
|
| +#endif
|
| +
|
| namespace base {
|
| namespace internal {
|
|
|
| @@ -42,6 +46,11 @@ LockImpl::LockImpl() {
|
| rv = pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_ERRORCHECK);
|
| DCHECK_EQ(rv, 0) << ". " << strerror(rv);
|
| #endif
|
| +#if defined(OS_MACOSX)
|
| + // macOS defaults to fair locks which can be orders of magnitude slower in the
|
| + // contention case, so default to first fit, which avoids queuing.
|
| + pthread_mutexattr_setpolicy_np(&mta, _PTHREAD_MUTEX_POLICY_FIRSTFIT);
|
| +#endif
|
| rv = pthread_mutex_init(&native_handle_, &mta);
|
| DCHECK_EQ(rv, 0) << ". " << strerror(rv);
|
| rv = pthread_mutexattr_destroy(&mta);
|
|
|