mirror of
https://github.com/netdata/netdata.git
synced 2025-04-21 20:23:00 +00:00
Use mimalloc (#19080)
* Remove NEED_PROTOBUF * Use mimalloc * Disable on Windows and when cmake version < 3.16. * Exclude mimalloc from all * Fix cmake version check * Check minor version to make Ubuntu 22.04 happy. * Print used allocator in build info.
This commit is contained in:
parent
7ccd72d621
commit
b0dd0f93ea
3 changed files with 56 additions and 16 deletions
|
@ -208,7 +208,37 @@ mark_as_advanced(BUILD_FOR_PACKAGING)
|
||||||
cmake_dependent_option(FORCE_LEGACY_LIBBPF "Force usage of libbpf 0.0.9 instead of the latest version." False "ENABLE_PLUGIN_EBPF" False)
|
cmake_dependent_option(FORCE_LEGACY_LIBBPF "Force usage of libbpf 0.0.9 instead of the latest version." False "ENABLE_PLUGIN_EBPF" False)
|
||||||
mark_as_advanced(FORCE_LEGACY_LIBBPF)
|
mark_as_advanced(FORCE_LEGACY_LIBBPF)
|
||||||
|
|
||||||
set(NEED_PROTOBUF True)
|
cmake_dependent_option(ENABLE_MIMALLOC "Enable mimalloc allocator" ON
|
||||||
|
"CMAKE_MINOR_VERSION GREATER_EQUAL 18; CMAKE_SIZEOF_VOID_P EQUAL 8; NOT OS_FREEBSD; NOT OS_MACOS; NOT OS_WINDOWS; NOT ENABLE_ADDRESS_SANITIZER" OFF)
|
||||||
|
|
||||||
|
if(ENABLE_MIMALLOC)
|
||||||
|
function(netdata_add_mimalloc)
|
||||||
|
set(MI_BUILD_STATIC ON CACHE INTERNAL "")
|
||||||
|
set(MI_BUILD_SHARED OFF CACHE INTERNAL "")
|
||||||
|
set(MI_BUILD_OBJECT OFF CACHE INTERNAL "")
|
||||||
|
set(MI_BUILD_TESTS OFF CACHE INTERNAL "")
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
include(NetdataFetchContentExtra)
|
||||||
|
|
||||||
|
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
|
||||||
|
FetchContent_Declare(mimalloc
|
||||||
|
GIT_REPOSITORY https://github.com/microsoft/mimalloc.git
|
||||||
|
GIT_TAG 8c532c32c3c96e5ba1f2283e032f69ead8add00f
|
||||||
|
EXCLUDE_FROM_ALL
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
FetchContent_Declare(mimalloc
|
||||||
|
GIT_REPOSITORY https://github.com/microsoft/mimalloc.git
|
||||||
|
GIT_TAG 8c532c32c3c96e5ba1f2283e032f69ead8add00f
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable_NoInstall(mimalloc)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
netdata_add_mimalloc()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(ENABLE_PLUGIN_GO)
|
if(ENABLE_PLUGIN_GO)
|
||||||
include(NetdataGoTools)
|
include(NetdataGoTools)
|
||||||
|
@ -245,12 +275,10 @@ if(ENABLE_WEBRTC)
|
||||||
FetchContent_MakeAvailable(libdatachannel)
|
FetchContent_MakeAvailable(libdatachannel)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NEED_PROTOBUF)
|
include(NetdataProtobuf)
|
||||||
include(NetdataProtobuf)
|
|
||||||
|
|
||||||
if(ENABLE_BUNDLED_PROTOBUF)
|
if(ENABLE_BUNDLED_PROTOBUF)
|
||||||
netdata_bundle_protobuf()
|
netdata_bundle_protobuf()
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(PKG_FILES_PATH "${CMAKE_SOURCE_DIR}/packaging/cmake/pkg-files")
|
set(PKG_FILES_PATH "${CMAKE_SOURCE_DIR}/packaging/cmake/pkg-files")
|
||||||
|
@ -590,13 +618,7 @@ else()
|
||||||
pkg_check_modules(CRYPTO IMPORTED_TARGET REQUIRED libcrypto)
|
pkg_check_modules(CRYPTO IMPORTED_TARGET REQUIRED libcrypto)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#
|
netdata_detect_protobuf()
|
||||||
# figure out if we need protoc/protobuf
|
|
||||||
#
|
|
||||||
|
|
||||||
if(NEED_PROTOBUF)
|
|
||||||
netdata_detect_protobuf()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# source files
|
# source files
|
||||||
|
@ -1822,6 +1844,7 @@ target_include_directories(libnetdata BEFORE PUBLIC ${CONFIG_H_DIR} ${CMAKE_SOUR
|
||||||
# target_link_libraries(test Threads::Threads)
|
# target_link_libraries(test Threads::Threads)
|
||||||
|
|
||||||
target_link_libraries(libnetdata PUBLIC
|
target_link_libraries(libnetdata PUBLIC
|
||||||
|
"$<$<BOOL:${ENABLE_MIMALLOC}>:mimalloc-static>"
|
||||||
"$<$<NOT:$<BOOL:${HAVE_BUILTIN_ATOMICS}>>:atomic>"
|
"$<$<NOT:$<BOOL:${HAVE_BUILTIN_ATOMICS}>>:atomic>"
|
||||||
"$<$<OR:$<BOOL:${OS_LINUX}>,$<BOOL:${OS_FREEBSD}>>:pthread;rt>"
|
"$<$<OR:$<BOOL:${OS_LINUX}>,$<BOOL:${OS_FREEBSD}>>:pthread;rt>"
|
||||||
"$<$<BOOL:${OS_WINDOWS}>:kernel32;advapi32;winmm;rpcrt4;wevtapi;ole32;oleaut32;wbemuuid>"
|
"$<$<BOOL:${OS_WINDOWS}>:kernel32;advapi32;winmm;rpcrt4;wevtapi;ole32;oleaut32;wbemuuid>"
|
||||||
|
@ -2553,9 +2576,7 @@ target_link_libraries(netdata PRIVATE
|
||||||
"$<$<BOOL:${CURL_FOUND}>:PkgConfig::CURL>"
|
"$<$<BOOL:${CURL_FOUND}>:PkgConfig::CURL>"
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NEED_PROTOBUF)
|
netdata_add_protobuf(netdata)
|
||||||
netdata_add_protobuf(netdata)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# build systemd-cat-native
|
# build systemd-cat-native
|
||||||
|
|
|
@ -145,6 +145,7 @@
|
||||||
#cmakedefine ENABLE_BUNDLED_JSONC
|
#cmakedefine ENABLE_BUNDLED_JSONC
|
||||||
#cmakedefine ENABLE_BUNDLED_YAML
|
#cmakedefine ENABLE_BUNDLED_YAML
|
||||||
#cmakedefine ENABLE_BUNDLED_PROTOBUF
|
#cmakedefine ENABLE_BUNDLED_PROTOBUF
|
||||||
|
#cmakedefine ENABLE_MIMALLOC
|
||||||
|
|
||||||
// directory paths
|
// directory paths
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ typedef enum __attribute__((packed)) {
|
||||||
BIB_FEATURE_CONTEXTS,
|
BIB_FEATURE_CONTEXTS,
|
||||||
BIB_FEATURE_TIERING,
|
BIB_FEATURE_TIERING,
|
||||||
BIB_FEATURE_ML,
|
BIB_FEATURE_ML,
|
||||||
|
BIB_FEATURE_ALLOCATOR,
|
||||||
BIB_DB_DBENGINE,
|
BIB_DB_DBENGINE,
|
||||||
BIB_DB_ALLOC,
|
BIB_DB_ALLOC,
|
||||||
BIB_DB_RAM,
|
BIB_DB_RAM,
|
||||||
|
@ -530,6 +531,14 @@ static struct {
|
||||||
.json = "ml",
|
.json = "ml",
|
||||||
.value = NULL,
|
.value = NULL,
|
||||||
},
|
},
|
||||||
|
[BIB_FEATURE_ALLOCATOR] = {
|
||||||
|
.category = BIC_FEATURE,
|
||||||
|
.type = BIT_STRING,
|
||||||
|
.analytics = "allocator",
|
||||||
|
.print = "Memory Allocator",
|
||||||
|
.json = "allocator",
|
||||||
|
.value = NULL,
|
||||||
|
},
|
||||||
[BIB_DB_DBENGINE] = {
|
[BIB_DB_DBENGINE] = {
|
||||||
.category = BIC_DATABASE,
|
.category = BIC_DATABASE,
|
||||||
.type = BIT_BOOLEAN,
|
.type = BIT_BOOLEAN,
|
||||||
|
@ -1096,6 +1105,15 @@ __attribute__((constructor)) void initialize_build_info(void) {
|
||||||
build_info_set_status(BIB_FEATURE_ML, true);
|
build_info_set_status(BIB_FEATURE_ML, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ENABLE_MIMALLOC)
|
||||||
|
build_info_set_status(BIB_FEATURE_ALLOCATOR, true);
|
||||||
|
build_info_set_value(BIB_FEATURE_ALLOCATOR, "mimalloc");
|
||||||
|
#else
|
||||||
|
build_info_set_status(BIB_FEATURE_ALLOCATOR, true);
|
||||||
|
build_info_set_value(BIB_FEATURE_ALLOCATOR, "system");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_DBENGINE
|
#ifdef ENABLE_DBENGINE
|
||||||
build_info_set_status(BIB_DB_DBENGINE, true);
|
build_info_set_status(BIB_DB_DBENGINE, true);
|
||||||
#ifdef ENABLE_ZSTD
|
#ifdef ENABLE_ZSTD
|
||||||
|
|
Loading…
Add table
Reference in a new issue