You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2011/10/03 21:34:43 UTC
svn commit: r1178527 - in /trafficserver/traffic/trunk: build/jemalloc.m4
build/tcmalloc.m4 configure.ac example/append-transform/append-transform.c
lib/ts/ink_config.h.in
Author: zwoop
Date: Mon Oct 3 19:34:42 2011
New Revision: 1178527
URL: http://svn.apache.org/viewvc?rev=1178527&view=rev
Log:
TS-567 Add support for jemalloc as well
Added:
trafficserver/traffic/trunk/build/jemalloc.m4
Modified:
trafficserver/traffic/trunk/build/tcmalloc.m4
trafficserver/traffic/trunk/configure.ac
trafficserver/traffic/trunk/example/append-transform/append-transform.c
trafficserver/traffic/trunk/lib/ts/ink_config.h.in
Added: trafficserver/traffic/trunk/build/jemalloc.m4
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/build/jemalloc.m4?rev=1178527&view=auto
==============================================================================
--- trafficserver/traffic/trunk/build/jemalloc.m4 (added)
+++ trafficserver/traffic/trunk/build/jemalloc.m4 Mon Oct 3 19:34:42 2011
@@ -0,0 +1,78 @@
+dnl -------------------------------------------------------- -*- autoconf -*-
+dnl Licensed to the Apache Software Foundation (ASF) under one or more
+dnl contributor license agreements. See the NOTICE file distributed with
+dnl this work for additional information regarding copyright ownership.
+dnl The ASF licenses this file to You under the Apache License, Version 2.0
+dnl (the "License"); you may not use this file except in compliance with
+dnl the License. You may obtain a copy of the License at
+dnl
+dnl http://www.apache.org/licenses/LICENSE-2.0
+dnl
+dnl Unless required by applicable law or agreed to in writing, software
+dnl distributed under the License is distributed on an "AS IS" BASIS,
+dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+dnl See the License for the specific language governing permissions and
+dnl limitations under the License.
+
+dnl
+dnl jemalloc.m4: Trafficserver's jemalloc autoconf macros
+dnl
+
+AC_DEFUN([TS_CHECK_JEMALLOC], [
+enable_jemalloc=no
+AC_ARG_WITH([jemalloc], [AC_HELP_STRING([--with-jemalloc=DIR], [use a specific jemalloc library])],
+[
+ if test "$withval" != "no"; then
+ if test "x${enable_tcmalloc}" = "xyes"; then
+ AC_MSG_ERROR([Cannot compile with both jemalloc and tcmalloc])
+ fi
+ enable_jemalloc=yes
+ jemalloc_base_dir="$withval"
+ case "$withval" in
+ yes)
+ jemalloc_base_dir="/usr"
+ AC_MSG_CHECKING(checking for jemalloc includes standard directories)
+ ;;
+ *":"*)
+ jemalloc_include="`echo $withval |sed -e 's/:.*$//'`"
+ jemalloc_ldflags="`echo $withval |sed -e 's/^.*://'`"
+ AC_MSG_CHECKING(checking for jemalloc includes in $jemalloc_include libs in $jemalloc_ldflags)
+ ;;
+ *)
+ jemalloc_include="$withval/include"
+ jemalloc_ldflags="$withval/lib"
+ AC_MSG_CHECKING(checking for jemalloc includes in $withval)
+ ;;
+ esac
+ fi
+])
+
+jemalloch=0
+if test "$enable_jemalloc" != "no"; then
+ saved_ldflags=$LDFLAGS
+ saved_cppflags=$CPPFLAGS
+ jemalloc_have_headers=0
+ jemalloc_have_libs=0
+ if test "$jemalloc_base_dir" != "/usr"; then
+ TS_ADDTO(CPPFLAGS, [-I${jemalloc_include}])
+ TS_ADDTO(LDFLAGS, [-L${jemalloc_ldflags}])
+ TS_ADDTO(LIBTOOL_LINK_FLAGS, [-R${jemalloc_ldflags}])
+ fi
+ if test "`uname -s`" = "Darwin"; then
+ AC_CHECK_LIB(jemalloc, je_malloc_stats_print, [jemalloc_have_libs=1])
+ else
+ AC_CHECK_LIB(jemalloc, malloc_stats_print, [jemalloc_have_libs=1])
+ fi
+ if test "$jemalloc_have_libs" != "0"; then
+ TS_FLAG_HEADERS(jemalloc/jemalloc.h, [jemalloc_have_headers=1])
+ fi
+ if test "$jemalloc_have_headers" != "0"; then
+ jemalloch=1
+ TS_ADDTO(LIBS, [-ljemalloc])
+ else
+ CPPFLAGS=$saved_cppflags
+ LDFLAGS=$saved_ldflags
+ fi
+fi
+AC_SUBST(jemalloch)
+])
Modified: trafficserver/traffic/trunk/build/tcmalloc.m4
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/build/tcmalloc.m4?rev=1178527&r1=1178526&r2=1178527&view=diff
==============================================================================
--- trafficserver/traffic/trunk/build/tcmalloc.m4 (original)
+++ trafficserver/traffic/trunk/build/tcmalloc.m4 Mon Oct 3 19:34:42 2011
@@ -18,9 +18,6 @@ dnl
dnl tcmalloc.m4: Trafficserver's tcmalloc autoconf macros
dnl
-dnl
-dnl TS_CHECK_TCMALLOC: look for tcmalloc libraries
-dnl
dnl This is kinda fugly, but need a way to both specify a directory and which
dnl of the many tcmalloc libraries to use ...
AC_DEFUN([TS_CHECK_TCMALLOC], [
@@ -33,9 +30,13 @@ AC_ARG_WITH([tcmalloc-lib],
]
)
-AC_ARG_WITH(tcmalloc, [AC_HELP_STRING([--with-tcmalloc=DIR], [use the tcmalloc library])],
+has_tcmalloc=0
+AC_ARG_WITH([tcmalloc], [AC_HELP_STRING([--with-tcmalloc=DIR], [use the tcmalloc library])],
[
if test "$withval" != "no"; then
+ if test "x${enable_jemalloc}" = "xyes"; then
+ AC_MSG_ERROR([Cannot compile with both tcmalloc and jemalloc])
+ fi
tcmalloc_have_libs=0
if test "x$withval" != "xyes" && test "x$withval" != "x"; then
tcmalloc_ldflags="$withval/lib"
@@ -45,7 +46,9 @@ AC_ARG_WITH(tcmalloc, [AC_HELP_STRING([-
AC_CHECK_LIB(${with_tcmalloc_lib}, tc_cfree , [tcmalloc_have_lib=1])
if test "$tcmalloc_have_lib" != "0"; then
TS_ADDTO(LIBS, [-l${with_tcmalloc_lib}])
+ has_tcmalloc=1
fi
fi
])
+AC_SUBST(has_tcmalloc)
])
Modified: trafficserver/traffic/trunk/configure.ac
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/configure.ac?rev=1178527&r1=1178526&r2=1178527&view=diff
==============================================================================
--- trafficserver/traffic/trunk/configure.ac (original)
+++ trafficserver/traffic/trunk/configure.ac Mon Oct 3 19:34:42 2011
@@ -974,9 +974,11 @@ AS_IF([test "x$enable_hwloc" = "xyes"],
AC_SUBST(use_hwloc)
#
-# Check for tcmalloc
+# Check for tcmalloc and jemalloc
+TS_CHECK_JEMALLOC
TS_CHECK_TCMALLOC
+
# -----------------------------------------------------------------------------
# 5. CHECK FOR HEADER FILES
Modified: trafficserver/traffic/trunk/example/append-transform/append-transform.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/append-transform/append-transform.c?rev=1178527&r1=1178526&r2=1178527&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/append-transform/append-transform.c (original)
+++ trafficserver/traffic/trunk/example/append-transform/append-transform.c Mon Oct 3 19:34:42 2011
@@ -88,8 +88,8 @@ handle_transform(TSCont contp)
TSVConn output_conn;
TSVIO write_vio;
MyData *data;
- int towrite;
- int avail;
+ int64_t towrite;
+ int64_t avail;
/* Get the output connection where we'll write data to. */
output_conn = TSTransformOutputVConnGet(contp);
Modified: trafficserver/traffic/trunk/lib/ts/ink_config.h.in
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_config.h.in?rev=1178527&r1=1178526&r2=1178527&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_config.h.in (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_config.h.in Mon Oct 3 19:34:42 2011
@@ -84,6 +84,9 @@
#define TS_HAS_LIBZ @zlibh@
#define TS_HAS_LZMA @lzmah@
#define TS_HAS_EXPAT @expath@
+#define TS_HAS_JEMALLOC @jemalloch@
+#define TS_HAS_TCMALLOC @has_tcmalloc@
+
/* Features */
#define TS_HAS_EVENTFD @has_eventfd@