|
@@ -7,6 +7,16 @@ find_package(OpenSSL REQUIRED)
|
|
|
find_package(PkgConfig)
|
|
find_package(PkgConfig)
|
|
|
if(PKG_CONFIG_FOUND)
|
|
if(PKG_CONFIG_FOUND)
|
|
|
pkg_check_modules(LZ4 QUIET liblz4)
|
|
pkg_check_modules(LZ4 QUIET liblz4)
|
|
|
|
|
+ # v1.9.4 — jemalloc replaces glibc malloc for the smartbotic-database
|
|
|
|
|
+ # binary. The fragmentation pattern from per-RPC nlohmann::json node
|
|
|
|
|
+ # churn (107k 33-byte allocations observed on Zoe) defeats glibc's
|
|
|
|
|
+ # malloc_trim because the trailing region of each arena always has a
|
|
|
|
|
+ # live chunk; jemalloc's background-thread dirty-page decay sidesteps
|
|
|
|
|
+ # the contiguity requirement and reclaims unused pages on a wallclock
|
|
|
|
|
+ # timer regardless of allocation activity. Linked as a library so
|
|
|
|
|
+ # the binary picks up jemalloc's malloc/free symbols at link time;
|
|
|
|
|
+ # no LD_PRELOAD needed.
|
|
|
|
|
+ pkg_check_modules(JEMALLOC QUIET jemalloc)
|
|
|
endif()
|
|
endif()
|
|
|
|
|
|
|
|
# Source files
|
|
# Source files
|
|
@@ -71,6 +81,21 @@ if(LZ4_FOUND)
|
|
|
target_include_directories(smartbotic-database PRIVATE ${LZ4_INCLUDE_DIRS})
|
|
target_include_directories(smartbotic-database PRIVATE ${LZ4_INCLUDE_DIRS})
|
|
|
endif()
|
|
endif()
|
|
|
|
|
|
|
|
|
|
+# v1.9.4 — jemalloc allocator (overrides glibc malloc/free)
|
|
|
|
|
+if(JEMALLOC_FOUND)
|
|
|
|
|
+ target_compile_definitions(smartbotic-database PRIVATE HAVE_JEMALLOC)
|
|
|
|
|
+ target_link_libraries(smartbotic-database PRIVATE ${JEMALLOC_LIBRARIES})
|
|
|
|
|
+ target_include_directories(smartbotic-database PRIVATE ${JEMALLOC_INCLUDE_DIRS})
|
|
|
|
|
+ # Position-sensitive: jemalloc must be linked early so its symbols win
|
|
|
|
|
+ # over libc's. -Wl,-no-as-needed forces the linker to record the
|
|
|
|
|
+ # dependency even though we don't reference any jemalloc symbol
|
|
|
|
|
+ # directly (we just want its malloc to override).
|
|
|
|
|
+ target_link_options(smartbotic-database PRIVATE -Wl,-no-as-needed)
|
|
|
|
|
+ message(STATUS "Linking with jemalloc (${JEMALLOC_VERSION})")
|
|
|
|
|
+else()
|
|
|
|
|
+ message(STATUS "jemalloc not found — falling back to glibc malloc (degraded RSS reclaim under load)")
|
|
|
|
|
+endif()
|
|
|
|
|
+
|
|
|
# Systemd support
|
|
# Systemd support
|
|
|
if(SYSTEMD_FOUND)
|
|
if(SYSTEMD_FOUND)
|
|
|
target_compile_definitions(smartbotic-database PRIVATE HAVE_SYSTEMD)
|
|
target_compile_definitions(smartbotic-database PRIVATE HAVE_SYSTEMD)
|