Commit c7632339 authored by Tollef Fog Heen's avatar Tollef Fog Heen

Use jemalloc by default on Linux

We seem to run into trouble with regular glibc malloc on Linux, so use
jemalloc instead of glibc's malloc.

This can be disabled using --disable-jemalloc


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3216 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 93a49594
......@@ -79,6 +79,7 @@ varnishd_LDADD = \
$(top_builddir)/lib/libvarnish/libvarnish.la \
$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
$(top_builddir)/lib/libvcl/libvcl.la \
@JEMALLOC_LDADD@ \
${DL_LIBS} ${PTHREAD_LIBS} ${NET_LIBS} ${LIBM}
EXTRA_DIST = default.vcl
......
......@@ -340,6 +340,28 @@ esac
AC_DEFINE_UNQUOTED([VCC_CC],"$VCC_CC",[C compiler command line for VCL code])
# Use jemalloc on Linux
JEMALLOC_SUBDIR=
JEMALLOC_LDADD=
AC_ARG_ENABLE(jemalloc,
AS_HELP_STRING([--disable-jemalloc],[do not use jemalloc (default is yes on Linux, no everywhere else)]),
[if "x$enableval" = "xyes"; then
JEMALLOC_SUBDIR=libjemalloc
JEMALLOC_LDADD='$(top_builddir)/lib/libjemalloc/libjemalloc_mt.la'
fi],
[case $host in #(
*-*-linux*)
JEMALLOC_SUBDIR=libjemalloc
JEMALLOC_LDADD='$(top_builddir)/lib/libjemalloc/libjemalloc_mt.la'
;; #(
*)
true
;;
esac])
AC_SUBST(JEMALLOC_SUBDIR)
AC_SUBST(JEMALLOC_LDADD)
# Generate output
AC_CONFIG_FILES([
Makefile
......@@ -361,6 +383,7 @@ AC_CONFIG_FILES([
lib/libvarnishapi/Makefile
lib/libvarnishcompat/Makefile
lib/libvcl/Makefile
lib/libjemalloc/Makefile
man/Makefile
redhat/Makefile
varnishapi.pc
......
......@@ -4,4 +4,5 @@ SUBDIRS = \
libvarnish \
libvarnishapi \
libvarnishcompat \
libvcl
libvcl \
@JEMALLOC_SUBDIR@
CFLAGS := -O3 -g
# See source code comments to avoid memory leaks when enabling MALLOC_MAG.
#CPPFLAGS := -DMALLOC_PRODUCTION -DMALLOC_MAG
CPPFLAGS := -DMALLOC_PRODUCTION
all: libjemalloc.so.0 libjemalloc_mt.so.0
jemalloc_linux_mt.o: jemalloc_linux.c
gcc $(CFLAGS) -c -DPIC -fPIC $(CPPFLAGS) -D__isthreaded=true -o $@ $+
jemalloc_linux.o: jemalloc_linux.c
gcc $(CFLAGS) -c -DPIC -fPIC $(CPPFLAGS) -D__isthreaded=false -o $@ $+
libjemalloc_mt.so.0: jemalloc_linux_mt.o
gcc -shared -lpthread -o $@ $+
ln -sf $@ libjemalloc_mt.so
libjemalloc.so.0: jemalloc_linux.o
gcc -shared -lpthread -o $@ $+
ln -sf $@ libjemalloc.so
clean:
rm -f *.o *.so.0 *.so
# See source code comments to avoid memory leaks when enabling MALLOC_MAG.
#CPPFLAGS := -DMALLOC_PRODUCTION -DMALLOC_MAG
AM_CPPFLAGS := -DMALLOC_PRODUCTION
#all: libjemalloc.so.0 libjemalloc_mt.so.0
noinst_LTLIBRARIES = libjemalloc_mt.la
libjemalloc_mt_la_LIBADD = ${PTHREAD_LIBS}
libjemalloc_mt_la_LDFLAGS = -version-info 0:0:0 -static
libjemalloc_mt_la_CFLAGS = -D__isthreaded=true
libjemalloc_mt_la_SOURCES = jemalloc_linux.c
#jemalloc_linux.o: jemalloc_linux.c
# gcc $(CFLAGS) -c -DPIC -fPIC $(CPPFLAGS) -D__isthreaded=false -o $@ $+
#libjemalloc_mt.so.0: jemalloc_linux_mt.o
# gcc -shared -lpthread -o $@ $+
# ln -sf $@ libjemalloc_mt.so
#libjemalloc.so.0: jemalloc_linux.o
# gcc -shared -lpthread -o $@ $+
# ln -sf $@ libjemalloc.so
#clean:
# rm -f *.o *.so.0 *.so
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