This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 47d43b34b3 [enhancement](thirdparty) Compile Jemalloc separately on 
thirdparty (#12577)
47d43b34b3 is described below

commit 47d43b34b3663170584374033d25ac4c389ba4cf
Author: Xinyi Zou <[email protected]>
AuthorDate: Wed Sep 14 23:31:48 2022 +0800

    [enhancement](thirdparty) Compile Jemalloc separately on thirdparty (#12577)
    
    Compile Jemalloc separately and optimize the configuration
---
 thirdparty/build-thirdparty.sh         | 17 +++++++++++++++++
 thirdparty/download-thirdparty.sh      | 11 +++++++++++
 thirdparty/patches/jemalloc_hook.patch | 11 +++++++++++
 3 files changed, 39 insertions(+)

diff --git a/thirdparty/build-thirdparty.sh b/thirdparty/build-thirdparty.sh
index 28c2ff353d..ae1254521f 100755
--- a/thirdparty/build-thirdparty.sh
+++ b/thirdparty/build-thirdparty.sh
@@ -1297,6 +1297,22 @@ build_hdfs3() {
     strip --strip-debug --strip-unneeded "${TP_LIB_DIR}"/libhdfs3.a
 }
 
+# jemalloc
+build_jemalloc() {
+    check_if_source_exist "${JEMALLOC_SOURCE}"
+    cd "${TP_SOURCE_DIR}/${JEMALLOC_SOURCE}"
+
+    mkdir -p "${BUILD_DIR}"
+    cd "${BUILD_DIR}"
+
+    cflags='-O3 -fno-omit-frame-pointer -fPIC -g'
+    CFLAGS="${cflags}" ../configure --prefix="${TP_INSTALL_DIR}" 
--with-jemalloc-prefix=je --enable-prof --disable-cxx --disable-libdl 
--disable-shared
+
+    make -j "${PARALLEL}"
+    make install
+    mv "${TP_INSTALL_DIR}"/lib/libjemalloc.a 
"${TP_INSTALL_DIR}"/lib/libjemalloc_doris.a
+}
+
 # benchmark
 build_benchmark() {
     check_if_source_exist "${BENCHMARK_SOURCE}"
@@ -1419,6 +1435,7 @@ build_cyrus_sasl
 build_librdkafka
 build_flatbuffers
 build_orc
+build_jemalloc
 build_arrow
 build_s2
 build_bitshuffle
diff --git a/thirdparty/download-thirdparty.sh 
b/thirdparty/download-thirdparty.sh
index 3856993c2f..a4ca817bd8 100755
--- a/thirdparty/download-thirdparty.sh
+++ b/thirdparty/download-thirdparty.sh
@@ -325,6 +325,17 @@ if [[ "${LIBRDKAFKA_SOURCE}" == "librdkafka-1.8.2" ]]; then
 fi
 echo "Finished patching ${LIBRDKAFKA_SOURCE}"
 
+# patch jemalloc, disable JEMALLOC_MANGLE for overloading the memory API.
+if [[ "${JEMALLOC_SOURCE}" = "jemalloc-5.2.1" ]]; then
+    cd "${TP_SOURCE_DIR}/${JEMALLOC_SOURCE}"
+    if [[ ! -f "${PATCHED_MARK}" ]]; then
+        patch -p0 <"${TP_PATCH_DIR}/jemalloc_hook.patch"
+        touch "${PATCHED_MARK}"
+    fi
+    cd -
+fi
+echo "Finished patching ${JEMALLOC_SOURCE}"
+
 # patch hyperscan
 # https://github.com/intel/hyperscan/issues/292
 if [[ "${HYPERSCAN_SOURCE}" == "hyperscan-5.4.0" ]]; then
diff --git a/thirdparty/patches/jemalloc_hook.patch 
b/thirdparty/patches/jemalloc_hook.patch
new file mode 100644
index 0000000000..4a41f39510
--- /dev/null
+++ b/thirdparty/patches/jemalloc_hook.patch
@@ -0,0 +1,11 @@
+--- include/jemalloc/jemalloc.sh
++++ include/jemalloc/jemalloc.sh
+@@ -12,7 +12,7 @@ extern "C" {
+ EOF
+
+ for hdr in jemalloc_defs.h jemalloc_rename.h jemalloc_macros.h \
+-           jemalloc_protos.h jemalloc_typedefs.h jemalloc_mangle.h ; do
++           jemalloc_protos.h jemalloc_typedefs.h ; do
+   cat "${objroot}include/jemalloc/${hdr}" \
+       | grep -v 'Generated from .* by configure\.' \
+       | sed -e 's/ $//g'
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to