From b682629c74d5b910f2a5c90474e244c953bf91d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Rodr=C3=ADguez?= Date: Tue, 2 May 2023 21:09:14 +0000 Subject: [PATCH 6/6] thread_mutex: APR_THREAD_MUTEX_DEFAULT should map to ADAPTATIVE_NP lock this is a linux-glibc specific hybrid lock, which has significant performance advatanges on multi-core systems. lock test is around 20%-30% faster now. --- locks/unix/thread_mutex.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/locks/unix/thread_mutex.c b/locks/unix/thread_mutex.c index cfb1e82c6..d7b3e03d1 100644 --- a/locks/unix/thread_mutex.c +++ b/locks/unix/thread_mutex.c @@ -66,15 +66,24 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, rv = pthread_mutex_init(&new_mutex->mutex, &mattr); pthread_mutexattr_destroy(&mattr); - } else + } else { #endif - rv = pthread_mutex_init(&new_mutex->mutex, NULL); - - if (rv) { + pthread_mutexattr_t mattr; + rv = pthread_mutexattr_init(&mattr); + if (rv) return rv; + rv = pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_ADAPTIVE_NP); + if (rv) { + pthread_mutexattr_destroy(&mattr); + return rv; + } + rv = pthread_mutex_init(&new_mutex->mutex, &mattr); + pthread_mutexattr_destroy(&mattr); + if (rv) { #ifdef HAVE_ZOS_PTHREADS - rv = errno; + rv = errno; #endif - return rv; + return rv; + } } #ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK -- 2.40.1