From ee3655db1df58e6d7634a8030ec7aa2168ffc9fd Mon Sep 17 00:00:00 2001 From: Pranav Bhandari Date: Fri, 27 Dec 2024 13:48:31 -0800 Subject: [PATCH] Migrate OSS build from custom to getdeps Summary: X-link: https://github.com/facebookincubator/zstrong/pull/1098 We have been manually syncing our builds when there is a change in builds of our dependencies (folly, thrift). This has been one of the major source of work in OSS maintenance. Migrating to getdeps will automatically sync the dependencies which means we only have to manage our own builds. NOTE: There is a dependency of getdeps on zlib which requires us to first run sudo dnf install -y zlib-devel before we successfully run getdeps. I don't think this should affect the OSS build as it is a getdeps dependency. Reviewed By: haowu14 Differential Revision: D65844211 fbshipit-source-id: 8e89e670cdec4a21ca7aba48ae58b5b72ddbf832 --- cachelib/CMakeLists.txt | 2 ++ cachelib/allocator/CMakeLists.txt | 11 ++++++- cachelib/cmake/FindNUMA.cmake | 50 ++++++++++++++++++++++++++++++ cachelib/cmake/FindSparsemap.cmake | 19 ++++++++++++ cachelib/datatype/CMakeLists.txt | 1 + cachelib/shm/CMakeLists.txt | 2 +- 6 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 cachelib/cmake/FindNUMA.cmake create mode 100644 cachelib/cmake/FindSparsemap.cmake diff --git a/cachelib/CMakeLists.txt b/cachelib/CMakeLists.txt index 506ba66bcf..581ac8a219 100644 --- a/cachelib/CMakeLists.txt +++ b/cachelib/CMakeLists.txt @@ -105,6 +105,8 @@ find_package(wangle CONFIG REQUIRED) find_package(Zlib REQUIRED) find_package(Zstd REQUIRED) find_package(FBThrift REQUIRED) # must come after wangle +find_package(NUMA REQUIRED) +find_package(Sparsemap REQUIRED) find_package(uring) if (NOT uring_FOUND) diff --git a/cachelib/allocator/CMakeLists.txt b/cachelib/allocator/CMakeLists.txt index 6103cdc823..483b41583e 100644 --- a/cachelib/allocator/CMakeLists.txt +++ b/cachelib/allocator/CMakeLists.txt @@ -27,7 +27,16 @@ add_library (cachelib_allocator ${SERIALIZE_THRIFT_FILES} ${DATASTRUCT_SERIALIZE_THRIFT_FILES} ${MEMORY_SERIALIZE_THRIFT_FILES} - CacheAllocator.cpp + CacheAllocatorLru2QCache.cpp + CacheAllocatorLru5B2QCache.cpp + CacheAllocatorLru5BCache.cpp + CacheAllocatorLru5BCacheWithSpinBuckets.cpp + CacheAllocatorLruCache.cpp + CacheAllocatorLruCacheWithSpinBuckets.cpp + CacheAllocatorTinyLFU5BCache.cpp + CacheAllocatorTinyLFUCache.cpp + CacheAllocatorWTinyLFU5BCache.cpp + CacheAllocatorWTinyLFUCache.cpp Cache.cpp CacheDetails.cpp CacheStats.cpp diff --git a/cachelib/cmake/FindNUMA.cmake b/cachelib/cmake/FindNUMA.cmake new file mode 100644 index 0000000000..6f6f5428a9 --- /dev/null +++ b/cachelib/cmake/FindNUMA.cmake @@ -0,0 +1,50 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# - Find NUMA +# Find the NUMA library and includes +# +# NUMA_INCLUDE_DIRS - where to find numa.h, etc. +# NUMA_LIBRARIES - List of libraries when using NUMA. +# NUMA_FOUND - True if NUMA found. + +message(STATUS "looking numa in dir: : ${NUMA_INCLUDE_DIRS}") +message(STATUS "root: : ${NUMA_ROOT_DIR}") + +find_path(NUMA_INCLUDE_DIRS + NAMES numa.h numaif.h + HINTS ${NUMA_ROOT_DIR}/include) + +message(STATUS "root: : ${NUMA_ROOT_DIR}") + +message(STATUS "looking numa in dir again : ${NUMA_INCLUDE_DIRS}") + +find_library(NUMA_LIBRARIES + NAMES numa + HINTS ${NUMA_ROOT_DIR}/lib) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(NUMA DEFAULT_MSG NUMA_LIBRARIES NUMA_INCLUDE_DIRS) + +mark_as_advanced( + NUMA_LIBRARIES + NUMA_INCLUDE_DIRS) + +if(NUMA_FOUND AND NOT (TARGET NUMA::NUMA)) + add_library (NUMA::NUMA UNKNOWN IMPORTED) + set_target_properties(NUMA::NUMA + PROPERTIES + IMPORTED_LOCATION ${NUMA_LIBRARIES} + INTERFACE_INCLUDE_DIRECTORIES ${NUMA_INCLUDE_DIRS}) +endif() diff --git a/cachelib/cmake/FindSparsemap.cmake b/cachelib/cmake/FindSparsemap.cmake new file mode 100644 index 0000000000..346bc09af8 --- /dev/null +++ b/cachelib/cmake/FindSparsemap.cmake @@ -0,0 +1,19 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +find_path(SPARSEMAP_INCLUDE_DIRS NAMES tsl/sparse_map.h + HINTS ${CMAKE_PREFIX_PATH} + PATH_SUFFIXES include +) +include_directories(${SPARSEMAP_INCLUDE_DIRS}) diff --git a/cachelib/datatype/CMakeLists.txt b/cachelib/datatype/CMakeLists.txt index e24ac78354..9f22025fc4 100644 --- a/cachelib/datatype/CMakeLists.txt +++ b/cachelib/datatype/CMakeLists.txt @@ -20,6 +20,7 @@ add_library (cachelib_datatype add_dependencies(cachelib_datatype thrift_generated_files) target_link_libraries(cachelib_datatype PUBLIC cachelib_common + GTest::gtest ) install(TARGETS cachelib_datatype diff --git a/cachelib/shm/CMakeLists.txt b/cachelib/shm/CMakeLists.txt index cbc437dcb2..41f38d3fc6 100644 --- a/cachelib/shm/CMakeLists.txt +++ b/cachelib/shm/CMakeLists.txt @@ -24,7 +24,7 @@ add_library (cachelib_shm add_dependencies(cachelib_shm thrift_generated_files) target_link_libraries(cachelib_shm PUBLIC cachelib_common - numa + NUMA::NUMA ) install(TARGETS cachelib_shm