]> git.proxmox.com Git - pve-qemu-kvm.git/blob - debian/patches/jemalloc.patch
Two more fixes
[pve-qemu-kvm.git] / debian / patches / jemalloc.patch
1 From patchwork Fri Jun 19 10:56:58 2015
2 Content-Type: text/plain; charset="utf-8"
3 MIME-Version: 1.0
4 Content-Transfer-Encoding: 7bit
5 Subject: configure: Add support for jemalloc
6 From: Alexandre DERUMIER <aderumier@odiso.com>
7 X-Patchwork-Id: 486671
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
12
13 This adds "--enable-jemalloc" and "--disable-jemalloc" to allow linking
14 to jemalloc memory allocator.
15
16 We have already tcmalloc support,
17 but it seem to not working well with a lot of iothreads/disks.
18
19 The main problem is that tcmalloc use a shared thread cache of 16MB
20 by default.
21 With more threads, this cache is shared, and some bad garbage collections
22 can occur if the cache is too low.
23
24 It's possible to tcmalloc cache increase it with a env var:
25 TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES=256MB
26
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.
29
30 Jemalloc don't have performance problem with default configuration.
31
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),
34 1 iothread by disk
35
36 glibc malloc
37 ------------
38
39 1 disk 29052
40 2 disks 55878
41 4 disks 127899
42 8 disks 240566
43 15 disks 269976
44
45 jemalloc
46 --------
47
48 1 disk 41278
49 2 disks 75781
50 4 disks 195351
51 8 disks 294241
52 15 disks 298199
53
54 tcmalloc 2.2.1 default 16M cache
55 --------------------------------
56
57 1 disk 37911
58 2 disks 67698
59 4 disks 41076
60 8 disks 43312
61 15 disks 37569
62
63 tcmalloc : 256M cache
64 ---------------------------
65
66 1 disk 33914
67 2 disks 58839
68 4 disks 148205
69 8 disks 213298
70 15 disks 218383
71
72 Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
73 Reviewed-by: Fam Zheng <famz@redhat.com>
74 ---
75 configure | 29 +++++++++++++++++++++++++++++
76 1 file changed, 29 insertions(+)
77
78 diff --git a/configure b/configure
79 index 222694f..2fe1e05 100755
80 --- a/configure
81 +++ b/configure
82 @@ -338,6 +338,7 @@ vhdx=""
83 vhdx=""
84 numa=""
85 tcmalloc="no"
86 +jemalloc="no"
87
88 # parse CC options first
89 for opt do
90 @@ -1149,6 +1150,10 @@ for opt do
91 ;;
92 --enable-tcmalloc) tcmalloc="yes"
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"
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
112
113 @@ -3362,6 +3374,22 @@ EOF
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
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"
141
142 if test "$sdl_too_old" = "yes"; then
143 echo "-> Your SDL version is too old - please upgrade to have SDL support"