From 96abe73517b4d9763425c2c383b2583442aae36e Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Tue, 21 Feb 2017 12:13:06 -0500 Subject: [PATCH] Issue 49141 - Use tcmalloc by default Description: Add configure option "--with-tcmalloc" for linking libtcmalloc with the core server. Update the spec file to use it by default. https://pagure.io/389-ds-base/issue/49141 Reviewed by: ? --- Makefile.am | 7 ++++--- configure.ac | 2 ++ ldap/admin/src/base-initconfig.in | 7 ------- m4/tcmalloc.m4 | 29 +++++++++++++++++++++++++++++ rpm/389-ds-base.spec.in | 5 ++++- 5 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 m4/tcmalloc.m4 diff --git a/Makefile.am b/Makefile.am index 112b8f1..6760e7a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -98,7 +98,7 @@ PCRE_LINK = @pcre_lib@ -lpcre NETSNMP_LINK = @netsnmp_lib@ @netsnmp_link@ PAM_LINK = -lpam KERBEROS_LINK = $(kerberos_lib) - +TCMALLOC_LINK = @tcmalloc_link@ SYSTEMD_LINK = @systemd_lib@ @@ -1075,7 +1075,8 @@ libslapd_la_CPPFLAGS = $(PLUGIN_CPPFLAGS) @sasl_inc@ @db_inc@ @svrcore_inc@ @ker if SPARC libslapd_la_SOURCES += ldap/servers/slapd/slapi_counter_sunos_sparcv9.S endif -libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(NUNC_STANS_LINK) $(SVRCORE_LINK) $(NSS_LINK) $(NSPR_LINK) $(KERBEROS_LINK) $(PCRE_LINK) $(THREADLIB) $(SYSTEMD_LINK) +libslapd_la_LIBADD = $(LDAPSDK_LINK) $(SASL_LINK) $(NUNC_STANS_LINK) $(SVRCORE_LINK) $(NSS_LINK) \ + $(NSPR_LINK) $(KERBEROS_LINK) $(PCRE_LINK) $(THREADLIB) $(SYSTEMD_LINK) $(TCMALLOC_LINK) #//////////////////////////////////////////////////////////////// @@ -1804,7 +1805,7 @@ ns_slapd_SOURCES = ldap/servers/slapd/abandon.c \ ns_slapd_CPPFLAGS = $(AM_CPPFLAGS) @sasl_inc@ @openldap_inc@ @ldapsdk_inc@ @nss_inc@ \ @nspr_inc@ @svrcore_inc@ @systemd_inc@ ns_slapd_LDADD = libslapd.la libldaputil.a $(LDAPSDK_LINK) $(NSS_LINK) $(LIBADD_DL) \ - $(NSPR_LINK) $(SASL_LINK) $(SVRCORE_LINK) $(LIBNSL) $(LIBSOCKET) $(THREADLIB) $(SYSTEMD_LINK) + $(NSPR_LINK) $(SASL_LINK) $(SVRCORE_LINK) $(LIBNSL) $(LIBSOCKET) $(THREADLIB) $(SYSTEMD_LINK) $(TCMALLOC_LINK) ns_slapd_DEPENDENCIES = libslapd.la # We need to link ns-slapd with the C++ compiler on HP-UX since we load # some C++ shared libraries (such as icu). diff --git a/configure.ac b/configure.ac index 38e6480..00e9bc7 100644 --- a/configure.ac +++ b/configure.ac @@ -689,6 +689,7 @@ m4_include(m4/selinux.m4) m4_include(m4/nunc-stans.m4) m4_include(m4/systemd.m4) m4_include(m4/cmocka.m4) +m4_include(m4/tcmalloc.m4) PACKAGE_BASE_VERSION=`echo $PACKAGE_VERSION | awk -F\. '{print $1"."$2}'` AC_SUBST(PACKAGE_BASE_VERSION) @@ -753,6 +754,7 @@ AC_SUBST(localrundir) AC_SUBST(systemd_inc) AC_SUBST(systemd_lib) AC_SUBST(systemd_defs) +AC_SUBST(tcmalloc_link) AC_SUBST(brand) AC_SUBST(capbrand) diff --git a/ldap/admin/src/base-initconfig.in b/ldap/admin/src/base-initconfig.in index 8507296..1403ada 100644 --- a/ldap/admin/src/base-initconfig.in +++ b/ldap/admin/src/base-initconfig.in @@ -40,10 +40,3 @@ # is a problem and fail to start. # If using systemd, omit the "; export PID_TIME" at the end. #PID_TIME=600 ; export PID_TIME - -# The tcmalloc memory allocator has been shown to have a positive impact on -# the Directory Server's virtual & resident memory size/growth. tcmalloc is -# available on RHEL/Fedora in the gperftools-libs package (this could be -# different on other platforms). -# If using systemd, omit the "; export LD_PRELOAD" at the end. -#LD_PRELOAD=@libdir@/libtcmalloc.so.4 ; export LD_PRELOAD diff --git a/m4/tcmalloc.m4 b/m4/tcmalloc.m4 new file mode 100644 index 0000000..da9a722 --- /dev/null +++ b/m4/tcmalloc.m4 @@ -0,0 +1,29 @@ +# BEGIN COPYRIGHT BLOCK +# Copyright (C) 2017 Red Hat, Inc. +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# END COPYRIGHT BLOCK + +AC_CHECKING(for tcmalloc) + +# check for --with-tcmalloc +AC_MSG_CHECKING(for --with-tcmalloc) +AC_ARG_WITH(tcmalloc, AS_HELP_STRING([--with-tcmalloc],[Use TCMalloc memory allocator.]), +[ + if test "$withval" = yes + then + AC_MSG_RESULT([using tcmalloc memory allocator]) + with_tcmalloc=yes + else + AC_MSG_RESULT(no) + fi +], +AC_MSG_RESULT(no)) + +if test "$with_tcmalloc" = yes; then + tcmalloc_link=-ltcmalloc +fi + + diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in index f1358af..19fec91 100644 --- a/rpm/389-ds-base.spec.in +++ b/rpm/389-ds-base.spec.in @@ -92,6 +92,9 @@ BuildRequires: autoconf BuildRequires: automake BuildRequires: libtool +# Needed for tcmalloc +BuildRequires: gperftools-devel + # this is needed for using semanage from our setup scripts Requires: policycoreutils-python @@ -314,7 +317,7 @@ autoreconf -fiv --with-systemdsystemunitdir=%{_unitdir} \ --with-systemdsystemconfdir=%{_sysconfdir}/systemd/system \ --with-systemdgroupname=%{groupname} $NSSARGS $NUNC_STANS_FLAGS \ - --with-systemd $ASAN_FLAGS + --with-systemd --with-tcmalloc $ASAN_FLAGS # Generate symbolic info for debuggers export XCFLAGS=$RPM_OPT_FLAGS -- 2.7.4