render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0001-configure-Add-support-for-tcmalloc.patch

Paolo Bonzini af53ec
From: Fam Zheng <famz@redhat.com>
Paolo Bonzini af53ec
Date: Thu, 26 Mar 2015 11:03:12 +0800
Paolo Bonzini af53ec
Subject: [PATCH] configure: Add support for tcmalloc
Paolo Bonzini af53ec
Paolo Bonzini af53ec
This adds "--enable-tcmalloc" and "--disable-tcmalloc" to allow linking
Paolo Bonzini af53ec
to libtcmalloc from gperftools.
Paolo Bonzini af53ec
Paolo Bonzini af53ec
tcmalloc is a malloc implementation that works well with threads and is
Paolo Bonzini af53ec
fast, so it is good for performance.
Paolo Bonzini af53ec
Paolo Bonzini af53ec
It is disabled by default, because the MALLOC_PERTURB_ flag we use in
Paolo Bonzini af53ec
tests doesn't work with tcmalloc. However we can enable tcmalloc
Paolo Bonzini af53ec
specific heap checker and profilers later.
Paolo Bonzini af53ec
Paolo Bonzini af53ec
An IOPS gain can be observed with virtio-blk-dataplane, other parts of
Paolo Bonzini af53ec
QEMU will directly benefit from it as well:
Paolo Bonzini af53ec
Paolo Bonzini af53ec
==========================================================
Paolo Bonzini af53ec
                       glibc malloc
Paolo Bonzini af53ec
----------------------------------------------------------
Paolo Bonzini af53ec
rw         bs         iodepth    bw     iops       latency
Paolo Bonzini af53ec
read       4k         1          150    38511      24
Paolo Bonzini af53ec
----------------------------------------------------------
Paolo Bonzini af53ec
Paolo Bonzini af53ec
==========================================================
Paolo Bonzini af53ec
                         tcmalloc
Paolo Bonzini af53ec
----------------------------------------------------------
Paolo Bonzini af53ec
rw         bs         iodepth    bw     iops       latency
Paolo Bonzini af53ec
read       4k         1          156    39969      23
Paolo Bonzini af53ec
----------------------------------------------------------
Paolo Bonzini af53ec
Paolo Bonzini af53ec
Signed-off-by: Fam Zheng <famz@redhat.com>
Paolo Bonzini af53ec
Message-Id: <1427338992-27057-1-git-send-email-famz@redhat.com>
Paolo Bonzini af53ec
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
18eddd
(cherry picked from commit 2847b46958ab0bd604e1b3fcafba0f5ba4375833)
Paolo Bonzini af53ec
---
Paolo Bonzini af53ec
 configure | 24 ++++++++++++++++++++++++
Paolo Bonzini af53ec
 1 file changed, 24 insertions(+)
Paolo Bonzini af53ec
Paolo Bonzini af53ec
diff --git a/configure b/configure
Paolo Bonzini af53ec
index 6969f6f..75a4def 100755
Paolo Bonzini af53ec
--- a/configure
Paolo Bonzini af53ec
+++ b/configure
Paolo Bonzini af53ec
@@ -336,6 +336,7 @@ libssh2=""
Paolo Bonzini af53ec
 vhdx=""
Paolo Bonzini af53ec
 quorum=""
Paolo Bonzini af53ec
 numa=""
Paolo Bonzini af53ec
+tcmalloc="no"
Paolo Bonzini af53ec
 
Paolo Bonzini af53ec
 # parse CC options first
Paolo Bonzini af53ec
 for opt do
Paolo Bonzini af53ec
@@ -1134,6 +1135,10 @@ for opt do
Paolo Bonzini af53ec
   ;;
Paolo Bonzini af53ec
   --enable-numa) numa="yes"
Paolo Bonzini af53ec
   ;;
Paolo Bonzini af53ec
+  --disable-tcmalloc) tcmalloc="no"
Paolo Bonzini af53ec
+  ;;
Paolo Bonzini af53ec
+  --enable-tcmalloc) tcmalloc="yes"
Paolo Bonzini af53ec
+  ;;
Paolo Bonzini af53ec
   *)
Paolo Bonzini af53ec
       echo "ERROR: unknown option $opt"
Paolo Bonzini af53ec
       echo "Try '$0 --help' for more information"
Paolo Bonzini af53ec
@@ -1407,6 +1412,8 @@ Advanced options (experts only):
Paolo Bonzini af53ec
   --enable-quorum          enable quorum block filter support
Paolo Bonzini af53ec
   --disable-numa           disable libnuma support
Paolo Bonzini af53ec
   --enable-numa            enable libnuma support
Paolo Bonzini af53ec
+  --disable-tcmalloc       disable tcmalloc support
Paolo Bonzini af53ec
+  --enable-tcmalloc        enable tcmalloc support
Paolo Bonzini af53ec
 
Paolo Bonzini af53ec
 NOTE: The object files are built at the place where configure is launched
Paolo Bonzini af53ec
 EOF
Paolo Bonzini af53ec
@@ -3331,6 +3338,22 @@ EOF
Paolo Bonzini af53ec
 fi
Paolo Bonzini af53ec
 
Paolo Bonzini af53ec
 ##########################################
Paolo Bonzini af53ec
+# tcmalloc probe
Paolo Bonzini af53ec
+
Paolo Bonzini af53ec
+if test "$tcmalloc" = "yes" ; then
Paolo Bonzini af53ec
+  cat > $TMPC << EOF
Paolo Bonzini af53ec
+#include <stdlib.h>
Paolo Bonzini af53ec
+int main(void) { malloc(1); return 0; }
Paolo Bonzini af53ec
+EOF
Paolo Bonzini af53ec
+
Paolo Bonzini af53ec
+  if compile_prog "" "-ltcmalloc" ; then
Paolo Bonzini af53ec
+    LIBS="-ltcmalloc $LIBS"
Paolo Bonzini af53ec
+  else
Paolo Bonzini af53ec
+    feature_not_found "tcmalloc" "install gperftools devel"
Paolo Bonzini af53ec
+  fi
Paolo Bonzini af53ec
+fi
Paolo Bonzini af53ec
+
Paolo Bonzini af53ec
+##########################################
Paolo Bonzini af53ec
 # signalfd probe
Paolo Bonzini af53ec
 signalfd="no"
Paolo Bonzini af53ec
 cat > $TMPC << EOF
Paolo Bonzini af53ec
@@ -4441,6 +4464,7 @@ echo "lzo support       $lzo"
Paolo Bonzini af53ec
 echo "snappy support    $snappy"
Paolo Bonzini af53ec
 echo "bzip2 support     $bzip2"
Paolo Bonzini af53ec
 echo "NUMA host support $numa"
Paolo Bonzini af53ec
+echo "tcmalloc support  $tcmalloc"
Paolo Bonzini af53ec
 
Paolo Bonzini af53ec
 if test "$sdl_too_old" = "yes"; then
Paolo Bonzini af53ec
 echo "-> Your SDL version is too old - please upgrade to have SDL support"