diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index 3326a922..24206598 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -71,13 +71,13 @@ jobs: sudo apt update sudo apt -y install zlib1g-dev libcurl4-openssl-dev libproj-dev libssl-dev libturbojpeg0-dev \ libjpeg-dev libc6-dev libboost-log-dev libboost-filesystem-dev libboost-system-dev \ - libsqlite3-dev libpng-dev libtiff5-dev libopenjp2-7-dev librados-dev \ + libsqlite3-dev libpng-dev libtiff5-dev libopenjp2-7-dev librados-dev libjemalloc-dev \ gettext build-essential cmake libcppunit-dev doxygen graphviz - name: Build packages run: | mkdir build && cd build - cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_VERSION=${{ github.ref_name }} -DCPACK_SYSTEM_NAME="ubuntu-24.04" .. + cmake -DCMAKE_INSTALL_PREFIX=/usr -DALLOCATOR=jemalloc -DBUILD_VERSION=${{ github.ref_name }} -DCPACK_SYSTEM_NAME="ubuntu-24.04" .. make -j2 make package cmake -DCEPH_ENABLED=1 .. diff --git a/CHANGELOG.md b/CHANGELOG.md index ca1d07ed..5ac1be98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ Le format est basé sur [Keep a Changelog](https://keepachangelog.com/) et ce pr ## [Unreleased] +## [5.0.2] - 2026-11-10 + +### Added + +- Possibilité de compiler en changeant l'allocateur mémoire (`tcmalloc` et `jemalloc` disponibles) + ## [5.0.1] - 2026-10-16 ### Fixed @@ -268,6 +274,7 @@ Les librairies sont gérées de manière indépendantes, conditionnées pour êt [1.0.3]: https://github.com/rok4/core-cpp/releases/tag/1.0.3 [Unreleased]: https://github.com/rok4/core-cpp/compare/5.0.0...HEAD +[5.0.2]: https://github.com/rok4/core-cpp/compare/5.0.0...5.0.0 [5.0.0]: https://github.com/rok4/core-cpp/compare/4.1.0...5.0.0 [4.1.0]: https://github.com/rok4/core-cpp/compare/4.0.0...4.1.0 [4.0.0]: https://github.com/rok4/core-cpp/compare/3.1.0...4.0.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index 35c5c0cb..c86ffd52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation location") set(BUILD_VERSION "0.0.0" CACHE STRING "Build version") set(CEPH_ENABLED 0 CACHE BOOL "Build with ceph storage") +set(ALLOCATOR "" CACHE STRING "Build with allocator") set(KDU_ENABLED 0 CACHE BOOL "Build with kakadu") set(UNITTEST_ENABLED 1 CACHE BOOL "Unit tests compilation") set(DOC_ENABLED 1 CACHE BOOL "Documentation compilation") @@ -32,6 +33,7 @@ configure_file(config.h.in config.h ESCAPE_QUOTES @ONLY) set(CMAKE_THREAD_LIBS_INIT "-lpthread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") + set(CMAKE_HAVE_THREADS_LIBRARY 1) set(CMAKE_USE_PTHREADS_INIT 1) set(THREADS_PREFER_PTHREAD_FLAG ON) @@ -85,6 +87,13 @@ if(CEPH_ENABLED) include_directories(${RADOS_INCLUDE_DIR}) endif(CEPH_ENABLED) + +IF(ALLOCATOR STREQUAL "jemalloc") + include_directories(${JEMALLOC_INCLUDE_DIR}) +ELSEIF(ALLOCATOR STREQUAL "tcmalloc") + include_directories(${TCMALLOC_INCLUDE_DIR}) +ENDIF() + add_library(${PROJECT_NAME} SHARED ${LIBROK4_SRCS}) target_include_directories(${PROJECT_NAME} PRIVATE @@ -108,6 +117,12 @@ if(CEPH_ENABLED) target_link_libraries(${PROJECT_NAME} PUBLIC rados) endif(CEPH_ENABLED) +IF(ALLOCATOR STREQUAL "jemalloc") + target_link_libraries(${PROJECT_NAME} PUBLIC jemalloc) +ELSEIF(ALLOCATOR STREQUAL "tcmalloc") + target_link_libraries(${PROJECT_NAME} PUBLIC tcmalloc) +ENDIF() + ################### TESTS UNITAIRES if(UNITTEST_ENABLED) @@ -197,6 +212,11 @@ if(CPACK_SYSTEM_NAME AND CPACK_SYSTEM_NAME STREQUAL "ubuntu-20.04" OR CPACK_SYST if(CEPH_ENABLED) set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, librados-dev") endif(CEPH_ENABLED) + IF(ALLOCATOR STREQUAL "jemalloc") + set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libjemalloc-dev") + ELSEIF(ALLOCATOR STREQUAL "tcmalloc") + set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libtcmalloc-minimal4t64") + ENDIF() set(CPACK_BINARY_DEB "ON") endif() diff --git a/README.md b/README.md index cc260c99..26994d37 100644 --- a/README.md +++ b/README.md @@ -213,6 +213,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS( "Rok4" DEFAULT_MSG ROK4_INCLUDE_DIR ROK4_LIBR ### Variables CMake * `CEPH_ENABLED` : active la compilation la classe de gestion du stockage Ceph. Valeur par défaut : `0`, `1` pour activer. +* `ALLOCATOR` : modifie l'implémentation des fonctions d'allocation. Valeurs possibles : `jemalloc`, `tcmalloc`. Valeur par défaut : `` * `UNITTEST_ENABLED` : active la compilation des tests unitaires. Valeur par défaut : `1`, `0` pour désactiver. * `DOC_ENABLED` : active la compilation de la documentation. Valeur par défaut : `1`, `0` pour désactiver. * `BUILD_VERSION` : version de la librairie compilée. Valeur par défaut : `0.0.0`. Utile pour la compilation de la documentation. diff --git a/cmake/modules/FindJemalloc.cmake b/cmake/modules/FindJemalloc.cmake new file mode 100644 index 00000000..271c79c3 --- /dev/null +++ b/cmake/modules/FindJemalloc.cmake @@ -0,0 +1,26 @@ + +# CMake module to search for Jemalloc library +# +# If it's found it sets JEMALLOC_FOUND to TRUE +# and following variables are set: +# JEMALLOC_INCLUDE_DIR +# JEMALLOC_LIBRARY + +FIND_PATH(JEMALLOC_INCLUDE_DIR jemalloc.h + /usr/local/include + /usr/include + /usr/include/jemalloc + c:/msys/local/include + ) + +FIND_LIBRARY(JEMALLOC_LIBRARY NAMES libjemalloc.so PATHS + /usr/local/lib + /usr/lib + /lib + /usr/lib64 + /usr/lib/x86_64-linux-gnu + c:/msys/local/lib + ) + +INCLUDE( "FindPackageHandleStandardArgs" ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( "Jemalloc" DEFAULT_MSG JEMALLOC_INCLUDE_DIR JEMALLOC_LIBRARY ) diff --git a/cmake/modules/FindTcmalloc.cmake b/cmake/modules/FindTcmalloc.cmake new file mode 100644 index 00000000..dc453d3f --- /dev/null +++ b/cmake/modules/FindTcmalloc.cmake @@ -0,0 +1,18 @@ + +# CMake module to search for Tcmalloc library +# +# If it's found it sets TCMALLOC_FOUND to TRUE +# and following variables are set: +# TCMALLOC_LIBRARY + +FIND_LIBRARY(TCMALLOC_LIBRARY NAMES libtcmalloc.so PATHS + /usr/local/lib + /usr/lib + /lib + /usr/lib64 + /usr/lib/x86_64-linux-gnu + c:/msys/local/lib + ) + +INCLUDE( "FindPackageHandleStandardArgs" ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( "Tcmalloc" DEFAULT_MSG TCMALLOC_LIBRARY ) diff --git a/cmake/modules/dependencies.cmake b/cmake/modules/dependencies.cmake index 8f86fc7a..649d440f 100644 --- a/cmake/modules/dependencies.cmake +++ b/cmake/modules/dependencies.cmake @@ -137,6 +137,22 @@ IF(CEPH_ENABLED) endif(NOT TARGET rados) ENDIF(CEPH_ENABLED) +IF(ALLOCATOR STREQUAL "jemalloc") + if(NOT TARGET jemalloc) + find_package(Jemalloc) + if(NOT JEMALLOC_FOUND) + message(FATAL_ERROR "Cannot find extern library jemalloc") + endif() + endif(NOT TARGET jemalloc) +ELSEIF(ALLOCATOR STREQUAL "tcmalloc") + if(NOT TARGET tcmalloc) + find_package(Tcmalloc) + if(NOT TCMALLOC_FOUND) + message(FATAL_ERROR "Cannot find extern library tcmalloc") + endif() + endif(NOT TARGET tcmalloc) +ENDIF() + # Statique if(UNITTEST_ENABLED)