]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/jemalloc.patch
Two more fixes
[pve-qemu-kvm.git] / debian / patches / jemalloc.patch
CommitLineData
21631cbc
WB
1From patchwork Fri Jun 19 10:56:58 2015
2Content-Type: text/plain; charset="utf-8"
3MIME-Version: 1.0
4Content-Transfer-Encoding: 7bit
5Subject: configure: Add support for jemalloc
6From: Alexandre DERUMIER <aderumier@odiso.com>
7X-Patchwork-Id: 486671
8Message-Id: <1434711418-20429-1-git-send-email-aderumier@odiso.com>
9To: qemu-devel@nongnu.org
10Cc: Alexandre Derumier <aderumier@odiso.com>
11Date: Fri, 19 Jun 2015 12:56:58 +0200
12
13This adds "--enable-jemalloc" and "--disable-jemalloc" to allow linking
14to jemalloc memory allocator.
15
16We have already tcmalloc support,
17but it seem to not working well with a lot of iothreads/disks.
18
19The main problem is that tcmalloc use a shared thread cache of 16MB
20by default.
21With more threads, this cache is shared, and some bad garbage collections
22can occur if the cache is too low.
23
24It's possible to tcmalloc cache increase it with a env var:
25TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES=256MB
26
27With default 16MB, performances are really bad with more than 2 disks.
28Increasing to 256MB, it's helping but still have problem with 16 disks/iothreads.
29
30Jemalloc don't have performance problem with default configuration.
31
32Here the benchmark results in iops of 1 qemu vm randread 4K iodepth=32,
33with rbd block backend (librbd is doing a lot of memory allocation),
341 iothread by disk
35
36glibc malloc
37------------
38
391 disk 29052
402 disks 55878
414 disks 127899
428 disks 240566
4315 disks 269976
44
45jemalloc
46--------
47
481 disk 41278
492 disks 75781
504 disks 195351
518 disks 294241
5215 disks 298199
53
54tcmalloc 2.2.1 default 16M cache
55--------------------------------
56
571 disk 37911
582 disks 67698
594 disks 41076
608 disks 43312
6115 disks 37569
62
63tcmalloc : 256M cache
64---------------------------
65
661 disk 33914
672 disks 58839
684 disks 148205
698 disks 213298
7015 disks 218383
71
72Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
73Reviewed-by: Fam Zheng <famz@redhat.com>
74---
75 configure | 29 +++++++++++++++++++++++++++++
76 1 file changed, 29 insertions(+)
77
78diff --git a/configure b/configure
79index 222694f..2fe1e05 100755
ae2e84e3
AD
80--- a/configure
81+++ b/configure
21631cbc 82@@ -338,6 +338,7 @@ vhdx=""
ae2e84e3 83 vhdx=""
ae2e84e3 84 numa=""
21631cbc 85 tcmalloc="no"
ae2e84e3
AD
86+jemalloc="no"
87
88 # parse CC options first
89 for opt do
21631cbc 90@@ -1149,6 +1150,10 @@ for opt do
ae2e84e3 91 ;;
21631cbc 92 --enable-tcmalloc) tcmalloc="yes"
ae2e84e3
AD
93 ;;
94+ --disable-jemalloc) jemalloc="no"
95+ ;;
96+ --enable-jemalloc) jemalloc="yes"
97+ ;;
98 *)
99 echo "ERROR: unknown option $opt"
100 echo "Try '$0 --help' for more information"
21631cbc
WB
101@@ -3345,6 +3352,11 @@ EOF
102 fi
103 fi
104
105+if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
106+ echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
107+ exit 1
108+fi
109+
110 ##########################################
111 # tcmalloc probe
ae2e84e3 112
21631cbc 113@@ -3362,6 +3374,22 @@ EOF
ae2e84e3
AD
114 fi
115
116 ##########################################
117+# jemalloc probe
118+
119+if test "$jemalloc" = "yes" ; then
120+ cat > $TMPC << EOF
121+#include <stdlib.h>
122+int main(void) { malloc(1); return 0; }
123+EOF
124+
125+ if compile_prog "" "-ljemalloc" ; then
126+ LIBS="-ljemalloc $LIBS"
127+ else
128+ feature_not_found "jemalloc" "install jemalloc devel"
129+ fi
130+fi
131+
132+##########################################
133 # signalfd probe
134 signalfd="no"
135 cat > $TMPC << EOF
21631cbc 136@@ -4573,6 +4591,7 @@ echo "snappy support $snappy"
ae2e84e3
AD
137 echo "bzip2 support $bzip2"
138 echo "NUMA host support $numa"
21631cbc 139 echo "tcmalloc support $tcmalloc"
ae2e84e3
AD
140+echo "jemalloc support $jemalloc"
141
142 if test "$sdl_too_old" = "yes"; then
143 echo "-> Your SDL version is too old - please upgrade to have SDL support"