From 88720bff603d75be2ce7fc293b85156004dec2ae Mon Sep 17 00:00:00 2001 From: Michel Alexandre Salim Date: Wed, 29 Dec 2021 10:41:11 -0800 Subject: [PATCH 01/32] Initial Fedora package Signed-off-by: Michel Alexandre Salim --- .gitignore | 1 + cachelib-install_cachebench_so.patch | 19 ++++ cachelib-ld_gtest.patch | 33 +++++++ cachelib-versioned_so.patch | 45 ++++++++++ cachelib.spec | 129 +++++++++++++++++++++++++++ sources | 1 + 6 files changed, 228 insertions(+) create mode 100644 .gitignore create mode 100644 cachelib-install_cachebench_so.patch create mode 100644 cachelib-ld_gtest.patch create mode 100644 cachelib-versioned_so.patch create mode 100644 cachelib.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9b29ecb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/CacheLib-e3703aade03d359d290936b334ab81ca4a856b41.tar.gz diff --git a/cachelib-install_cachebench_so.patch b/cachelib-install_cachebench_so.patch new file mode 100644 index 0000000..a7e4c5a --- /dev/null +++ b/cachelib-install_cachebench_so.patch @@ -0,0 +1,19 @@ +diff -ruN CacheLib-e3703aade03d359d290936b334ab81ca4a856b41/cachelib/cachebench/CMakeLists.txt CacheLib-install_cachebench_so/cachelib/cachebench/CMakeLists.txt +--- CacheLib-e3703aade03d359d290936b334ab81ca4a856b41/cachelib/cachebench/CMakeLists.txt 2021-11-29 13:01:49.000000000 -0800 ++++ CacheLib-install_cachebench_so/cachelib/cachebench/CMakeLists.txt 2021-12-22 11:23:22.159017377 -0800 +@@ -49,6 +49,15 @@ + ) + + ++if (BUILD_SHARED_LIBS) ++ install( ++ TARGETS cachelib_cachebench ++ EXPORT cachelib-exports ++ DESTINATION ${LIB_INSTALL_DIR} ++ ) ++endif () ++ ++ + if (BUILD_TESTS) + add_library (cachebench_test_support INTERFACE ) + target_link_libraries (cachebench_test_support INTERFACE diff --git a/cachelib-ld_gtest.patch b/cachelib-ld_gtest.patch new file mode 100644 index 0000000..0e42dc9 --- /dev/null +++ b/cachelib-ld_gtest.patch @@ -0,0 +1,33 @@ +diff -ruN CacheLib-e3703aade03d359d290936b334ab81ca4a856b41/cachelib/common/CMakeLists.txt CacheLib-ld_gtest/cachelib/common/CMakeLists.txt +--- CacheLib-e3703aade03d359d290936b334ab81ca4a856b41/cachelib/common/CMakeLists.txt 2021-11-29 13:01:49.000000000 -0800 ++++ CacheLib-ld_gtest/cachelib/common/CMakeLists.txt 2021-12-22 10:21:59.259653149 -0800 +@@ -21,15 +21,11 @@ + CountDownLatch.cpp + ${BLOOM_THRIFT_FILES} + hothash/HotHashDetector.cpp +- hothash/HotHashDetectorTest.cpp + PercentileStats.cpp + PeriodicWorker.cpp + piecewise/GenericPieces.cpp +- piecewise/GenericPiecesTest.cpp + piecewise/RequestRange.cpp +- piecewise/RequestRangeTest.cpp + Serialization.cpp +- TestUtils.cpp + Utils.cpp + ) + add_dependencies(cachelib_common thrift_generated_files) +@@ -51,7 +47,12 @@ + + + if (BUILD_TESTS) +- add_library (common_test_support INTERFACE) ++ add_library (common_test_support INTERFACE ++ TestUtils.cpp ++ hothash/HotHashDetectorTest.cpp ++ piecewise/GenericPiecesTest.cpp ++ piecewise/RequestRangeTest.cpp ++ ) + target_link_libraries (common_test_support INTERFACE + cachelib_common + gflags diff --git a/cachelib-versioned_so.patch b/cachelib-versioned_so.patch new file mode 100644 index 0000000..496ea32 --- /dev/null +++ b/cachelib-versioned_so.patch @@ -0,0 +1,45 @@ +diff -ruN CacheLib-e3703aade03d359d290936b334ab81ca4a856b41/cachelib/CMakeLists.txt CacheLib-versioned_so/cachelib/CMakeLists.txt +--- CacheLib-e3703aade03d359d290936b334ab81ca4a856b41/cachelib/CMakeLists.txt 2021-11-29 13:01:49.000000000 -0800 ++++ CacheLib-versioned_so/cachelib/CMakeLists.txt 2021-12-22 14:22:35.444840967 -0800 +@@ -24,14 +24,18 @@ + + #configure_file(cachelib/cachelib_config.h.in cachelib_config.h) + +-set(CACHELIB_MAJOR_VERSION 0) ++if (NOT DEFINED CACHELIB_MAJOR_VERSION) ++ set(CACHELIB_MAJOR_VERSION 0) ++endif () + set(CACHELIB_MINOR_VERSION 1) + set(CACHELIB_PATCH_VERSION 0) + set(CACHELIB_VERSION + ${CACHELIB_MAJOR_VERSION}.${CACHELIB_MINOR_VERSION}.${CACHELIB_PATCH_VERSION}) + + set(PACKAGE_NAME "cachelib") +-set(PACKAGE_VERSION "${CACHELIB_VERSION}") ++if (NOT DEFINED PACKAGE_VERSION) ++ set(PACKAGE_VERSION "${CACHELIB_VERSION}") ++endif () + set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") + set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") + set(PACKAGE_BUGREPORT "https://github.com/facebook/TBD") +@@ -361,6 +365,20 @@ + #NAMESPACE cachelib:: + DESTINATION ${CMAKE_INSTALL_DIR}) + ++if (BUILD_SHARED_LIBS) ++ set_target_properties( ++ cachelib_allocator ++ cachelib_cachebench ++ cachelib_common ++ cachelib_datatype ++ cachelib_navy ++ cachelib_shm ++ PROPERTIES ++ SOVERSION ${CACHELIB_MAJOR_VERSION} ++ VERSION ${PACKAGE_VERSION} ++ ) ++endif () ++ + if (BUILD_TESTS) + get_property(TEST_BINARIES GLOBAL PROPERTY TEST_BINARIES) + #message(STATUS "=== Test binaries : ${TEST_BINARIES} ===") diff --git a/cachelib.spec b/cachelib.spec new file mode 100644 index 0000000..860b9b3 --- /dev/null +++ b/cachelib.spec @@ -0,0 +1,129 @@ +# Tests currently fail with +# /builddir/build/BUILD/CacheLib-e3703aade03d359d290936b334ab81ca4a856b41/cachelib/compact_cache/tests/CCacheTests.cpp:159:1: required from here +# /builddir/build/BUILD/CacheLib-e3703aade03d359d290936b334ab81ca4a856b41/cachelib/../cachelib/compact_cache/CCacheFixedLruBucket.h:277:11: internal compiler error: Floating point exception +# 277 | memcpy(destPtr, srcPtr, sizeof(T)); +# | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ +%bcond_with tests + +%global forgeurl https://github.com/facebook/CacheLib +%global commit e3703aade03d359d290936b334ab81ca4a856b41 +%global date 20211129 +%forgemeta + +# see cachelib/allocator/CacheVersion.h's kCachelibVersion +%global major_ver 16 + + +Name: cachelib +Version: %{major_ver} +Release: %autorelease +Summary: Pluggable caching engine for scale high performance cache services + +License: ASL 2.0 +URL: %forgeurl +Source0: %forgesource +# move TestUtils from cachelib_common to common_test_support to avoid ld issues +Patch0: %{name}-ld_gtest.patch +# need to install cachelib_cachebench when building shared libs +Patch1: %{name}-install_cachebench_so.patch +# and version them +Patch2: %{name}-versioned_so.patch + +# Folly is known not to work on big-endian CPUs +# https://bugzilla.redhat.com/show_bug.cgi?id=1892151 +ExcludeArch: s390x +# does not compile cleanly on 32-bit arches +# TODO: file excludearch blocker +%if 0%{?el8} +ExcludeArch: %{arm} +%else +ExcludeArch: %{arm32} +%endif +ExcludeArch: %{ix86} + +BuildRequires: cmake +BuildRequires: gcc-c++ +BuildRequires: fbthrift-devel +BuildRequires: fizz-devel +BuildRequires: folly-devel +%if %{with tests} +BuildRequires: gmock-devel +%endif +# this is actually needed, because of +# cachelib/navy/admission_policy/DynamicRandomAP.h +BuildRequires: gtest-devel +BuildRequires: libdwarf-devel +BuildRequires: libzstd-devel +BuildRequires: wangle-devel +BuildRequires: zlib-devel +BuildRequires: tsl-sparse-map-devel +# BuildRequires: libatomic + + +%global _description %{expand: +CacheLib is a C++ library providing in-process high performance caching +mechanism. CacheLib provides a thread safe API to build high throughput, low +overhead caching services, with built-in ability to leverage DRAM and SSD +caching transparently.} + +%description %{_description} + +%package devel +Summary: %{summary} +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: cmake + +%description devel %{_description} + +The %{name}-devel package contains libraries and header files for developing +applications that use %{name}. + + +%prep +%forgeautosetup -p1 + + +%build +pushd %{name} +%cmake \ +%if %{with tests} + -DBUILD_TESTS:BOOL=ON \ +%else + -DBUILD_TESTS:BOOL=OFF \ +%endif + -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=FALSE \ + -DCMAKE_INSTALL_DIR:PATH=%{_libdir}/cmake/%{name} \ + -DCONFIGS_INSTALL_DIR:STRING=%{_datadir}/%{name}/test_configs \ + -DINCLUDE_INSTALL_DIR:PATH=%{_includedir}/%{name} \ + -DCACHELIB_MAJOR_VERSION:STRING=%{major_ver} \ + -DPACKAGE_VERSION:STRING=%{major_ver}.%{date} +%cmake_build + + +%install +pushd %{name} +%cmake_install + + +%if %{with tests} +%check +pushd %{name} +%ctest +%endif + + +%files +%license LICENSE +%doc BENCHMARKS.md CHANGELOG.md README.md examples +%{_bindir}/cachebench +%{_datadir}/%{name} +%{_libdir}/*.so.* + +%files devel +%{_includedir}/%{name} +%{_libdir}/*.so +%{_libdir}/cmake/%{name} + + +%changelog +%autochangelog diff --git a/sources b/sources new file mode 100644 index 0000000..1540f2e --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (CacheLib-e3703aade03d359d290936b334ab81ca4a856b41.tar.gz) = 39b37b941cb5fafef2ed8748ccb1e19e69bb8509ab9d59212b0b42f26a66a622f5f22955d4dc2d49e18bdf6060a19c4101466cf7dfb1a8afd68e3fa1bc2f65bf From 24028fcd60461a87b040f9e0102ad3dc44e528cc Mon Sep 17 00:00:00 2001 From: Michel Alexandre Salim Date: Wed, 29 Dec 2021 11:40:00 -0800 Subject: [PATCH 02/32] Update to snapshot from 2021.12.20 Also list bugs for architecture build failures. Signed-off-by: Michel Alexandre Salim --- .gitignore | 2 +- cachelib.spec | 14 ++++++++++---- sources | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 9b29ecb..c7443b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -/CacheLib-e3703aade03d359d290936b334ab81ca4a856b41.tar.gz +/CacheLib-c4904ef2524f396eb432392f8308a69dda926bd8.tar.gz diff --git a/cachelib.spec b/cachelib.spec index 860b9b3..449dfcb 100644 --- a/cachelib.spec +++ b/cachelib.spec @@ -6,8 +6,9 @@ %bcond_with tests %global forgeurl https://github.com/facebook/CacheLib -%global commit e3703aade03d359d290936b334ab81ca4a856b41 -%global date 20211129 +%global commit c4904ef2524f396eb432392f8308a69dda926bd8 +%global shortcommit %(c=%{commit}; echo ${c:0:7}) +%global date 20211220 %forgemeta # see cachelib/allocator/CacheVersion.h's kCachelibVersion @@ -16,7 +17,9 @@ Name: cachelib Version: %{major_ver} -Release: %autorelease +# using -s seems to add the snapinfo twice in the generated filename +# https://pagure.io/fedora-infra/rpmautospec/issue/240 +Release: %autorelease -e %{date}git%{shortcommit} Summary: Pluggable caching engine for scale high performance cache services License: ASL 2.0 @@ -33,13 +36,16 @@ Patch2: %{name}-versioned_so.patch # https://bugzilla.redhat.com/show_bug.cgi?id=1892151 ExcludeArch: s390x # does not compile cleanly on 32-bit arches -# TODO: file excludearch blocker +# https://bugzilla.redhat.com/show_bug.cgi?id=2036124 %if 0%{?el8} ExcludeArch: %{arm} %else ExcludeArch: %{arm32} %endif ExcludeArch: %{ix86} +# build failure on aarch64 +# https://bugzilla.redhat.com/show_bug.cgi?id=2036121 +ExcludeArch: %{arm64} BuildRequires: cmake BuildRequires: gcc-c++ diff --git a/sources b/sources index 1540f2e..6428f23 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (CacheLib-e3703aade03d359d290936b334ab81ca4a856b41.tar.gz) = 39b37b941cb5fafef2ed8748ccb1e19e69bb8509ab9d59212b0b42f26a66a622f5f22955d4dc2d49e18bdf6060a19c4101466cf7dfb1a8afd68e3fa1bc2f65bf +SHA512 (CacheLib-c4904ef2524f396eb432392f8308a69dda926bd8.tar.gz) = 6ce0a8783bd88d1b4673832cad5305971fe92dadb4f8a1423eaf5828e97c3b0f0100a70bdf97e476d66e3824d8e3841e7d971979aa8c57b8fa2b357870dd96cc From 63963821d9e9afe8d39fe7eea2bfcd33bc0175d4 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 19 Jan 2022 22:47:24 +0000 Subject: [PATCH 03/32] - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild Signed-off-by: Fedora Release Engineering From c746c7083be849a351073a024af30a488d6e076f Mon Sep 17 00:00:00 2001 From: Michel Alexandre Salim Date: Thu, 24 Feb 2022 19:33:14 -0800 Subject: [PATCH 04/32] Fix for finding gtest on EL8; exclude aarch64 instead of %%arm64 Signed-off-by: Michel Alexandre Salim --- cachelib-find-gtest.patch | 70 +++++++++++++++++++++++++++++++++++++++ cachelib.spec | 12 +++++-- 2 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 cachelib-find-gtest.patch diff --git a/cachelib-find-gtest.patch b/cachelib-find-gtest.patch new file mode 100644 index 0000000..b9cce71 --- /dev/null +++ b/cachelib-find-gtest.patch @@ -0,0 +1,70 @@ +diff '--color=auto' -ruN CacheLib-c4904ef2524f396eb432392f8308a69dda926bd8/cachelib/cmake/FindGTest.cmake CacheLib-c4904ef2524f396eb432392f8308a69dda926bd8-find-gtest/cachelib/cmake/FindGTest.cmake +--- CacheLib-c4904ef2524f396eb432392f8308a69dda926bd8/cachelib/cmake/FindGTest.cmake 1969-12-31 16:00:00.000000000 -0800 ++++ CacheLib-c4904ef2524f396eb432392f8308a69dda926bd8-find-gtest/cachelib/cmake/FindGTest.cmake 2022-02-24 20:08:51.087790319 -0800 +@@ -0,0 +1,54 @@ ++# Copyright (c) Facebook, Inc. and its 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 GTest ++# ++# This will define: ++# GTEST_FOUND ++# GTEST_INCLUDE_DIRS ++# GTEST_LIBRARIES ++# GTEST_MAIN_LIBRARIES ++# GTEST_BOTH_LIBRARIES ++ ++find_path(GTEST_INCLUDE_DIRS gtest/gtest.h ++ HINTS ++ $ENV{GTEST_ROOT}/include ++ ${GTEST_ROOT}/include ++) ++ ++find_library(GTEST_LIBRARIES ++ NAMES gtest ++ HINTS ++ $ENV{GTEST_ROOT} ++ ${GTEST_ROOT} ++) ++ ++find_library(GTEST_MAIN_LIBRARIES ++ NAMES gtest_main ++ HINTS ++ $ENV{GTEST_ROOT} ++ ${GTEST_ROOT} ++) ++ ++set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}) ++ ++mark_as_advanced(GTEST_INCLUDE_DIRS GTEST_LIBRARIES GTEST_MAIN_LIBRARIES) ++ ++include(FindPackageHandleStandardArgs) ++find_package_handle_standard_args( ++ GTest GTEST_LIBRARIES GTEST_INCLUDE_DIRS GTEST_MAIN_LIBRARIES) ++ ++if(GTEST_FOUND AND NOT GTEST_FIND_QUIETLY) ++ message(STATUS "GTEST: ${GTEST_INCLUDE_DIRS}") ++endif() +diff '--color=auto' -ruN CacheLib-c4904ef2524f396eb432392f8308a69dda926bd8/cachelib/CMakeLists.txt CacheLib-c4904ef2524f396eb432392f8308a69dda926bd8-find-gtest/cachelib/CMakeLists.txt +--- CacheLib-c4904ef2524f396eb432392f8308a69dda926bd8/cachelib/CMakeLists.txt 2021-12-20 07:22:18.000000000 -0800 ++++ CacheLib-c4904ef2524f396eb432392f8308a69dda926bd8-find-gtest/cachelib/CMakeLists.txt 2022-02-24 20:12:39.078602510 -0800 +@@ -93,7 +93,7 @@ + system filesystem regex context program_options thread) + find_package(Gflags REQUIRED) + find_package(Glog REQUIRED) +-find_package(GTest CONFIG REQUIRED) ++find_package(GTest REQUIRED) + find_package(folly CONFIG REQUIRED) + find_package(fizz CONFIG REQUIRED) + find_package(fmt CONFIG REQUIRED) diff --git a/cachelib.spec b/cachelib.spec index 449dfcb..fd2cd66 100644 --- a/cachelib.spec +++ b/cachelib.spec @@ -31,6 +31,8 @@ Patch0: %{name}-ld_gtest.patch Patch1: %{name}-install_cachebench_so.patch # and version them Patch2: %{name}-versioned_so.patch +# needed on EL8; its gtest does not come with cmake files +Patch3: %{name}-find-gtest.patch # Folly is known not to work on big-endian CPUs # https://bugzilla.redhat.com/show_bug.cgi?id=1892151 @@ -45,7 +47,7 @@ ExcludeArch: %{arm32} ExcludeArch: %{ix86} # build failure on aarch64 # https://bugzilla.redhat.com/show_bug.cgi?id=2036121 -ExcludeArch: %{arm64} +ExcludeArch: aarch64 BuildRequires: cmake BuildRequires: gcc-c++ @@ -86,7 +88,13 @@ applications that use %{name}. %prep -%forgeautosetup -p1 +%forgesetup +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%if 0%{?el8} +%patch3 -p1 +%endif %build From 6a43db44e46038c5d76856f6e0eae551241f0b7f Mon Sep 17 00:00:00 2001 From: Michel Alexandre Salim Date: Mon, 28 Feb 2022 11:01:49 -0800 Subject: [PATCH 05/32] Update to snapshot from 20220228; use new-style versioning Signed-off-by: Michel Alexandre Salim --- .gitignore | 2 +- cachelib.spec | 28 ++++++++++++---------------- sources | 2 +- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index c7443b2..ad2fa97 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -/CacheLib-c4904ef2524f396eb432392f8308a69dda926bd8.tar.gz +/CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85.tar.gz diff --git a/cachelib.spec b/cachelib.spec index fd2cd66..d404dbe 100644 --- a/cachelib.spec +++ b/cachelib.spec @@ -6,9 +6,12 @@ %bcond_with tests %global forgeurl https://github.com/facebook/CacheLib -%global commit c4904ef2524f396eb432392f8308a69dda926bd8 +%global commit 03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85 %global shortcommit %(c=%{commit}; echo ${c:0:7}) -%global date 20211220 +%global date 20220228 +# disable forge macro snapinfo generation +# https://pagure.io/fedora-infra/rpmautospec/issue/240 +%global distprefix %{nil} %forgemeta # see cachelib/allocator/CacheVersion.h's kCachelibVersion @@ -16,23 +19,18 @@ Name: cachelib -Version: %{major_ver} -# using -s seems to add the snapinfo twice in the generated filename -# https://pagure.io/fedora-infra/rpmautospec/issue/240 -Release: %autorelease -e %{date}git%{shortcommit} +Version: %{major_ver}^%{date}git%{shortcommit} +Release: %autorelease Summary: Pluggable caching engine for scale high performance cache services License: ASL 2.0 URL: %forgeurl Source0: %forgesource -# move TestUtils from cachelib_common to common_test_support to avoid ld issues -Patch0: %{name}-ld_gtest.patch -# need to install cachelib_cachebench when building shared libs -Patch1: %{name}-install_cachebench_so.patch -# and version them -Patch2: %{name}-versioned_so.patch +# cachelib builds broken by recent thrift codemod +Patch0: %{name}-undo-thrift-codemod.patch # needed on EL8; its gtest does not come with cmake files -Patch3: %{name}-find-gtest.patch +Patch1: %{name}-find-gtest.patch + # Folly is known not to work on big-endian CPUs # https://bugzilla.redhat.com/show_bug.cgi?id=1892151 @@ -90,10 +88,8 @@ applications that use %{name}. %prep %forgesetup %patch0 -p1 -%patch1 -p1 -%patch2 -p1 %if 0%{?el8} -%patch3 -p1 +%patch1 -p1 %endif diff --git a/sources b/sources index 6428f23..838f6d4 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (CacheLib-c4904ef2524f396eb432392f8308a69dda926bd8.tar.gz) = 6ce0a8783bd88d1b4673832cad5305971fe92dadb4f8a1423eaf5828e97c3b0f0100a70bdf97e476d66e3824d8e3841e7d971979aa8c57b8fa2b357870dd96cc +SHA512 (CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85.tar.gz) = 5450820657ef531d6bf375d44d9bfa31c6d27dc42bb92faf594cebc2fe63f9130dfa2a02a7e7a3e5e34544a3446bdf2f6675c825439ed13ed91f04bf5c368e04 From 4913bb557a7d07dae467a6d62626f0de9939aa2b Mon Sep 17 00:00:00 2001 From: Michel Alexandre Salim Date: Mon, 28 Feb 2022 12:08:06 -0800 Subject: [PATCH 06/32] Add new patch and retire old merged patches Signed-off-by: Michel Alexandre Salim --- cachelib-install_cachebench_so.patch | 19 -- cachelib-ld_gtest.patch | 33 --- cachelib-undo-thrift-codemod.patch | 412 +++++++++++++++++++++++++++ cachelib-versioned_so.patch | 45 --- 4 files changed, 412 insertions(+), 97 deletions(-) delete mode 100644 cachelib-install_cachebench_so.patch delete mode 100644 cachelib-ld_gtest.patch create mode 100644 cachelib-undo-thrift-codemod.patch delete mode 100644 cachelib-versioned_so.patch diff --git a/cachelib-install_cachebench_so.patch b/cachelib-install_cachebench_so.patch deleted file mode 100644 index a7e4c5a..0000000 --- a/cachelib-install_cachebench_so.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff -ruN CacheLib-e3703aade03d359d290936b334ab81ca4a856b41/cachelib/cachebench/CMakeLists.txt CacheLib-install_cachebench_so/cachelib/cachebench/CMakeLists.txt ---- CacheLib-e3703aade03d359d290936b334ab81ca4a856b41/cachelib/cachebench/CMakeLists.txt 2021-11-29 13:01:49.000000000 -0800 -+++ CacheLib-install_cachebench_so/cachelib/cachebench/CMakeLists.txt 2021-12-22 11:23:22.159017377 -0800 -@@ -49,6 +49,15 @@ - ) - - -+if (BUILD_SHARED_LIBS) -+ install( -+ TARGETS cachelib_cachebench -+ EXPORT cachelib-exports -+ DESTINATION ${LIB_INSTALL_DIR} -+ ) -+endif () -+ -+ - if (BUILD_TESTS) - add_library (cachebench_test_support INTERFACE ) - target_link_libraries (cachebench_test_support INTERFACE diff --git a/cachelib-ld_gtest.patch b/cachelib-ld_gtest.patch deleted file mode 100644 index 0e42dc9..0000000 --- a/cachelib-ld_gtest.patch +++ /dev/null @@ -1,33 +0,0 @@ -diff -ruN CacheLib-e3703aade03d359d290936b334ab81ca4a856b41/cachelib/common/CMakeLists.txt CacheLib-ld_gtest/cachelib/common/CMakeLists.txt ---- CacheLib-e3703aade03d359d290936b334ab81ca4a856b41/cachelib/common/CMakeLists.txt 2021-11-29 13:01:49.000000000 -0800 -+++ CacheLib-ld_gtest/cachelib/common/CMakeLists.txt 2021-12-22 10:21:59.259653149 -0800 -@@ -21,15 +21,11 @@ - CountDownLatch.cpp - ${BLOOM_THRIFT_FILES} - hothash/HotHashDetector.cpp -- hothash/HotHashDetectorTest.cpp - PercentileStats.cpp - PeriodicWorker.cpp - piecewise/GenericPieces.cpp -- piecewise/GenericPiecesTest.cpp - piecewise/RequestRange.cpp -- piecewise/RequestRangeTest.cpp - Serialization.cpp -- TestUtils.cpp - Utils.cpp - ) - add_dependencies(cachelib_common thrift_generated_files) -@@ -51,7 +47,12 @@ - - - if (BUILD_TESTS) -- add_library (common_test_support INTERFACE) -+ add_library (common_test_support INTERFACE -+ TestUtils.cpp -+ hothash/HotHashDetectorTest.cpp -+ piecewise/GenericPiecesTest.cpp -+ piecewise/RequestRangeTest.cpp -+ ) - target_link_libraries (common_test_support INTERFACE - cachelib_common - gflags diff --git a/cachelib-undo-thrift-codemod.patch b/cachelib-undo-thrift-codemod.patch new file mode 100644 index 0000000..f636a24 --- /dev/null +++ b/cachelib-undo-thrift-codemod.patch @@ -0,0 +1,412 @@ +diff '--color=auto' -ruN CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85/cachelib/allocator/CacheAllocator-inl.h CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85-undo-thrift-codemod/cachelib/allocator/CacheAllocator-inl.h +--- CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85/cachelib/allocator/CacheAllocator-inl.h 2022-02-28 10:07:30.000000000 -0800 ++++ CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85-undo-thrift-codemod/cachelib/allocator/CacheAllocator-inl.h 2022-02-28 10:59:44.769907918 -0800 +@@ -3163,22 +3163,22 @@ + // TODO: + // Once everyone is on v8 or later, remove the outter if. + if (kCachelibVersion > 8) { +- if (*meta.ramFormatVersion() != kCacheRamFormatVersion) { ++ if (*meta.ramFormatVersion_ref() != kCacheRamFormatVersion) { + throw std::runtime_error( + folly::sformat("Expected cache ram format version {}. But found {}.", +- kCacheRamFormatVersion, *meta.ramFormatVersion())); ++ kCacheRamFormatVersion, *meta.ramFormatVersion_ref())); + } + } + +- if (*meta.accessType() != AccessType::kId) { ++ if (*meta.accessType_ref() != AccessType::kId) { + throw std::invalid_argument( +- folly::sformat("Expected {}, got {} for AccessType", *meta.accessType(), +- AccessType::kId)); ++ folly::sformat("Expected {}, got {} for AccessType", ++ *meta.accessType_ref(), AccessType::kId)); + } + +- if (*meta.mmType() != MMType::kId) { +- throw std::invalid_argument(folly::sformat("Expected {}, got {} for MMType", +- *meta.mmType(), MMType::kId)); ++ if (*meta.mmType_ref() != MMType::kId) { ++ throw std::invalid_argument(folly::sformat( ++ "Expected {}, got {} for MMType", *meta.mmType_ref(), MMType::kId)); + } + return meta; + } +diff '--color=auto' -ruN CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85/cachelib/allocator/ChainedHashTable-inl.h CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85-undo-thrift-codemod/cachelib/allocator/ChainedHashTable-inl.h +--- CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85/cachelib/allocator/ChainedHashTable-inl.h 2022-02-28 10:07:30.000000000 -0800 ++++ CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85-undo-thrift-codemod/cachelib/allocator/ChainedHashTable-inl.h 2022-02-28 10:59:44.777907960 -0800 +@@ -241,12 +241,12 @@ + ht_{config_.getNumBuckets(), memStart, compressor, config_.getHasher(), + false /* resetMem */}, + locks_{config_.getLocksPower(), config_.getHasher()}, +- numKeys_(*object.numKeys()) { ++ numKeys_(*object.numKeys_ref()) { + if (config_.getBucketsPower() != +- static_cast(*object.bucketsPower())) { ++ static_cast(*object.bucketsPower_ref())) { + throw std::invalid_argument(folly::sformat( + "Hashtable bucket power not compatible. old = {}, new = {}", +- *object.bucketsPower(), ++ *object.bucketsPower_ref(), + config.getBucketsPower())); + } + +@@ -260,11 +260,11 @@ + // checking hasher magic id not equal to 0 is to ensure it'll be + // a warm roll going from a cachelib without hasher magic id to + // one with a magic id +- if (*object.hasherMagicId() != 0 && +- *object.hasherMagicId() != config_.getHasher()->getMagicId()) { ++ if (*object.hasherMagicId_ref() != 0 && ++ *object.hasherMagicId_ref() != config_.getHasher()->getMagicId()) { + throw std::invalid_argument(folly::sformat( + "Hash object's ID mismatch. expected = {}, actual = {}", +- *object.hasherMagicId(), config_.getHasher()->getMagicId())); ++ *object.hasherMagicId_ref(), config_.getHasher()->getMagicId())); + } + } + +@@ -476,10 +476,10 @@ + } + + serialization::ChainedHashTableObject object; +- *object.bucketsPower() = config_.getBucketsPower(); +- *object.locksPower() = config_.getLocksPower(); +- *object.numKeys() = numKeys_; +- *object.hasherMagicId() = config_.getHasher()->getMagicId(); ++ *object.bucketsPower_ref() = config_.getBucketsPower(); ++ *object.locksPower_ref() = config_.getLocksPower(); ++ *object.numKeys_ref() = numKeys_; ++ *object.hasherMagicId_ref() = config_.getHasher()->getMagicId(); + return object; + } + +diff '--color=auto' -ruN CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85/cachelib/allocator/datastruct/DList.h CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85-undo-thrift-codemod/cachelib/allocator/datastruct/DList.h +--- CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85/cachelib/allocator/datastruct/DList.h 2022-02-28 10:07:30.000000000 -0800 ++++ CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85-undo-thrift-codemod/cachelib/allocator/datastruct/DList.h 2022-02-28 10:59:44.777907960 -0800 +@@ -94,18 +94,20 @@ + // @param compressor PtrCompressor object + DList(const DListObject& object, PtrCompressor compressor) + : compressor_(std::move(compressor)), +- head_(compressor_.unCompress(CompressedPtr{*object.compressedHead()})), +- tail_(compressor_.unCompress(CompressedPtr{*object.compressedTail()})), +- size_(*object.size()) {} ++ head_(compressor_.unCompress( ++ CompressedPtr{*object.compressedHead_ref()})), ++ tail_(compressor_.unCompress( ++ CompressedPtr{*object.compressedTail_ref()})), ++ size_(*object.size_ref()) {} + + /** + * Exports the current state as a thrift object for later restoration. + */ + DListObject saveState() const { + DListObject state; +- *state.compressedHead() = compressor_.compress(head_).saveState(); +- *state.compressedTail() = compressor_.compress(tail_).saveState(); +- *state.size() = size_; ++ *state.compressedHead_ref() = compressor_.compress(head_).saveState(); ++ *state.compressedTail_ref() = compressor_.compress(tail_).saveState(); ++ *state.size_ref() = size_; + return state; + } + +diff '--color=auto' -ruN CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85/cachelib/allocator/datastruct/MultiDList.h CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85-undo-thrift-codemod/cachelib/allocator/datastruct/MultiDList.h +--- CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85/cachelib/allocator/datastruct/MultiDList.h 2022-02-28 10:07:30.000000000 -0800 ++++ CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85-undo-thrift-codemod/cachelib/allocator/datastruct/MultiDList.h 2022-02-28 10:59:44.777907960 -0800 +@@ -58,7 +58,7 @@ + // @param object saved MultiDList object + // @param compressor PtrCompressor object + MultiDList(const MultiDListObject& object, PtrCompressor compressor) { +- for (const auto& list : *object.lists()) { ++ for (const auto& list : *object.lists_ref()) { + lists_.emplace_back(std::make_unique(list, compressor)); + } + } +@@ -69,7 +69,7 @@ + MultiDListObject saveState() const { + MultiDListObject state; + for (const auto& listPtr : lists_) { +- state.lists()->emplace_back(listPtr->saveState()); ++ state.lists_ref()->emplace_back(listPtr->saveState()); + } + return state; + } +diff '--color=auto' -ruN CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85/cachelib/allocator/datastruct/SList.h CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85-undo-thrift-codemod/cachelib/allocator/datastruct/SList.h +--- CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85/cachelib/allocator/datastruct/SList.h 2022-02-28 10:07:30.000000000 -0800 ++++ CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85-undo-thrift-codemod/cachelib/allocator/datastruct/SList.h 2022-02-28 10:59:44.777907960 -0800 +@@ -85,12 +85,14 @@ + + explicit SList(const SListObject& object, PtrCompressor compressor) + : compressor_(std::move(compressor)), +- size_(*object.size()), +- head_(compressor_.unCompress(CompressedPtr{*object.compressedHead()})) { ++ size_(*object.size_ref()), ++ head_(compressor_.unCompress( ++ CompressedPtr{*object.compressedHead_ref()})) { + // TODO(bwatling): eventually we'll always have 'compressedTail' and we can + // remove the loop below. +- if (*object.compressedTail() >= 0) { +- tail_ = compressor_.unCompress(CompressedPtr{*object.compressedTail()}); ++ if (*object.compressedTail_ref() >= 0) { ++ tail_ = ++ compressor_.unCompress(CompressedPtr{*object.compressedTail_ref()}); + } else if (head_) { + tail_ = head_; + while (T* next = getNext(*tail_)) { +@@ -106,9 +108,9 @@ + */ + SListObject saveState() const { + SListObject state; +- *state.compressedHead() = compressor_.compress(head_).saveState(); +- *state.compressedTail() = compressor_.compress(tail_).saveState(); +- *state.size() = size_; ++ *state.compressedHead_ref() = compressor_.compress(head_).saveState(); ++ *state.compressedTail_ref() = compressor_.compress(tail_).saveState(); ++ *state.size_ref() = size_; + return state; + } + +diff '--color=auto' -ruN CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85/cachelib/allocator/MM2Q.h CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85-undo-thrift-codemod/cachelib/allocator/MM2Q.h +--- CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85/cachelib/allocator/MM2Q.h 2022-02-28 10:07:30.000000000 -0800 ++++ CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85-undo-thrift-codemod/cachelib/allocator/MM2Q.h 2022-02-28 10:59:44.777907960 -0800 +@@ -71,14 +71,14 @@ + struct Config { + // Create from serialized config + explicit Config(SerializationConfigType configState) +- : Config(*configState.lruRefreshTime(), +- *configState.lruRefreshRatio(), +- *configState.updateOnWrite(), +- *configState.updateOnRead(), +- *configState.tryLockUpdate(), +- *configState.rebalanceOnRecordAccess(), +- *configState.hotSizePercent(), +- *configState.coldSizePercent()) {} ++ : Config(*configState.lruRefreshTime_ref(), ++ *configState.lruRefreshRatio_ref(), ++ *configState.updateOnWrite_ref(), ++ *configState.updateOnRead_ref(), ++ *configState.tryLockUpdate_ref(), ++ *configState.rebalanceOnRecordAccess_ref(), ++ *configState.hotSizePercent_ref(), ++ *configState.coldSizePercent_ref()) {} + + // @param time the refresh time in seconds to trigger an update in + // position upon access. An item will be promoted only once in each lru +diff '--color=auto' -ruN CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85/cachelib/allocator/MM2Q-inl.h CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85-undo-thrift-codemod/cachelib/allocator/MM2Q-inl.h +--- CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85/cachelib/allocator/MM2Q-inl.h 2022-02-28 10:07:30.000000000 -0800 ++++ CacheLib-03dcb9bbddb977b5ec6e9ba6c5b1a53cac521f85-undo-thrift-codemod/cachelib/allocator/MM2Q-inl.h 2022-02-28 10:59:44.777907960 -0800 +@@ -21,9 +21,9 @@ + template T::*HookPtr> + MM2Q::Container::Container(const serialization::MM2QObject& object, + PtrCompressor compressor) +- : lru_(*object.lrus(), compressor), +- tailTrackingEnabled_(*object.tailTrackingEnabled()), +- config_(*object.config()) { ++ : lru_(*object.lrus_ref(), compressor), ++ tailTrackingEnabled_(*object.tailTrackingEnabled_ref()), ++ config_(*object.config_ref()) { + lruRefreshTime_ = config_.lruRefreshTime; + nextReconfigureTime_ = config_.mmReconfigureIntervalSecs.count() == 0 + ? std::numeric_limits