Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](memory) Disable Jemalloc Hook #45210

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion be/src/http/default_path_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void memory_info_handler(std::stringstream* output) {
auto* _opaque = static_cast<std::string*>(opaque);
_opaque->append(buf);
};
jemalloc_stats_print(write_cb, &tmp, "a");
malloc_stats_print(write_cb, &tmp, "a");
boost::replace_all(tmp, "\n", "<br>");
(*output) << tmp;
#else
Expand Down
4 changes: 1 addition & 3 deletions be/src/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/src/runtime")

file(GLOB_RECURSE RUNTIME_FILES CONFIGURE_DEPENDS *.cpp *.cc)

if (NOT USE_JEMALLOC OR NOT USE_MEM_TRACKER)
list(REMOVE_ITEM RUNTIME_FILES ${CMAKE_CURRENT_SOURCE_DIR}/memory/jemalloc_hook.cpp)
endif()
list(REMOVE_ITEM RUNTIME_FILES ${CMAKE_CURRENT_SOURCE_DIR}/memory/jemalloc_hook.cpp)

add_library(Runtime STATIC
${RUNTIME_FILES}
Expand Down
8 changes: 4 additions & 4 deletions be/src/runtime/memory/heap_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ void HeapProfiler::set_prof_active(bool prof) {
#ifdef USE_JEMALLOC
std::lock_guard guard(_mutex);
try {
int err = jemallctl("prof.active", nullptr, nullptr, &prof, 1);
err |= jemallctl("prof.thread_active_init", nullptr, nullptr, &prof, 1);
int err = mallctl("prof.active", nullptr, nullptr, &prof, 1);
err |= mallctl("prof.thread_active_init", nullptr, nullptr, &prof, 1);
if (err) {
LOG(WARNING) << "jemalloc heap profiling start failed, " << err;
} else {
Expand All @@ -48,7 +48,7 @@ bool HeapProfiler::get_prof_dump(const std::string& profile_file_name) {
std::lock_guard guard(_mutex);
const char* file_name_ptr = profile_file_name.c_str();
try {
int err = jemallctl("prof.dump", nullptr, nullptr, &file_name_ptr, sizeof(const char*));
int err = mallctl("prof.dump", nullptr, nullptr, &file_name_ptr, sizeof(const char*));
if (err) {
LOG(WARNING) << "dump heap profile failed, " << err;
return false;
Expand Down Expand Up @@ -93,7 +93,7 @@ bool HeapProfiler::check_heap_profiler() {
#ifdef USE_JEMALLOC
size_t value = 0;
size_t sz = sizeof(value);
jemallctl("prof.active", &value, &sz, nullptr, 0);
mallctl("prof.active", &value, &sz, nullptr, 0);
return value;
#else
return false;
Expand Down
2 changes: 1 addition & 1 deletion be/src/util/mem_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void MemInfo::refresh_allocator_mem() {
// the current epoch number, which might be useful to log as a sanity check.
uint64_t epoch = 0;
size_t sz = sizeof(epoch);
jemallctl("epoch", &epoch, &sz, &epoch, sz);
mallctl("epoch", &epoch, &sz, &epoch, sz);

// Number of extents of the given type in this arena in the bucket corresponding to page size index.
// Large size class starts at 16384, the extents have three sizes before 16384: 4096, 8192, and 12288, so + 3
Expand Down
10 changes: 5 additions & 5 deletions be/src/util/mem_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class MemInfo {
#ifdef USE_JEMALLOC
size_t value = 0;
size_t sz = sizeof(value);
if (jemallctl(name.c_str(), &value, &sz, nullptr, 0) == 0) {
if (mallctl(name.c_str(), &value, &sz, nullptr, 0) == 0) {
return value;
}
#endif
Expand All @@ -114,7 +114,7 @@ class MemInfo {
#ifdef USE_JEMALLOC
unsigned value = 0;
size_t sz = sizeof(value);
if (jemallctl(name.c_str(), &value, &sz, nullptr, 0) == 0) {
if (mallctl(name.c_str(), &value, &sz, nullptr, 0) == 0) {
return value;
}
#endif
Expand Down Expand Up @@ -146,8 +146,8 @@ class MemInfo {
if (config::enable_je_purge_dirty_pages) {
try {
// Purge all unused dirty pages for arena <i>, or for all arenas if <i> equals MALLCTL_ARENAS_ALL.
int err = jemallctl(fmt::format("arena.{}.purge", MALLCTL_ARENAS_ALL).c_str(),
nullptr, nullptr, nullptr, 0);
int err = mallctl(fmt::format("arena.{}.purge", MALLCTL_ARENAS_ALL).c_str(),
nullptr, nullptr, nullptr, 0);
if (err) {
LOG(WARNING) << "Jemalloc purge all unused dirty pages failed";
}
Expand All @@ -166,7 +166,7 @@ class MemInfo {
#ifdef USE_JEMALLOC
constexpr size_t TCACHE_LIMIT = (1ULL << 30); // 1G
if (allocator_cache_mem() - je_dirty_pages_mem() > TCACHE_LIMIT) {
int err = jemallctl("thread.tcache.flush", nullptr, nullptr, nullptr, 0);
int err = mallctl("thread.tcache.flush", nullptr, nullptr, nullptr, 0);
if (err) {
LOG(WARNING) << "Jemalloc thread.tcache.flush failed";
}
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/common/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class DefaultMemoryAllocator {

static void release_unused() {
#if defined(USE_JEMALLOC)
jemallctl(fmt::format("arena.{}.purge", MALLCTL_ARENAS_ALL).c_str(), NULL, NULL, NULL, 0);
mallctl(fmt::format("arena.{}.purge", MALLCTL_ARENAS_ALL).c_str(), NULL, NULL, NULL, 0);
#endif // defined(USE_JEMALLOC)
}
};
Expand Down
14 changes: 0 additions & 14 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -377,20 +377,6 @@ if [[ "${BUILD_TYPE_LOWWER}" == "asan" ]]; then
elif [[ -z "${USE_JEMALLOC}" ]]; then
USE_JEMALLOC='ON'
fi
if [[ -f "${TP_INCLUDE_DIR}/jemalloc/jemalloc_doris_with_prefix.h" ]]; then
# compatible with old thirdparty
rm -rf "${TP_INCLUDE_DIR}/jemalloc/jemalloc.h"
rm -rf "${TP_LIB_DIR}/libjemalloc_doris.a"
rm -rf "${TP_LIB_DIR}/libjemalloc_doris_pic.a"
rm -rf "${TP_INCLUDE_DIR}/rocksdb"
rm -rf "${TP_LIB_DIR}/librocksdb.a"

mv "${TP_INCLUDE_DIR}/jemalloc/jemalloc_doris_with_prefix.h" "${TP_INCLUDE_DIR}/jemalloc/jemalloc.h"
mv "${TP_LIB_DIR}/libjemalloc_doris_with_prefix.a" "${TP_LIB_DIR}/libjemalloc_doris.a"
mv "${TP_LIB_DIR}/libjemalloc_doris_with_prefix_pic.a" "${TP_LIB_DIR}/libjemalloc_doris_pic.a"
mv "${TP_LIB_DIR}/librocksdb_jemalloc_with_prefix.a" "${TP_LIB_DIR}/librocksdb.a"
mv -f "${TP_INCLUDE_DIR}/rocksdb_jemalloc_with_prefix" "${TP_INCLUDE_DIR}/rocksdb"
fi
if [[ -z "${USE_BTHREAD_SCANNER}" ]]; then
USE_BTHREAD_SCANNER='OFF'
fi
Expand Down
6 changes: 0 additions & 6 deletions cloud/src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ set(COMMON_FILES
network_util.cpp
)

if (USE_JEMALLOC)
set(COMMON_FILES ${COMMON_FILES}
jemalloc_hook.cpp
)
endif()

add_library(Common STATIC
${COMMON_FILES}
)
4 changes: 3 additions & 1 deletion thirdparty/build-thirdparty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1529,8 +1529,10 @@ build_jemalloc_doris() {
WITH_LG_PAGE=''
fi

# CFLAGS="${cflags}" ../configure --prefix="${TP_INSTALL_DIR}" --with-install-suffix="_doris" "${WITH_LG_PAGE}" \
# --with-jemalloc-prefix=je --enable-prof --disable-cxx --disable-libdl --disable-shared
CFLAGS="${cflags}" ../configure --prefix="${TP_INSTALL_DIR}" --with-install-suffix="_doris" "${WITH_LG_PAGE}" \
--with-jemalloc-prefix=je --enable-prof --disable-cxx --disable-libdl --disable-shared
--enable-prof --disable-libdl --disable-shared

make -j "${PARALLEL}"
make install
Expand Down
Loading