@cryptotaxi247 / netdata-1 / commits / eb927d506

jemalloc and tcmalloc configure best practices applied

Costa Tsaousis (ktsaou) committed Oct 2, 2016 at 12:51 UTC eb927d506e44b20b75b44916d2b74857b25ff4be
3 files changed +25 -13
configure.ac
+10 -5
@@ -85,13 +85,18 @@ CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
85 CC="${PTHREAD_CC}"
86
87 TS_CHECK_JEMALLOC
88 -if test "$has_jemalloc" = "0"; then
88 +if test "$has_jemalloc" = "1"; then
89 + AC_DEFINE([ENABLE_JEMALLOC], [1], [compile and link with jemalloc])
90 +else
91 TS_CHECK_TCMALLOC
92 + if test "$has_tcmalloc" = "1"; then
93 + AC_DEFINE([ENABLE_TCMALLOC], [1], [compile and link with tcmalloc])
94 + else
95 + AC_C_MALLOPT
96 + AC_C_MALLINFO
97 + fi
98 fi
91 -if test "$has_jemalloc$has_tcmalloc" = "00"; then
92 - AC_C_MALLOPT
93 - AC_C_MALLINFO
94 -fi
99 +
100 AC_TYPE_UINT8_T
101 AC_TYPE_UINT16_T
102 AC_TYPE_UINT32_T
src/common.h
+14 -7
@@ -5,18 +5,25 @@
5 #include <config.h>
6 #endif
7
8 -#ifdef has_jemalloc
8 +/* select the memory allocator, based on autoconf findings */
9 +#if defined(ENABLE_JEMALLOC)
10 +
11 +#if defined(HAVE_JEMALLOC_JEMALLOC_H)
12 #include <jemalloc/jemalloc.h>
10 -#undef HAVE_C_MALLOPT
11 -#undef HAVE_C_MALLINFO
12 -#elif has_tcmalloc
13 -#include <google/tcmalloc.h>
14 -#undef HAVE_C_MALLOPT
15 -#undef HAVE_C_MALLINFO
13 #else
14 #include <malloc.h>
15 #endif
16
17 +#elif defined(ENABLE_TCMALLOC)
18 +
19 +#include <google/tcmalloc.h>
20 +
21 +#else /* !defined(ENABLE_JEMALLOC) && !defined(ENABLE_TCMALLOC) */
22 +
23 +#include <malloc.h>
24 +
25 +#endif
26 +
27 #include <pthread.h>
28 #include <errno.h>
29
src/main.c
+1 -1
@@ -374,7 +374,7 @@ int main(int argc, char **argv)
374 break;
375 case 'v':
376 // TODO: Outsource version to makefile which can compute version from git.
377 - printf("netdata " VERSION "\n");
377 + printf("netdata %s\n", VERSION);
378 return 0;
379 case 'W':
380 {