1 From patchwork Fri Jun 19 10:56:58 2015
2 Content-Type: text/plain; charset="utf-8"
4 Content-Transfer-Encoding: 7bit
5 Subject: configure: Add support for jemalloc
6 From: Alexandre DERUMIER <aderumier@odiso.com>
8 Message-Id: <1434711418-20429-1-git-send-email-aderumier@odiso.com>
9 To: qemu-devel@nongnu.org
10 Cc: Alexandre Derumier <aderumier@odiso.com>
11 Date: Fri, 19 Jun 2015 12:56:58 +0200
13 This adds "--enable-jemalloc" and "--disable-jemalloc" to allow linking
14 to jemalloc memory allocator.
16 We have already tcmalloc support,
17 but it seem to not working well with a lot of iothreads/disks.
19 The main problem is that tcmalloc use a shared thread cache of 16MB
21 With more threads, this cache is shared, and some bad garbage collections
22 can occur if the cache is too low.
24 It's possible to tcmalloc cache increase it with a env var:
25 TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES=256MB
27 With default 16MB, performances are really bad with more than 2 disks.
28 Increasing to 256MB, it's helping but still have problem with 16 disks/iothreads.
30 Jemalloc don't have performance problem with default configuration.
32 Here the benchmark results in iops of 1 qemu vm randread 4K iodepth=32,
33 with rbd block backend (librbd is doing a lot of memory allocation),
54 tcmalloc 2.2.1 default 16M cache
55 --------------------------------
64 ---------------------------
72 Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
73 Reviewed-by: Fam Zheng <famz@redhat.com>
75 configure | 29 +++++++++++++++++++++++++++++
76 1 file changed, 29 insertions(+)
78 diff --git a/configure b/configure
79 index 222694f..2fe1e05 100755
82 @@ -338,6 +338,7 @@ vhdx=""
88 # parse CC options first
90 @@ -1149,6 +1150,10 @@ for opt do
92 --enable-tcmalloc) tcmalloc="yes"
94 + --disable-jemalloc) jemalloc="no"
96 + --enable-jemalloc) jemalloc="yes"
99 echo "ERROR: unknown option $opt"
100 echo "Try '$0 --help' for more information"
101 @@ -3345,6 +3352,11 @@ EOF
105 +if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
106 + echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
110 ##########################################
113 @@ -3362,6 +3374,22 @@ EOF
116 ##########################################
119 +if test "$jemalloc" = "yes" ; then
122 +int main(void) { malloc(1); return 0; }
125 + if compile_prog "" "-ljemalloc" ; then
126 + LIBS="-ljemalloc $LIBS"
128 + feature_not_found "jemalloc" "install jemalloc devel"
132 +##########################################
136 @@ -4573,6 +4591,7 @@ echo "snappy support $snappy"
137 echo "bzip2 support $bzip2"
138 echo "NUMA host support $numa"
139 echo "tcmalloc support $tcmalloc"
140 +echo "jemalloc support $jemalloc"
142 if test "$sdl_too_old" = "yes"; then
143 echo "-> Your SDL version is too old - please upgrade to have SDL support"