Commit 8cbf3b6f authored by Evan Hunt's avatar Evan Hunt

[master] use adaptive locks when available

3781.	[tuning]	Use adaptive mutex locks when available; this
			has been found to improve performance under load
			on many systems. "configure --with-locktype=standard"
			restores conventional mutex locks. [RT #32576]
parent 997f5130
3781. [tuning] Use adaptive mutex locks when available; this
has been found to improve performance under load
on many systems. "configure --with-locktype=standard"
restores conventional mutex locks. [RT #32576]
3780. [bug] $GENERATE handled negative numbers incorrectly.
[RT #25528]
......
......@@ -335,6 +335,9 @@ int sigwait(const unsigned int *set, int *sig);
/* Define if your PKCS11 provider supports GOST. */
#undef HAVE_PKCS11_GOST
/* Support for PTHREAD_MUTEX_ADAPTIVE_NP */
#undef HAVE_PTHREAD_MUTEX_ADAPTIVE_NP
/* Define to 1 if you have the `pthread_yield' function. */
#undef HAVE_PTHREAD_YIELD
......
......@@ -978,6 +978,7 @@ with_geoip
with_gssapi
with_randomdev
enable_threads
with_locktype
with_libtool
enable_native_pkcs11
with_openssl
......@@ -1691,6 +1692,7 @@ Optional Packages:
--with-geoip=PATH Build with GeoIP support (yes|no|path)
--with-gssapi=PATH Specify path for system-supplied GSSAPI [default=yes]
--with-randomdev=PATH Specify path for random device
--with-locktype=ARG Specify mutex lock type (adaptive or standard)
--with-libtool use GNU libtool
--with-openssl=PATH Build with OpenSSL yes|no|path.
(Crypto is required for DNSSEC)
......@@ -14855,6 +14857,57 @@ if test "x$ac_cv_func_pthread_attr_setstacksize" = xyes; then :
fi
# Check whether --with-locktype was given.
if test "${with_locktype+set}" = set; then :
withval=$with_locktype; locktype="$withval"
else
locktype="adaptive"
fi
case "$locktype" in
adaptive)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PTHREAD_MUTEX_ADAPTIVE_NP" >&5
$as_echo_n "checking for PTHREAD_MUTEX_ADAPTIVE_NP... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#define _GNU_SOURCE
#include <pthread.h>
int
main ()
{
return (PTHREAD_MUTEX_ADAPTIVE_NP);
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using adaptive lock type" >&5
$as_echo "using adaptive lock type" >&6; }
$as_echo "#define HAVE_PTHREAD_MUTEX_ADAPTIVE_NP 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using standard lock type" >&5
$as_echo "using standard lock type" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
;;
standard)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using standard lock type" >&5
$as_echo "using standard lock type" >&6; }
;;
*)
as_fn_error $? "You must specify \"adaptive\" or \"standard\" for --with-locktype." "$LINENO" 5
;;
esac
for ac_header in sched.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "sched.h" "ac_cv_header_sched_h" "$ac_includes_default"
......@@ -23715,7 +23768,12 @@ echo "========================================================================"
echo "Configuration summary:"
echo "------------------------------------------------------------------------"
echo "Optional features enabled:"
$use_threads && echo " Multiprocessing support (--enable-threads)"
if $use_threads; then
echo " Multiprocessing support (--enable-threads)"
if test "$enable_full_report" = "yes" -o "$locktype" = "standard"; then
echo " Mutex lock type: $locktype"
fi
fi
test "$use_tuning" = "large" && echo " Large-system tuning (--with-tuning)"
test "$use_geoip" = "no" || echo " GeoIP access control (--with-geoip)"
test "$use_gssapi" = "no" || echo " GSS-API (--with-gssapi)"
......
# Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 1998-2003 Internet Software Consortium.
#
# Permission to use, copy, modify, and/or distribute this software for any
......@@ -1022,6 +1023,33 @@ then
AC_CHECK_FUNC(pthread_attr_setstacksize,
AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACKSIZE),)
AC_ARG_WITH(locktype,
[ --with-locktype=ARG Specify mutex lock type (adaptive or standard)],
locktype="$withval", locktype="adaptive")
case "$locktype" in
adaptive)
AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#define _GNU_SOURCE
#include <pthread.h>
]], [[
return (PTHREAD_MUTEX_ADAPTIVE_NP);
]])],
[ AC_MSG_RESULT(using adaptive lock type)
AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
[Support for PTHREAD_MUTEX_ADAPTIVE_NP]) ],
[ AC_MSG_RESULT(using standard lock type) ])
;;
standard)
AC_MSG_RESULT(using standard lock type)
;;
*)
AC_MSG_ERROR([You must specify "adaptive" or "standard" for --with-locktype.])
;;
esac
AC_CHECK_HEADERS(sched.h)
case "$host" in
......@@ -4419,7 +4447,12 @@ echo "========================================================================"
echo "Configuration summary:"
echo "------------------------------------------------------------------------"
echo "Optional features enabled:"
$use_threads && echo " Multiprocessing support (--enable-threads)"
if $use_threads; then
echo " Multiprocessing support (--enable-threads)"
if test "$enable_full_report" = "yes" -o "$locktype" = "standard"; then
echo " Mutex lock type: $locktype"
fi
fi
test "$use_tuning" = "large" && echo " Large-system tuning (--with-tuning)"
test "$use_geoip" = "no" || echo " GeoIP access control (--with-geoip)"
test "$use_gssapi" = "no" || echo " GSS-API (--with-gssapi)"
......
......@@ -260,8 +260,20 @@ isc__mutex_init(isc_mutex_t *mp, const char *file, unsigned int line) {
char strbuf[ISC_STRERRORSIZE];
isc_result_t result = ISC_R_SUCCESS;
int err;
#ifdef HAVE_PTHREAD_MUTEX_ADAPTIVE_NP
pthread_mutexattr_t attr;
if (pthread_mutexattr_init(&attr) != 0)
return (ISC_R_UNEXPECTED);
if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP) != 0) {
pthread_mutexattr_destroy(&attr);
return (ISC_R_UNEXPECTED);
}
err = pthread_mutex_init(mp, &attr);
#else /* HAVE_PTHREAD_MUTEX_ADAPTIVE_NP */
err = pthread_mutex_init(mp, ISC__MUTEX_ATTRS);
#endif /* HAVE_PTHREAD_MUTEX_ADAPTIVE_NP */
if (err == ENOMEM)
return (ISC_R_NOMEMORY);
if (err != 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment