diff --git a/packages/feedsim/install_feedsim.sh b/packages/feedsim/install_feedsim.sh index cbbb0560..b1b6641e 100755 --- a/packages/feedsim/install_feedsim.sh +++ b/packages/feedsim/install_feedsim.sh @@ -1,11 +1,10 @@ #!/bin/bash -# Copyright (c) Meta Platforms, Inc. and affiliates. +# Copyright (c) Meta Platforms, Inc. and affiliates and Contributors # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. set -Eeuo pipefail -# trap cleanup SIGINT SIGTERM ERR EXIT # Constants FEEDSIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) @@ -16,10 +15,6 @@ echo "BENCHPRESS_ROOT is ${BENCHPRESS_ROOT}" source "${BENCHPRESS_ROOT}/packages/common/os-distro.sh" -cleanup() { - trap - SIGINT SIGTERM ERR EXIT -} - msg() { echo >&2 -e "${1-}" } @@ -31,24 +26,39 @@ die() { exit "$code" } +verify_checksum() { + local file="$1" + local expected_checksum="$2" + + if ! [ -f "$file" ]; then + echo "WARNING: File not found: $file" + exit 1 + fi + + local actual_checksum + actual_checksum=$(sha256sum "$file" | awk '{print $1}') + + if [[ "$actual_checksum" != "$expected_checksum" ]]; then + echo "WARNING: Checksum mismatch for file: $file" + exit 1 + fi +} + ARCH="$(uname -p)" -if [ "$ARCH" = "aarch64" ]; then - if distro_is_like ubuntu; then - "${FEEDSIM_ROOT}"/install_feedsim_ubuntu.sh - exit $? - else - "${FEEDSIM_ROOT}"/install_feedsim_aarch64.sh - exit $? - fi -fi -if distro_is_like ubuntu && [ "$(uname -p)" = "x86_64" ]; then - "${FEEDSIM_ROOT}"/install_feedsim_ubuntu.sh - exit $? -fi -dnf install -y bc ninja-build flex bison git texinfo binutils-devel \ + +if distro_is_like ubuntu; then + apt install -y bc cmake ninja-build flex bison texinfo binutils-dev \ + libunwind-dev bzip2 libbz2-dev libsodium-dev libghc-double-conversion-dev \ + libzstd-dev lz4 liblz4-dev xzip libsnappy-dev libtool libssl-dev \ + zlib1g-dev libdwarf-dev libaio-dev libatomic1 patch perl libiberty-dev \ + libfmt-dev sysstat jq xxhash libxxhash-dev +else + dnf install -y bc ninja-build flex bison git texinfo binutils-devel \ libsodium-devel libunwind-devel bzip2-devel double-conversion-devel \ libzstd-devel lz4-devel xz-devel snappy-devel libtool bzip2 openssl-devel \ zlib-devel libdwarf libdwarf-devel libaio-devel libatomic patch jq xxhash xxhash-devel +fi + # Creates feedsim directory under benchmarks/ mkdir -p "${BENCHPRESS_ROOT}/benchmarks/feedsim" @@ -62,138 +72,160 @@ chmod u+x "${FEEDSIM_ROOT_SRC}/run.sh" chmod u+x "${FEEDSIM_ROOT_SRC}/run-feedsim-multi.sh" msg "Installing third-party dependencies..." -cp -r "${BENCHPRESS_ROOT}/packages/feedsim/third_party" "${FEEDSIM_ROOT_SRC}" -mv "${FEEDSIM_THIRD_PARTY_SRC}/src" "${FEEDSIM_ROOT_SRC}/src" +mkdir -p "${FEEDSIM_THIRD_PARTY_SRC}" +if ! [ -d "${FEEDSIM_ROOT_SRC}/src" ]; then + cp -r "${BENCHPRESS_ROOT}/packages/feedsim/third_party/src" "${FEEDSIM_ROOT_SRC}/" +else + msg "[SKIPPED] copying feedsim src" +fi cd "${FEEDSIM_THIRD_PARTY_SRC}" -# Installing cmake-4.0.3 +DEP_CMAKE_VERSION="4.0.3" +# Installing cmake +if ! [ -d "cmake-${DEP_CMAKE_VERSION}-linux-${ARCH}" ]; then + wget "https://github.com/Kitware/CMake/releases/download/v${DEP_CMAKE_VERSION}/cmake-${DEP_CMAKE_VERSION}-linux-${ARCH}.tar.gz" -O "cmake-${DEP_CMAKE_VERSION}-linux-${ARCH}.tar.gz" + if [ "$ARCH" = "aarch64" ]; then + verify_checksum "cmake-${DEP_CMAKE_VERSION}-linux-${ARCH}.tar.gz" "391da1544ef50ac31300841caaf11db4de3976cdc4468643272e44b3f4644713" + else + verify_checksum "cmake-${DEP_CMAKE_VERSION}-linux-${ARCH}.tar.gz" "585ae9e013107bc8e7c7c9ce872cbdcbdff569e675b07ef57aacfb88c886faac" + fi + tar xfz "cmake-${DEP_CMAKE_VERSION}-linux-${ARCH}.tar.gz" + export PATH="${FEEDSIM_THIRD_PARTY_SRC}/cmake-${DEP_CMAKE_VERSION}-linux-${ARCH}/bin:${PATH}" +else + msg "[SKIPPED] cmake-${DEP_CMAKE_VERSION}" +fi -if ! [ -d "cmake-4.0.3" ]; then - wget "https://github.com/Kitware/CMake/releases/download/v4.0.3/cmake-4.0.3.tar.gz" - tar -zxf "cmake-4.0.3.tar.gz" - cd "cmake-4.0.3" - mkdir staging - ./bootstrap --parallel=8 --prefix="$(pwd)/staging" - make -j8 +# Installing fast_float +if ! [ -d "fast_float" ]; then + git clone https://github.com/fastfloat/fast_float.git + cd fast_float + git checkout v8.1.0 + mkdir build && cd build + cmake .. + make -j"$(nproc)" make install - cd ../ + cd ../../ else - msg "[SKIPPED] cmake-4.0.3" + msg "[SKIPPED] fast_float" fi -export PATH="${FEEDSIM_THIRD_PARTY_SRC}/cmake-4.0.3/staging/bin:${PATH}" - -git clone https://github.com/fastfloat/fast_float.git -cd fast_float -mkdir build && cd build -cmake .. -make -make install -cd ../ - +DEP_GENGOPT_VERSION="2.23" # Installing gengetopt -if ! [ -d "gengetopt-2.23" ]; then +if ! [ -d "gengetopt-${DEP_GENGOPT_VERSION}" ]; then # Source the download retry function source "${BENCHPRESS_ROOT}/scripts/download_with_retry.sh" - download_with_retry "https://mirrors.ocf.berkeley.edu/gnu/gengetopt/gengetopt-2.23.tar.xz" - tar -xf "gengetopt-2.23.tar.xz" - cd "gengetopt-2.23" + download_with_retry "https://mirrors.ocf.berkeley.edu/gnu/gengetopt/gengetopt-${DEP_GENGOPT_VERSION}.tar.xz" + verify_checksum "gengetopt-${DEP_GENGOPT_VERSION}.tar.xz" "b941aec9011864978dd7fdeb052b1943535824169d2aa2b0e7eae9ab807584ac" + tar -xf "gengetopt-${DEP_GENGOPT_VERSION}.tar.xz" + cd "gengetopt-${DEP_GENGOPT_VERSION}" ./configure make -j"$(nproc)" make install cd ../ else - msg "[SKIPPED] gengetopt-2.23" + msg "[SKIPPED] gengetopt-${DEP_GENGOPT_VERSION}" fi +DEP_BOOST_VERSION="1_88_0" # Installing Boost -if ! [ -d "boost_1_88_0" ]; then - wget "https://archives.boost.io/release/1.88.0/source/boost_1_88_0.tar.gz" - tar -xzf "boost_1_88_0.tar.gz" - cd "boost_1_88_0" +if ! [ -d "boost_${DEP_BOOST_VERSION}" ]; then + wget "https://archives.boost.io/release/$(echo $DEP_BOOST_VERSION | sed 's/_/./g')/source/boost_${DEP_BOOST_VERSION}.tar.gz" -O "boost_${DEP_BOOST_VERSION}.tar.gz" + verify_checksum "boost_${DEP_BOOST_VERSION}.tar.gz" "3621533e820dcab1e8012afd583c0c73cf0f77694952b81352bf38c1488f9cb4" + tar -xzf "boost_${DEP_BOOST_VERSION}.tar.gz" + cd "boost_${DEP_BOOST_VERSION}" ./bootstrap.sh --without-libraries=python - ./b2 install + ./b2 -j"$(nproc)" install cd ../ else - msg "[SKIPPED] boost_1_88_0" + msg "[SKIPPED] boost_${DEP_BOOST_VERSION}" fi - +DEP_GFLAGS_VERSION="2.2.2" # Installing gflags -if ! [ -d "gflags-2.2.2" ]; then - wget "https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.tar.gz" -O "gflags-2.2.2.tar.gz" - tar -xzf "gflags-2.2.2.tar.gz" - cd "gflags-2.2.2" +if ! [ -d "gflags-${DEP_GFLAGS_VERSION}" ]; then + wget "https://github.com/gflags/gflags/archive/refs/tags/v${DEP_GFLAGS_VERSION}.tar.gz" -O "gflags-${DEP_GFLAGS_VERSION}.tar.gz" + verify_checksum "gflags-${DEP_GFLAGS_VERSION}.tar.gz" "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf" + tar -xzf "gflags-${DEP_GFLAGS_VERSION}.tar.gz" + cd "gflags-${DEP_GFLAGS_VERSION}" mkdir -p build && cd build cmake -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ../ - make -j8 + make -j"$(nproc)" make install cd ../../ else - msg "[SKIPPED] gflags-2.2.2" + msg "[SKIPPED] gflags-${DEP_GFLAGS_VERSION}" fi +DEP_GFLAGS_VERSION="0.4.0" # Installing glog -if ! [ -d "glog-0.4.0" ]; then - wget "https://github.com/google/glog/archive/refs/tags/v0.4.0.tar.gz" -O "glog-0.4.0.tar.gz" - tar -xzf "glog-0.4.0.tar.gz" - cd "glog-0.4.0" +if ! [ -d "glog-${DEP_GFLAGS_VERSION}" ]; then + wget "https://github.com/google/glog/archive/refs/tags/v${DEP_GFLAGS_VERSION}.tar.gz" -O "glog-${DEP_GFLAGS_VERSION}.tar.gz" + verify_checksum "glog-${DEP_GFLAGS_VERSION}.tar.gz" "f28359aeba12f30d73d9e4711ef356dc842886968112162bc73002645139c39c" + tar -xzf "glog-${DEP_GFLAGS_VERSION}.tar.gz" + cd "glog-${DEP_GFLAGS_VERSION}" mkdir -p build && cd build cmake -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ../ - make -j8 + make -j"$(nproc)" make install cd ../../ else - msg "[SKIPPED] glog-0.4.0" + msg "[SKIPPED] glog-${DEP_GFLAGS_VERSION}" fi +DEP_JEMALLOC_VERSION="5.3.0" # Installing JEMalloc -if ! [ -d "jemalloc-5.3.0" ]; then - wget "https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2" - bunzip2 "jemalloc-5.3.0.tar.bz2" - tar -xvf "jemalloc-5.3.0.tar" - cd "jemalloc-5.3.0" +if ! [ -d "jemalloc-${DEP_JEMALLOC_VERSION}" ]; then + wget "https://github.com/jemalloc/jemalloc/releases/download/${DEP_JEMALLOC_VERSION}/jemalloc-${DEP_JEMALLOC_VERSION}.tar.bz2" -O "jemalloc-${DEP_JEMALLOC_VERSION}.tar.bz2" + verify_checksum "jemalloc-${DEP_JEMALLOC_VERSION}.tar.bz2" "2db82d1e7119df3e71b7640219b6dfe84789bc0537983c3b7ac4f7189aecfeaa" + bunzip2 "jemalloc-${DEP_JEMALLOC_VERSION}.tar.bz2" + tar -xvf "jemalloc-${DEP_JEMALLOC_VERSION}.tar" + cd "jemalloc-${DEP_JEMALLOC_VERSION}" ./configure --enable-prof --enable-prof-libunwind make -j"$(nproc)" make install cd ../ else - msg "[SKIPPED] jemalloc-5.3.0" + msg "[SKIPPED] jemalloc-${DEP_JEMALLOC_VERSION}" fi +DEP_LIBEVENT_VERSION="2.1.12-stable" # Installing libevent -if ! [ -d "libevent-2.1.11-stable" ]; then - wget "https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz" - tar -xzf "libevent-2.1.12-stable.tar.gz" - cd "libevent-2.1.12-stable" +if ! [ -d "libevent-${DEP_LIBEVENT_VERSION}" ]; then + wget "https://github.com/libevent/libevent/releases/download/release-${DEP_LIBEVENT_VERSION}/libevent-${DEP_LIBEVENT_VERSION}.tar.gz" -O "libevent-${DEP_LIBEVENT_VERSION}.tar.gz" + verify_checksum "libevent-${DEP_LIBEVENT_VERSION}.tar.gz" "92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb" + tar -xzf "libevent-${DEP_LIBEVENT_VERSION}.tar.gz" + cd "libevent-${DEP_LIBEVENT_VERSION}" ./configure make -j"$(nproc)" make install cd ../ else - msg "[SKIPPED] libevent-2.1.12-stable" + msg "[SKIPPED] libevent-${DEP_LIBEVENT_VERSION}" fi msg "Installing third-party dependencies ... DONE" - - # Installing FeedSim -cd "${FEEDSIM_ROOT_SRC}" - -cd "src" +cd "${FEEDSIM_ROOT_SRC}/src" +msg "Initializing third-party submodules" # Populate third party submodules while read -r submod; do REPO="$(echo "$submod" | cut -d ' ' -f 1)" COMMIT="$(echo "$submod" | cut -d ' ' -f 2)" SUBMOD_DIR="$(echo "$submod" | cut -d ' ' -f 3)" - mkdir -p "${SUBMOD_DIR}" - git clone "${REPO}" "${SUBMOD_DIR}" - pushd "${SUBMOD_DIR}" - git checkout "${COMMIT}" - popd + if ! [ -d "${SUBMOD_DIR}" ]; then + mkdir -p "${SUBMOD_DIR}" + git clone "${REPO}" "${SUBMOD_DIR}" + pushd "${SUBMOD_DIR}" + git checkout "${COMMIT}" + popd + else + msg "[SKIPPED] ${SUBMOD_DIR}" + fi + done < "${FEEDSIM_ROOT}/submodules.txt" +msg "Initializing third-party submodules ... DONE" # Patch fizz for OpenSSL 3.0 compatibility if [ -f "third_party/fizz/fizz/tool/FizzServerCommand.cpp" ]; then @@ -201,20 +233,25 @@ if [ -f "third_party/fizz/fizz/tool/FizzServerCommand.cpp" ]; then sed -i 's/EVP_PKEY_cmp(pubKey.get(), key.get()) == 1/EVP_PKEY_eq(pubKey.get(), key.get())/g' "third_party/fizz/fizz/tool/FizzServerCommand.cpp" fi +msg "Building FeedSim ..." mkdir -p build && cd build/ # Build FeedSim +FS_CC="${BP_CC:-gcc}" +FS_CXX="${BP_CC:-g++}" FS_CFLAGS="${BP_CFLAGS:--O3 -DNDEBUG}" -FS_CXXFLAGS="${BP_CXXFLAGS:--O3 -DNDEBUG }" +FS_CXXFLAGS="${BP_CXXFLAGS:--O3 -DNDEBUG -Wno-deprecated-declarations}" FS_LDFLAGS="${BP_LDFLAGS:-} -latomic -Wl,--export-dynamic" cmake -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_C_COMPILER="$BP_CC" \ - -DCMAKE_CXX_COMPILER="$BP_CXX" \ + -DCMAKE_PREFIX_PATH="${FEEDSIM_THIRD_PARTY_SRC}/build-deps" \ + -DCMAKE_C_COMPILER="$FS_CC" \ + -DCMAKE_CXX_COMPILER="$FS_CXX" \ -DCMAKE_C_FLAGS_RELEASE="$FS_CFLAGS" \ -DCMAKE_CXX_FLAGS_RELEASE="$FS_CXXFLAGS -DFMT_HEADER_ONLY=1" \ -DCMAKE_EXE_LINKER_FLAGS_RELEASE="$FS_LDFLAGS" \ ../ -ninja -v -j1 +ninja -j"$(nproc)" +msg "Building FeedSim ... DONE" diff --git a/packages/feedsim/install_feedsim_aarch64.sh b/packages/feedsim/install_feedsim_aarch64.sh deleted file mode 100755 index 7eeff08c..00000000 --- a/packages/feedsim/install_feedsim_aarch64.sh +++ /dev/null @@ -1,220 +0,0 @@ -#!/bin/bash -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -set -Eeuo pipefail -# trap cleanup SIGINT SIGTERM ERR EXIT - -# Constants -FEEDSIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) -BENCHPRESS_ROOT="$(readlink -f "$FEEDSIM_ROOT/../..")" -FEEDSIM_ROOT_SRC="${BENCHPRESS_ROOT}/benchmarks/feedsim" -FEEDSIM_THIRD_PARTY_SRC="${FEEDSIM_ROOT_SRC}/third_party" -echo "BENCHPRESS_ROOT is ${BENCHPRESS_ROOT}" - -cleanup() { - trap - SIGINT SIGTERM ERR EXIT -} - - -msg() { - echo >&2 -e "${1-}" -} - -die() { - local msg=$1 - local code=${2-1} # default exit status 1 - msg "$msg" - exit "$code" -} - -dnf install -y bc ninja-build flex bison git texinfo binutils-devel \ - libsodium-devel libunwind-devel bzip2-devel double-conversion-devel \ - libzstd-devel lz4-devel xz-devel snappy-devel libtool bzip2 openssl-devel \ - zlib-devel libdwarf libdwarf-devel libaio-devel libatomic patch jq xxhash xxhash-devel - -# Creates feedsim directory under benchmarks/ -mkdir -p "${BENCHPRESS_ROOT}/benchmarks/feedsim" -cd "${BENCHPRESS_ROOT}/benchmarks" - -# Copy run.sh template (overwrite) -cp "${BENCHPRESS_ROOT}/packages/feedsim/run.sh" "${FEEDSIM_ROOT_SRC}/run.sh" -cp "${BENCHPRESS_ROOT}/packages/feedsim/run-feedsim-multi.sh" "${FEEDSIM_ROOT_SRC}/run-feedsim-multi.sh" -# Set as executable -chmod u+x "${FEEDSIM_ROOT_SRC}/run.sh" -chmod u+x "${FEEDSIM_ROOT_SRC}/run-feedsim-multi.sh" - -msg "Installing third-party dependencies..." -mkdir -p "${FEEDSIM_THIRD_PARTY_SRC}" -if ! [ -d "${FEEDSIM_ROOT_SRC}/src" ]; then - cp -r "${BENCHPRESS_ROOT}/packages/feedsim/third_party/src" "${FEEDSIM_ROOT_SRC}/" -else - msg "[SKIPPED] copying feedsim src" -fi -cd "${FEEDSIM_THIRD_PARTY_SRC}" - -# Installing cmake-4.0.3 - -if ! [ -d "cmake-4.0.3" ]; then - wget "https://github.com/Kitware/CMake/releases/download/v4.0.3/cmake-4.0.3.tar.gz" - tar -zxf "cmake-4.0.3.tar.gz" - cd "cmake-4.0.3" - mkdir staging - ./bootstrap --parallel=8 --prefix="$(pwd)/staging" - make -j8 - make install - cd ../ -else - msg "[SKIPPED] cmake-4.0.3" -fi - -export PATH="${FEEDSIM_THIRD_PARTY_SRC}/cmake-4.0.3/staging/bin:${PATH}" - -git clone https://github.com/fastfloat/fast_float.git -cd fast_float -mkdir build && cd build -cmake .. -make -make install -cd ../ - -# Installing gengetopt -if ! [ -d "gengetopt-2.23" ]; then - # Source the download retry function - source "${BENCHPRESS_ROOT}/scripts/download_with_retry.sh" - download_with_retry "https://mirrors.ocf.berkeley.edu/gnu/gengetopt/gengetopt-2.23.tar.xz" - tar -xf "gengetopt-2.23.tar.xz" - cd "gengetopt-2.23" - ./configure - make -j"$(nproc)" - make install - cd ../ -else - msg "[SKIPPED] gengetopt-2.23" -fi - -# Installing Boost -if ! [ -d "boost_1_88_0" ]; then - wget "https://archives.boost.io/release/1.88.0/source/boost_1_88_0.tar.gz" - tar -xzf "boost_1_88_0.tar.gz" - cd "boost_1_88_0" - ./bootstrap.sh --without-libraries=python - ./b2 install - cd ../ -else - msg "[SKIPPED] boost_1_88_0" -fi - - -# Installing gflags -if ! [ -d "gflags-2.2.2" ]; then - wget "https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.tar.gz" -O "gflags-2.2.2.tar.gz" - tar -xzf "gflags-2.2.2.tar.gz" - cd "gflags-2.2.2" - mkdir -p build && cd build - cmake -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ../ - make -j8 - make install - cd ../../ -else - msg "[SKIPPED] gflags-2.2.2" -fi - -# Installing glog -if ! [ -d "glog-0.4.0" ]; then - wget "https://github.com/google/glog/archive/refs/tags/v0.4.0.tar.gz" -O "glog-0.4.0.tar.gz" - tar -xzf "glog-0.4.0.tar.gz" - cd "glog-0.4.0" - mkdir -p build && cd build - cmake -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ../ - make -j8 - make install - cd ../../ -else - msg "[SKIPPED] glog-0.4.0" -fi - -# Installing JEMalloc -if ! [ -d "jemalloc-5.3.0" ]; then - wget "https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2" - bunzip2 "jemalloc-5.3.0.tar.bz2" - tar -xvf "jemalloc-5.3.0.tar" - cd "jemalloc-5.3.0" - ./configure --enable-prof --enable-prof-libunwind - make -j"$(nproc)" - make install - cd ../ -else - msg "[SKIPPED] jemalloc-5.3.0" -fi - -# Installing libevent -if ! [ -d "libevent-2.1.11-stable" ]; then - wget "https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz" - tar -xzf "libevent-2.1.12-stable.tar.gz" - cd "libevent-2.1.12-stable" - ./configure - make -j"$(nproc)" - make install - cd ../ -else - msg "[SKIPPED] libevent-2.1.12-stable" -fi - -msg "Installing third-party dependencies ... DONE" - - -# Installing FeedSim -cd "${FEEDSIM_ROOT_SRC}" - -cd "src" - -# Populate third party submodules -while read -r submod; -do - REPO="$(echo "$submod" | cut -d ' ' -f 1)" - COMMIT="$(echo "$submod" | cut -d ' ' -f 2)" - SUBMOD_DIR="$(echo "$submod" | cut -d ' ' -f 3)" - if ! [ -d "${SUBMOD_DIR}" ]; then - mkdir -p "${SUBMOD_DIR}" - git clone "${REPO}" "${SUBMOD_DIR}" - pushd "${SUBMOD_DIR}" - git checkout "${COMMIT}" - popd - else - msg "[SKIPPED] ${SUBMOD_DIR}" - fi - -done < "${FEEDSIM_ROOT}/submodules.txt" - -# Patch fizz for OpenSSL 3.0 compatibility -if [ -f "third_party/fizz/fizz/tool/FizzServerCommand.cpp" ]; then - # Replace EVP_PKEY_cmp with EVP_PKEY_eq - sed -i 's/EVP_PKEY_cmp(pubKey.get(), key.get()) == 1/EVP_PKEY_eq(pubKey.get(), key.get())/g' "third_party/fizz/fizz/tool/FizzServerCommand.cpp" -fi - -mkdir -p build && cd build/ - -# Build FeedSim -FS_CFLAGS="${BP_CFLAGS:--O3 -DNDEBUG}" -FS_CXXFLAGS="${BP_CXXFLAGS:--O3 -DNDEBUG -Wno-deprecated-declarations}" -FS_LDFLAGS="${BP_LDFLAGS:-} -latomic -Wl,--export-dynamic" - -BP_CC=gcc -BP_CXX=g++ - -# Use system OpenSSL - -cmake -G Ninja \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_PREFIX_PATH="${FEEDSIM_THIRD_PARTY_SRC}/build-deps" \ - -DCMAKE_C_COMPILER="$BP_CC" \ - -DCMAKE_CXX_COMPILER="$BP_CXX" \ - -DCMAKE_C_FLAGS_RELEASE="$FS_CFLAGS" \ - -DCMAKE_CXX_FLAGS_RELEASE="$FS_CXXFLAGS -DFMT_HEADER_ONLY=1" \ - -DCMAKE_EXE_LINKER_FLAGS_RELEASE="$FS_LDFLAGS" \ - ../ - -ninja-build -v -j1 diff --git a/packages/feedsim/install_feedsim_aarch64_ubuntu.sh b/packages/feedsim/install_feedsim_aarch64_ubuntu.sh deleted file mode 100755 index 7b4660df..00000000 --- a/packages/feedsim/install_feedsim_aarch64_ubuntu.sh +++ /dev/null @@ -1,218 +0,0 @@ -#!/bin/bash -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -set -Eeuo pipefail -# trap cleanup SIGINT SIGTERM ERR EXIT - -# Constants -FEEDSIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) -BENCHPRESS_ROOT="$(readlink -f "$FEEDSIM_ROOT/../..")" -FEEDSIM_ROOT_SRC="${BENCHPRESS_ROOT}/benchmarks/feedsim" -FEEDSIM_THIRD_PARTY_SRC="${FEEDSIM_ROOT_SRC}/third_party" -echo "BENCHPRESS_ROOT is ${BENCHPRESS_ROOT}" - -cleanup() { - trap - SIGINT SIGTERM ERR EXIT -} - - -msg() { - echo >&2 -e "${1-}" -} - -die() { - local msg=$1 - local code=${2-1} # default exit status 1 - msg "$msg" - exit "$code" -} - -apt install -y bc cmake ninja-build flex bison texinfo binutils-dev \ - libunwind-dev bzip2 libbz2-dev libsodium-dev libghc-double-conversion-dev \ - libzstd-dev lz4 liblz4-dev xzip libsnappy-dev libtool libssl-dev \ - zlib1g-dev libdwarf-dev libaio-dev libatomic1 patch perl libiberty-dev \ - libfmt-dev sysstat jq - -# Creates feedsim directory under benchmarks/ -mkdir -p "${BENCHPRESS_ROOT}/benchmarks/feedsim" -cd "${BENCHPRESS_ROOT}/benchmarks" - -# Copy run.sh template (overwrite) -cp "${BENCHPRESS_ROOT}/packages/feedsim/run.sh" "${FEEDSIM_ROOT_SRC}/run.sh" -cp "${BENCHPRESS_ROOT}/packages/feedsim/run-feedsim-multi.sh" "${FEEDSIM_ROOT_SRC}/run-feedsim-multi.sh" -# Set as executable -chmod u+x "${FEEDSIM_ROOT_SRC}/run.sh" -chmod u+x "${FEEDSIM_ROOT_SRC}/run-feedsim-multi.sh" - -msg "Installing third-party dependencies..." -mkdir -p "${FEEDSIM_THIRD_PARTY_SRC}" -if ! [ -d "${FEEDSIM_ROOT_SRC}/src" ]; then - cp -r "${BENCHPRESS_ROOT}/packages/feedsim/third_party/src" "${FEEDSIM_ROOT_SRC}/" -else - msg "[SKIPPED] copying feedsim src" -fi -cd "${FEEDSIM_THIRD_PARTY_SRC}" - -# Installing gengetopt -if ! [ -d "gengetopt-2.23" ]; then - # Source the download retry function - source "${BENCHPRESS_ROOT}/scripts/download_with_retry.sh" - download_with_retry "https://mirrors.ocf.berkeley.edu/gnu/gengetopt/gengetopt-2.23.tar.xz" - tar -xf "gengetopt-2.23.tar.xz" - cd "gengetopt-2.23" - ./configure - make -j"$(nproc)" - make install - cd ../ -else - msg "[SKIPPED] gengetopt-2.23" -fi - -# Installing Boost -if ! [ -d "boost_1_71_0" ]; then - wget "https://archives.boost.io/release/1.71.0/source/boost_1_71_0.tar.gz" - tar -xzf "boost_1_71_0.tar.gz" - cd "boost_1_71_0" - ./bootstrap.sh --without-libraries=python - sed -i 's/if PTHREAD_STACK_MIN > 0/ifdef PTHREAD_STACK_MIN/g' boost/thread/pthread/thread_data.hpp - ./b2 - ./b2 install - cd ../ -else - msg "[SKIPPED] boost_1_71_0" -fi - -# Installing gflags -if ! [ -d "gflags-2.2.2" ]; then - wget "https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.tar.gz" -O "gflags-2.2.2.tar.gz" - tar -xzf "gflags-2.2.2.tar.gz" - cd "gflags-2.2.2" - mkdir -p build && cd build - cmake -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release ../ - make -j8 - make install - cd ../../ -else - msg "[SKIPPED] gflags-2.2.2" -fi - -# Installing glog -if ! [ -d "glog-0.4.0" ]; then - wget "https://github.com/google/glog/archive/refs/tags/v0.4.0.tar.gz" -O "glog-0.4.0.tar.gz" - tar -xzf "glog-0.4.0.tar.gz" - cd "glog-0.4.0" - mkdir -p build && cd build - cmake -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release ../ - make -j8 - make install - cd ../../ -else - msg "[SKIPPED] glog-0.4.0" -fi - -# Installing JEMalloc -if ! [ -d "jemalloc-5.2.1" ]; then - wget "https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2" - bunzip2 "jemalloc-5.2.1.tar.bz2" - tar -xvf "jemalloc-5.2.1.tar" - cd "jemalloc-5.2.1" - ./configure --enable-prof --enable-prof-libunwind - make -j"$(nproc)" - make install - cd ../ -else - msg "[SKIPPED] jemalloc-5.2.1" -fi - -# Installing libevent -if ! [ -d "libevent-2.1.11-stable" ]; then - wget "https://github.com/libevent/libevent/releases/download/release-2.1.11-stable/libevent-2.1.11-stable.tar.gz" - tar -xzf "libevent-2.1.11-stable.tar.gz" - cd "libevent-2.1.11-stable" - ./configure - make -j"$(nproc)" - make install - cd ../ -else - msg "[SKIPPED] libevent-2.1.11-stable" -fi - -# Installing openssl -if ! [ -d "openssl" ]; then - mkdir -p build-deps - git clone --branch OpenSSL_1_1_1b --depth 1 https://github.com/openssl/openssl.git - cd "openssl" - ./config --prefix="${FEEDSIM_THIRD_PARTY_SRC}/build-deps" - make -j"$(nproc)" - make install - cd ../ -else - msg "[SKIPPED] openssl" -fi - -msg "Installing third-party dependencies ... DONE" - - -# Installing FeedSim -cd "${FEEDSIM_ROOT_SRC}" - -cd "src" - -# Populate third party submodules -msg "Checking out submodules..." -while read -r submod; -do - REPO="$(echo "$submod" | cut -d ' ' -f 1)" - COMMIT="$(echo "$submod" | cut -d ' ' -f 2)" - SUBMOD_DIR="$(echo "$submod" | cut -d ' ' -f 3)" - if ! [ -d "${SUBMOD_DIR}" ]; then - mkdir -p "${SUBMOD_DIR}" - git clone "${REPO}" "${SUBMOD_DIR}" - pushd "${SUBMOD_DIR}" - git checkout "${COMMIT}" - popd - else - msg "[SKIPPED] ${SUBMOD_DIR}" - fi - -done < "${FEEDSIM_ROOT}/submodules.txt" - -# If running on Ubuntu 22.04, apply compatilibity patches to folly, rsocket and wangle -# TODO: This is a temporary fix. In the long term we should seek to have feedsim -# support the up-to-date version of these dependencies -REPOS_TO_PATCH=(folly rsocket-cpp) -if grep -i 'Ubuntu 22.04' /etc/os-release >/dev/null 2>&1; then - for repo in "${REPOS_TO_PATCH[@]}"; do - pushd "third_party/$repo" || exit 1 - git apply --check "${FEEDSIM_ROOT}/patches/ubuntu-22-compatibility/${repo}.diff" && \ - git apply "${FEEDSIM_ROOT}/patches/ubuntu-22-compatibility/${repo}.diff" - popd || exit 1 - done -fi - -mkdir -p build && cd build/ - -# Build FeedSim -FS_CFLAGS="${BP_CFLAGS:--O3 -DNDEBUG}" -FS_CXXFLAGS="${BP_CXXFLAGS:--O3 -DNDEBUG }" -FS_LDFLAGS="${BP_LDFLAGS:-} -latomic -Wl,--export-dynamic" - -BP_CC=gcc -BP_CXX=g++ - -cmake -G Ninja \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_PREFIX_PATH="${FEEDSIM_THIRD_PARTY_SRC}/build-deps" \ - -DCMAKE_C_COMPILER="$BP_CC" \ - -DCMAKE_CXX_COMPILER="$BP_CXX" \ - -DCMAKE_C_FLAGS_RELEASE="$FS_CFLAGS" \ - -DCMAKE_CXX_FLAGS_RELEASE="$FS_CXXFLAGS" \ - -DCMAKE_EXE_LINKER_FLAGS_RELEASE="$FS_LDFLAGS" \ - ../ - -sed -i 's/lib64/lib/' build.ninja - -ninja -v -j1 diff --git a/packages/feedsim/install_feedsim_ubuntu.sh b/packages/feedsim/install_feedsim_ubuntu.sh deleted file mode 100755 index 3f52c35b..00000000 --- a/packages/feedsim/install_feedsim_ubuntu.sh +++ /dev/null @@ -1,219 +0,0 @@ -#!/bin/bash -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -set -Eeuo pipefail -# trap cleanup SIGINT SIGTERM ERR EXIT - -# Constants -FEEDSIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) -BENCHPRESS_ROOT="$(readlink -f "$FEEDSIM_ROOT/../..")" -FEEDSIM_ROOT_SRC="${BENCHPRESS_ROOT}/benchmarks/feedsim" -FEEDSIM_THIRD_PARTY_SRC="${FEEDSIM_ROOT_SRC}/third_party" -echo "BENCHPRESS_ROOT is ${BENCHPRESS_ROOT}" - -cleanup() { - trap - SIGINT SIGTERM ERR EXIT -} - - -msg() { - echo >&2 -e "${1-}" -} - -die() { - local msg=$1 - local code=${2-1} # default exit status 1 - msg "$msg" - exit "$code" -} - -#dnf install -y cmake ninja-build flex bison git texinfo binutils-devel \ -# libunwind-devel bzip2-devel libsodium-devel double-conversion-devel \ -# libzstd-devel lz4-devel xz-devel snappy-devel libtool openssl-devel \ -# zlib-devel libdwarf-devel libaio-devel libatomic patch perl -apt install -y bc cmake ninja-build flex bison texinfo binutils-dev \ - libunwind-dev bzip2 libbz2-dev libsodium-dev libghc-double-conversion-dev \ - libzstd-dev lz4 liblz4-dev xzip libsnappy-dev libtool libssl-dev \ - zlib1g-dev libdwarf-dev libaio-dev libatomic1 patch perl libiberty-dev \ - libfmt-dev sysstat jq xxhash libxxhash-dev - - -# Creates feedsim directory under benchmarks/ -mkdir -p "${BENCHPRESS_ROOT}/benchmarks/feedsim" -cd "${BENCHPRESS_ROOT}/benchmarks" - -# Copy run.sh template (overwrite) -cp "${BENCHPRESS_ROOT}/packages/feedsim/run.sh" "${FEEDSIM_ROOT_SRC}/run.sh" -cp "${BENCHPRESS_ROOT}/packages/feedsim/run-feedsim-multi.sh" "${FEEDSIM_ROOT_SRC}/run-feedsim-multi.sh" -# Set as executable -chmod u+x "${FEEDSIM_ROOT_SRC}/run.sh" -chmod u+x "${FEEDSIM_ROOT_SRC}/run-feedsim-multi.sh" - -msg "Installing third-party dependencies..." -mkdir -p "${FEEDSIM_THIRD_PARTY_SRC}" -if ! [ -d "${FEEDSIM_ROOT_SRC}/src" ]; then - cp -r "${BENCHPRESS_ROOT}/packages/feedsim/third_party/src" "${FEEDSIM_ROOT_SRC}/" -else - msg "[SKIPPED] copying feedsim src" -fi -cd "${FEEDSIM_THIRD_PARTY_SRC}" - -# Installing cmake-4.0.3 - -if ! [ -d "cmake-4.0.3" ]; then - wget "https://github.com/Kitware/CMake/releases/download/v4.0.3/cmake-4.0.3.tar.gz" - tar -zxf "cmake-4.0.3.tar.gz" - cd "cmake-4.0.3" - mkdir staging - ./bootstrap --parallel=8 --prefix="$(pwd)/staging" - make -j8 - make install - cd ../ -else - msg "[SKIPPED] cmake-4.0.3" -fi - -export PATH="${FEEDSIM_THIRD_PARTY_SRC}/cmake-4.0.3/staging/bin:${PATH}" - -git clone https://github.com/fastfloat/fast_float.git -cd fast_float -mkdir build && cd build -cmake .. -make -make install -cd ../ - -# Installing gengetopt -if ! [ -d "gengetopt-2.23" ]; then - # Source the download retry function - source "${BENCHPRESS_ROOT}/scripts/download_with_retry.sh" - download_with_retry "https://mirrors.ocf.berkeley.edu/gnu/gengetopt/gengetopt-2.23.tar.xz" - tar -xf "gengetopt-2.23.tar.xz" - cd "gengetopt-2.23" - ./configure - make -j"$(nproc)" - make install - cd ../ -else - msg "[SKIPPED] gengetopt-2.23" -fi - -# Installing Boost -if ! [ -d "boost_1_88_0" ]; then - wget "https://archives.boost.io/release/1.88.0/source/boost_1_88_0.tar.gz" - tar -xzf "boost_1_88_0.tar.gz" - cd "boost_1_88_0" - ./bootstrap.sh --without-libraries=python - ./b2 install - cd ../ -else - msg "[SKIPPED] boost_1_88_0" -fi - - -# Installing gflags -if ! [ -d "gflags-2.2.2" ]; then - wget "https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.tar.gz" -O "gflags-2.2.2.tar.gz" - tar -xzf "gflags-2.2.2.tar.gz" - cd "gflags-2.2.2" - mkdir -p build && cd build - cmake -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ../ - make -j8 - make install - cd ../../ -else - msg "[SKIPPED] gflags-2.2.2" -fi - -# Installing glog -if ! [ -d "glog-0.4.0" ]; then - wget "https://github.com/google/glog/archive/refs/tags/v0.4.0.tar.gz" -O "glog-0.4.0.tar.gz" - tar -xzf "glog-0.4.0.tar.gz" - cd "glog-0.4.0" - mkdir -p build && cd build - cmake -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ../ - make -j8 - make install - cd ../../ -else - msg "[SKIPPED] glog-0.4.0" -fi - -# Installing JEMalloc -if ! [ -d "jemalloc-5.3.0" ]; then - wget "https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2" - bunzip2 "jemalloc-5.3.0.tar.bz2" - tar -xvf "jemalloc-5.3.0.tar" - cd "jemalloc-5.3.0" - ./configure --enable-prof --enable-prof-libunwind - make -j"$(nproc)" - make install - cd ../ -else - msg "[SKIPPED] jemalloc-5.3.0" -fi - -# Installing libevent -if ! [ -d "libevent-2.1.11-stable" ]; then - wget "https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz" - tar -xzf "libevent-2.1.12-stable.tar.gz" - cd "libevent-2.1.12-stable" - ./configure - make -j"$(nproc)" - make install - cd ../ -else - msg "[SKIPPED] libevent-2.1.12-stable" -fi - -msg "Installing third-party dependencies ... DONE" - - -# Installing FeedSim -cd "${FEEDSIM_ROOT_SRC}" - -cd "src" - -# Populate third party submodules -while read -r submod; -do - REPO="$(echo "$submod" | cut -d ' ' -f 1)" - COMMIT="$(echo "$submod" | cut -d ' ' -f 2)" - SUBMOD_DIR="$(echo "$submod" | cut -d ' ' -f 3)" - mkdir -p "${SUBMOD_DIR}" - git clone "${REPO}" "${SUBMOD_DIR}" - pushd "${SUBMOD_DIR}" - git checkout "${COMMIT}" - popd -done < "${FEEDSIM_ROOT}/submodules.txt" - -# Patch fizz for OpenSSL 3.0 compatibility -if [ -f "third_party/fizz/fizz/tool/FizzServerCommand.cpp" ]; then - # Replace EVP_PKEY_cmp with EVP_PKEY_eq - sed -i 's/EVP_PKEY_cmp(pubKey.get(), key.get()) == 1/EVP_PKEY_eq(pubKey.get(), key.get())/g' "third_party/fizz/fizz/tool/FizzServerCommand.cpp" -fi - -mkdir -p build && cd build/ - -# Build FeedSim -FS_CFLAGS="${BP_CFLAGS:--O3 -DNDEBUG}" -FS_CXXFLAGS="${BP_CXXFLAGS:--O3 -DNDEBUG }" -FS_LDFLAGS="${BP_LDFLAGS:-} -latomic -Wl,--export-dynamic" - -BP_CC=gcc -BP_CXX=g++ - -cmake -G Ninja \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_C_COMPILER="$BP_CC" \ - -DCMAKE_CXX_COMPILER="$BP_CXX" \ - -DCMAKE_C_FLAGS_RELEASE="$FS_CFLAGS" \ - -DCMAKE_CXX_FLAGS_RELEASE="$FS_CXXFLAGS -DFMT_HEADER_ONLY=1" \ - -DCMAKE_EXE_LINKER_FLAGS_RELEASE="$FS_LDFLAGS" \ - ../ - -sed -i 's/lib64/lib/' build.ninja -ninja -v -j1 diff --git a/packages/feedsim/third_party/src/CMake/build-fbthrift.cmake b/packages/feedsim/third_party/src/CMake/build-fbthrift.cmake index 41e1af34..4ac25d70 100644 --- a/packages/feedsim/third_party/src/CMake/build-fbthrift.cmake +++ b/packages/feedsim/third_party/src/CMake/build-fbthrift.cmake @@ -40,7 +40,7 @@ ExternalProject_Add(fbthrift cmake --build . ) -ExternalProject_Add_StepDependencies(fbthrift configure folly wangle fmt) +ExternalProject_Add_StepDependencies(fbthrift configure folly wangle fmt mvfst) ExternalProject_Get_Property(fbthrift SOURCE_DIR) ExternalProject_Get_Property(fbthrift INSTALL_DIR) diff --git a/packages/feedsim/third_party/src/CMake/build-fmt.cmake b/packages/feedsim/third_party/src/CMake/build-fmt.cmake index 1acf0cef..0c06e003 100644 --- a/packages/feedsim/third_party/src/CMake/build-fmt.cmake +++ b/packages/feedsim/third_party/src/CMake/build-fmt.cmake @@ -1,33 +1,31 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -include(ExternalProject) - -ExternalProject_Add(fmt - SOURCE_DIR "${oldisim_SOURCE_DIR}/third_party/fmt" - DOWNLOAD_COMMAND "" - BUILD_ALWAYS OFF - INSTALL_DIR ${OLDISIM_STAGING_DIR} - CMAKE_ARGS - -DCMAKE_BUILD_TYPE:STRING=Release - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=True - -DCMAKE_CXX_STANDARD:BOOL=17 - -DCMAKE_INSTALL_PREFIX:PATH= - -DFMT_TEST:BOOL=OFF - BINARY_DIR ${oldisim_BINARY_DIR}/third_party/fmt - BUILD_BYPRODUCTS /lib64/libfmt.a - ) - -# Specify include dir -ExternalProject_Get_Property(fmt INSTALL_DIR) - -set(FMT_LIBRARIES - ${INSTALL_DIR}/lib64/libfmt.a - ) -message(STATUS "fmt Library: ${FMT_LIBRARIES}") - -mark_as_advanced( - FMT_LIBRARIES -) +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +include(ExternalProject) +include(GNUInstallDirs) + +ExternalProject_Add(fmt + SOURCE_DIR "${oldisim_SOURCE_DIR}/third_party/fmt" + DOWNLOAD_COMMAND "" + BUILD_ALWAYS OFF + INSTALL_DIR ${OLDISIM_STAGING_DIR} + CMAKE_ARGS + -DCMAKE_BUILD_TYPE:STRING=Release + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=True + -DCMAKE_CXX_STANDARD:BOOL=17 + -DCMAKE_INSTALL_PREFIX:PATH= + -DFMT_TEST:BOOL=OFF + BINARY_DIR ${oldisim_BINARY_DIR}/third_party/fmt + BUILD_BYPRODUCTS /${CMAKE_INSTALL_LIBDIR}/libfmt.a + ) + +# Specify include dir +ExternalProject_Get_Property(fmt INSTALL_DIR) +set(FMT_LIBRARIES "${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libfmt.a") +message(STATUS "fmt Library: ${FMT_LIBRARIES}") + +mark_as_advanced( + FMT_LIBRARIES +) diff --git a/packages/feedsim/third_party/src/CMake/build-mvfst.cmake b/packages/feedsim/third_party/src/CMake/build-mvfst.cmake index 201e15a5..671cc0ec 100644 --- a/packages/feedsim/third_party/src/CMake/build-mvfst.cmake +++ b/packages/feedsim/third_party/src/CMake/build-mvfst.cmake @@ -25,3 +25,4 @@ ExternalProject_Add(mvfst BUILD_COMMAND cmake --build . ) +ExternalProject_Add_StepDependencies(mvfst configure fmt folly fizz) \ No newline at end of file diff --git a/packages/feedsim/third_party/src/workloads/CMakeLists.txt b/packages/feedsim/third_party/src/workloads/CMakeLists.txt index 3b7e2a0e..683aba18 100644 --- a/packages/feedsim/third_party/src/workloads/CMakeLists.txt +++ b/packages/feedsim/third_party/src/workloads/CMakeLists.txt @@ -8,6 +8,4 @@ project(oldisim_workloads) include_directories(${CMAKE_CURRENT_LIST_DIR}) -add_subdirectory(simple) -add_subdirectory(search) add_subdirectory(ranking) diff --git a/packages/feedsim/third_party/src/workloads/ranking/CMakeLists.txt b/packages/feedsim/third_party/src/workloads/ranking/CMakeLists.txt index 73e43ce3..25318903 100644 --- a/packages/feedsim/third_party/src/workloads/ranking/CMakeLists.txt +++ b/packages/feedsim/third_party/src/workloads/ranking/CMakeLists.txt @@ -6,6 +6,8 @@ cmake_minimum_required(VERSION 3.12) project(oldisim_ranking) +add_subdirectory(icachebuster) +add_subdirectory(pointerchase) find_package(Boost 1.53.0 COMPONENTS context diff --git a/packages/feedsim/third_party/src/workloads/ranking/LeafNodeRank.cc b/packages/feedsim/third_party/src/workloads/ranking/LeafNodeRank.cc index 1bb24ee9..f78d4cb9 100644 --- a/packages/feedsim/third_party/src/workloads/ranking/LeafNodeRank.cc +++ b/packages/feedsim/third_party/src/workloads/ranking/LeafNodeRank.cc @@ -45,8 +45,8 @@ #include "if/gen-cpp2/ranking_types.h" -#include "../search/ICacheBuster.h" -#include "../search/PointerChase.h" +#include "icachebuster/ICacheBuster.h" +#include "pointerchase/PointerChase.h" #include "generators/RankingGenerators.h" @@ -310,7 +310,7 @@ int main(int argc, char** argv) { int fake_argc = 1; char* fake_argv[2] = {const_cast("./LeafNodeRank"), nullptr}; char** sargv = static_cast(fake_argv); - folly::init(&fake_argc, &sargv); + folly::Init (&fake_argc, &sargv); auto cpuThreadPool = std::make_shared(args.cpu_threads_arg); diff --git a/packages/feedsim/third_party/src/workloads/ranking/gen-cpp/ranking_constants.cpp b/packages/feedsim/third_party/src/workloads/ranking/gen-cpp/ranking_constants.cpp deleted file mode 100644 index ea8e0d06..00000000 --- a/packages/feedsim/third_party/src/workloads/ranking/gen-cpp/ranking_constants.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.13.0) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -#include "ranking_constants.h" - -namespace ranking { - -const rankingConstants g_ranking_constants; - -rankingConstants::rankingConstants() { -} - -} // namespace - diff --git a/packages/feedsim/third_party/src/workloads/ranking/gen-cpp/ranking_constants.h b/packages/feedsim/third_party/src/workloads/ranking/gen-cpp/ranking_constants.h deleted file mode 100644 index 178e6d77..00000000 --- a/packages/feedsim/third_party/src/workloads/ranking/gen-cpp/ranking_constants.h +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.13.0) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -#ifndef ranking_CONSTANTS_H -#define ranking_CONSTANTS_H - -#include "ranking_types.h" - -namespace ranking { - -class rankingConstants { - public: - rankingConstants(); - -}; - -extern const rankingConstants g_ranking_constants; - -} // namespace - -#endif diff --git a/packages/feedsim/third_party/src/workloads/ranking/gen-cpp/ranking_types.cpp b/packages/feedsim/third_party/src/workloads/ranking/gen-cpp/ranking_types.cpp deleted file mode 100644 index f4dd5a26..00000000 --- a/packages/feedsim/third_party/src/workloads/ranking/gen-cpp/ranking_types.cpp +++ /dev/null @@ -1,1225 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.13.0) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -#include "ranking_types.h" - -#include -#include - -#include - -namespace ranking { - -int _kRankingStoryTypeValues[] = { - RankingStoryType::STORY_TYPE_A, - RankingStoryType::STORY_TYPE_B, - RankingStoryType::STORY_TYPE_C, - RankingStoryType::STORY_TYPE_D, - RankingStoryType::STORY_TYPE_E, - RankingStoryType::STORY_TYPE_F, - RankingStoryType::STORY_TYPE_G, - RankingStoryType::STORY_TYPE_H, - RankingStoryType::STORY_TYPE_I, - RankingStoryType::STORY_TYPE_J, - RankingStoryType::STORY_TYPE_K, - RankingStoryType::STORY_TYPE_L, - RankingStoryType::STORY_TYPE_M, - RankingStoryType::STORY_TYPE_N, - RankingStoryType::STORY_TYPE_O, - RankingStoryType::STORY_TYPE_P, - RankingStoryType::STORY_TYPE_Q, - RankingStoryType::STORY_TYPE_R, - RankingStoryType::STORY_TYPE_S, - RankingStoryType::STORY_TYPE_T, - RankingStoryType::STORY_TYPE_U, - RankingStoryType::STORY_TYPE_V, - RankingStoryType::STORY_TYPE_W, - RankingStoryType::STORY_TYPE_X, - RankingStoryType::STORY_TYPE_Y, - RankingStoryType::STORY_TYPE_Z -}; -const char* _kRankingStoryTypeNames[] = { - "STORY_TYPE_A", - "STORY_TYPE_B", - "STORY_TYPE_C", - "STORY_TYPE_D", - "STORY_TYPE_E", - "STORY_TYPE_F", - "STORY_TYPE_G", - "STORY_TYPE_H", - "STORY_TYPE_I", - "STORY_TYPE_J", - "STORY_TYPE_K", - "STORY_TYPE_L", - "STORY_TYPE_M", - "STORY_TYPE_N", - "STORY_TYPE_O", - "STORY_TYPE_P", - "STORY_TYPE_Q", - "STORY_TYPE_R", - "STORY_TYPE_S", - "STORY_TYPE_T", - "STORY_TYPE_U", - "STORY_TYPE_V", - "STORY_TYPE_W", - "STORY_TYPE_X", - "STORY_TYPE_Y", - "STORY_TYPE_Z" -}; -const std::map _RankingStoryType_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(26, _kRankingStoryTypeValues, _kRankingStoryTypeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL)); - -std::ostream& operator<<(std::ostream& out, const RankingStoryType::type& val) { - std::map::const_iterator it = _RankingStoryType_VALUES_TO_NAMES.find(val); - if (it != _RankingStoryType_VALUES_TO_NAMES.end()) { - out << it->second; - } else { - out << static_cast(val); - } - return out; -} - -std::string to_string(const RankingStoryType::type& val) { - std::map::const_iterator it = _RankingStoryType_VALUES_TO_NAMES.find(val); - if (it != _RankingStoryType_VALUES_TO_NAMES.end()) { - return std::string(it->second); - } else { - return std::to_string(static_cast(val)); - } -} - -int _kRankingObjectTypeValues[] = { - RankingObjectType::OBJ_TYPE_A, - RankingObjectType::OBJ_TYPE_B, - RankingObjectType::OBJ_TYPE_C, - RankingObjectType::OBJ_TYPE_D, - RankingObjectType::OBJ_TYPE_E, - RankingObjectType::OBJ_TYPE_F, - RankingObjectType::OBJ_TYPE_G, - RankingObjectType::OBJ_TYPE_H, - RankingObjectType::OBJ_TYPE_I, - RankingObjectType::OBJ_TYPE_J, - RankingObjectType::OBJ_TYPE_K, - RankingObjectType::OBJ_TYPE_L, - RankingObjectType::OBJ_TYPE_M, - RankingObjectType::OBJ_TYPE_N, - RankingObjectType::OBJ_TYPE_O, - RankingObjectType::OBJ_TYPE_P, - RankingObjectType::OBJ_TYPE_Q, - RankingObjectType::OBJ_TYPE_R, - RankingObjectType::OBJ_TYPE_S, - RankingObjectType::OBJ_TYPE_T, - RankingObjectType::OBJ_TYPE_U, - RankingObjectType::OBJ_TYPE_V, - RankingObjectType::OBJ_TYPE_W, - RankingObjectType::OBJ_TYPE_X, - RankingObjectType::OBJ_TYPE_Y, - RankingObjectType::OBJ_TYPE_Z -}; -const char* _kRankingObjectTypeNames[] = { - "OBJ_TYPE_A", - "OBJ_TYPE_B", - "OBJ_TYPE_C", - "OBJ_TYPE_D", - "OBJ_TYPE_E", - "OBJ_TYPE_F", - "OBJ_TYPE_G", - "OBJ_TYPE_H", - "OBJ_TYPE_I", - "OBJ_TYPE_J", - "OBJ_TYPE_K", - "OBJ_TYPE_L", - "OBJ_TYPE_M", - "OBJ_TYPE_N", - "OBJ_TYPE_O", - "OBJ_TYPE_P", - "OBJ_TYPE_Q", - "OBJ_TYPE_R", - "OBJ_TYPE_S", - "OBJ_TYPE_T", - "OBJ_TYPE_U", - "OBJ_TYPE_V", - "OBJ_TYPE_W", - "OBJ_TYPE_X", - "OBJ_TYPE_Y", - "OBJ_TYPE_Z" -}; -const std::map _RankingObjectType_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(26, _kRankingObjectTypeValues, _kRankingObjectTypeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL)); - -std::ostream& operator<<(std::ostream& out, const RankingObjectType::type& val) { - std::map::const_iterator it = _RankingObjectType_VALUES_TO_NAMES.find(val); - if (it != _RankingObjectType_VALUES_TO_NAMES.end()) { - out << it->second; - } else { - out << static_cast(val); - } - return out; -} - -std::string to_string(const RankingObjectType::type& val) { - std::map::const_iterator it = _RankingObjectType_VALUES_TO_NAMES.find(val); - if (it != _RankingObjectType_VALUES_TO_NAMES.end()) { - return std::string(it->second); - } else { - return std::to_string(static_cast(val)); - } -} - - -Payload::~Payload() noexcept { -} - - -void Payload::__set_message(const std::string& val) { - this->message = val; -} -std::ostream& operator<<(std::ostream& out, const Payload& obj) -{ - obj.printTo(out); - return out; -} - - -uint32_t Payload::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->message); - this->__isset.message = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t Payload::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("Payload"); - - xfer += oprot->writeFieldBegin("message", ::apache::thrift::protocol::T_STRING, 1); - xfer += oprot->writeString(this->message); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - -void swap(Payload &a, Payload &b) { - using ::std::swap; - swap(a.message, b.message); - swap(a.__isset, b.__isset); -} - -Payload::Payload(const Payload& other0) { - message = other0.message; - __isset = other0.__isset; -} -Payload::Payload( Payload&& other1) { - message = std::move(other1.message); - __isset = std::move(other1.__isset); -} -Payload& Payload::operator=(const Payload& other2) { - message = other2.message; - __isset = other2.__isset; - return *this; -} -Payload& Payload::operator=(Payload&& other3) { - message = std::move(other3.message); - __isset = std::move(other3.__isset); - return *this; -} -void Payload::printTo(std::ostream& out) const { - using ::apache::thrift::to_string; - out << "Payload("; - out << "message=" << to_string(message); - out << ")"; -} - - -Action::~Action() noexcept { -} - - -void Action::__set_type(const int16_t val) { - this->type = val; -} - -void Action::__set_timeUsec(const int64_t val) { - this->timeUsec = val; -} - -void Action::__set_timeMsec(const int32_t val) { - this->timeMsec = val; -} - -void Action::__set_actorID(const int64_t val) { - this->actorID = val; -} -std::ostream& operator<<(std::ostream& out, const Action& obj) -{ - obj.printTo(out); - return out; -} - - -uint32_t Action::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == ::apache::thrift::protocol::T_I16) { - xfer += iprot->readI16(this->type); - this->__isset.type = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 2: - if (ftype == ::apache::thrift::protocol::T_I64) { - xfer += iprot->readI64(this->timeUsec); - this->__isset.timeUsec = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_I32) { - xfer += iprot->readI32(this->timeMsec); - this->__isset.timeMsec = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 4: - if (ftype == ::apache::thrift::protocol::T_I64) { - xfer += iprot->readI64(this->actorID); - this->__isset.actorID = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t Action::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("Action"); - - xfer += oprot->writeFieldBegin("type", ::apache::thrift::protocol::T_I16, 1); - xfer += oprot->writeI16(this->type); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("timeUsec", ::apache::thrift::protocol::T_I64, 2); - xfer += oprot->writeI64(this->timeUsec); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("timeMsec", ::apache::thrift::protocol::T_I32, 3); - xfer += oprot->writeI32(this->timeMsec); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("actorID", ::apache::thrift::protocol::T_I64, 4); - xfer += oprot->writeI64(this->actorID); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - -void swap(Action &a, Action &b) { - using ::std::swap; - swap(a.type, b.type); - swap(a.timeUsec, b.timeUsec); - swap(a.timeMsec, b.timeMsec); - swap(a.actorID, b.actorID); - swap(a.__isset, b.__isset); -} - -Action::Action(const Action& other4) { - type = other4.type; - timeUsec = other4.timeUsec; - timeMsec = other4.timeMsec; - actorID = other4.actorID; - __isset = other4.__isset; -} -Action::Action( Action&& other5) { - type = std::move(other5.type); - timeUsec = std::move(other5.timeUsec); - timeMsec = std::move(other5.timeMsec); - actorID = std::move(other5.actorID); - __isset = std::move(other5.__isset); -} -Action& Action::operator=(const Action& other6) { - type = other6.type; - timeUsec = other6.timeUsec; - timeMsec = other6.timeMsec; - actorID = other6.actorID; - __isset = other6.__isset; - return *this; -} -Action& Action::operator=(Action&& other7) { - type = std::move(other7.type); - timeUsec = std::move(other7.timeUsec); - timeMsec = std::move(other7.timeMsec); - actorID = std::move(other7.actorID); - __isset = std::move(other7.__isset); - return *this; -} -void Action::printTo(std::ostream& out) const { - using ::apache::thrift::to_string; - out << "Action("; - out << "type=" << to_string(type); - out << ", " << "timeUsec=" << to_string(timeUsec); - out << ", " << "timeMsec=" << to_string(timeMsec); - out << ", " << "actorID=" << to_string(actorID); - out << ")"; -} - - -RankingObject::~RankingObject() noexcept { -} - - -void RankingObject::__set_objectID(const int64_t val) { - this->objectID = val; -} - -void RankingObject::__set_objectType(const RankingObjectType::type val) { - this->objectType = val; -} - -void RankingObject::__set_actorID(const int64_t val) { - this->actorID = val; -} - -void RankingObject::__set_createTime(const int64_t val) { - this->createTime = val; -} - -void RankingObject::__set_payloadIntMap(const RankingPayloadIntMap& val) { - this->payloadIntMap = val; -} - -void RankingObject::__set_payloadStrMap(const RankingPayloadStringMap& val) { - this->payloadStrMap = val; -} - -void RankingObject::__set_payloadVecMap(const RankingPayloadVecMap& val) { - this->payloadVecMap = val; -} - -void RankingObject::__set_actions(const std::vector & val) { - this->actions = val; -} - -void RankingObject::__set_weight(const double val) { - this->weight = val; -} -std::ostream& operator<<(std::ostream& out, const RankingObject& obj) -{ - obj.printTo(out); - return out; -} - - -uint32_t RankingObject::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == ::apache::thrift::protocol::T_I64) { - xfer += iprot->readI64(this->objectID); - this->__isset.objectID = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 2: - if (ftype == ::apache::thrift::protocol::T_I32) { - int32_t ecast8; - xfer += iprot->readI32(ecast8); - this->objectType = (RankingObjectType::type)ecast8; - this->__isset.objectType = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_I64) { - xfer += iprot->readI64(this->actorID); - this->__isset.actorID = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 4: - if (ftype == ::apache::thrift::protocol::T_I64) { - xfer += iprot->readI64(this->createTime); - this->__isset.createTime = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 5: - if (ftype == ::apache::thrift::protocol::T_MAP) { - { - this->payloadIntMap.clear(); - uint32_t _size9; - ::apache::thrift::protocol::TType _ktype10; - ::apache::thrift::protocol::TType _vtype11; - xfer += iprot->readMapBegin(_ktype10, _vtype11, _size9); - uint32_t _i13; - for (_i13 = 0; _i13 < _size9; ++_i13) - { - int16_t _key14; - xfer += iprot->readI16(_key14); - int64_t& _val15 = this->payloadIntMap[_key14]; - xfer += iprot->readI64(_val15); - } - xfer += iprot->readMapEnd(); - } - this->__isset.payloadIntMap = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 6: - if (ftype == ::apache::thrift::protocol::T_MAP) { - { - this->payloadStrMap.clear(); - uint32_t _size16; - ::apache::thrift::protocol::TType _ktype17; - ::apache::thrift::protocol::TType _vtype18; - xfer += iprot->readMapBegin(_ktype17, _vtype18, _size16); - uint32_t _i20; - for (_i20 = 0; _i20 < _size16; ++_i20) - { - int16_t _key21; - xfer += iprot->readI16(_key21); - std::string& _val22 = this->payloadStrMap[_key21]; - xfer += iprot->readString(_val22); - } - xfer += iprot->readMapEnd(); - } - this->__isset.payloadStrMap = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 7: - if (ftype == ::apache::thrift::protocol::T_MAP) { - { - this->payloadVecMap.clear(); - uint32_t _size23; - ::apache::thrift::protocol::TType _ktype24; - ::apache::thrift::protocol::TType _vtype25; - xfer += iprot->readMapBegin(_ktype24, _vtype25, _size23); - uint32_t _i27; - for (_i27 = 0; _i27 < _size23; ++_i27) - { - int16_t _key28; - xfer += iprot->readI16(_key28); - SmallListI64& _val29 = this->payloadVecMap[_key28]; - { - _val29.clear(); - uint32_t _size30; - ::apache::thrift::protocol::TType _etype33; - xfer += iprot->readListBegin(_etype33, _size30); - _val29.resize(_size30); - uint32_t _i34; - for (_i34 = 0; _i34 < _size30; ++_i34) - { - xfer += iprot->readI64(_val29[_i34]); - } - xfer += iprot->readListEnd(); - } - } - xfer += iprot->readMapEnd(); - } - this->__isset.payloadVecMap = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 8: - if (ftype == ::apache::thrift::protocol::T_LIST) { - { - this->actions.clear(); - uint32_t _size35; - ::apache::thrift::protocol::TType _etype38; - xfer += iprot->readListBegin(_etype38, _size35); - this->actions.resize(_size35); - uint32_t _i39; - for (_i39 = 0; _i39 < _size35; ++_i39) - { - xfer += this->actions[_i39].read(iprot); - } - xfer += iprot->readListEnd(); - } - this->__isset.actions = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 9: - if (ftype == ::apache::thrift::protocol::T_DOUBLE) { - xfer += iprot->readDouble(this->weight); - this->__isset.weight = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t RankingObject::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("RankingObject"); - - xfer += oprot->writeFieldBegin("objectID", ::apache::thrift::protocol::T_I64, 1); - xfer += oprot->writeI64(this->objectID); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("objectType", ::apache::thrift::protocol::T_I32, 2); - xfer += oprot->writeI32((int32_t)this->objectType); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("actorID", ::apache::thrift::protocol::T_I64, 3); - xfer += oprot->writeI64(this->actorID); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("createTime", ::apache::thrift::protocol::T_I64, 4); - xfer += oprot->writeI64(this->createTime); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("payloadIntMap", ::apache::thrift::protocol::T_MAP, 5); - { - xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_I16, ::apache::thrift::protocol::T_I64, static_cast(this->payloadIntMap.size())); - std::map ::const_iterator _iter40; - for (_iter40 = this->payloadIntMap.begin(); _iter40 != this->payloadIntMap.end(); ++_iter40) - { - xfer += oprot->writeI16(_iter40->first); - xfer += oprot->writeI64(_iter40->second); - } - xfer += oprot->writeMapEnd(); - } - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("payloadStrMap", ::apache::thrift::protocol::T_MAP, 6); - { - xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_I16, ::apache::thrift::protocol::T_STRING, static_cast(this->payloadStrMap.size())); - std::map ::const_iterator _iter41; - for (_iter41 = this->payloadStrMap.begin(); _iter41 != this->payloadStrMap.end(); ++_iter41) - { - xfer += oprot->writeI16(_iter41->first); - xfer += oprot->writeString(_iter41->second); - } - xfer += oprot->writeMapEnd(); - } - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("payloadVecMap", ::apache::thrift::protocol::T_MAP, 7); - { - xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_I16, ::apache::thrift::protocol::T_LIST, static_cast(this->payloadVecMap.size())); - std::map ::const_iterator _iter42; - for (_iter42 = this->payloadVecMap.begin(); _iter42 != this->payloadVecMap.end(); ++_iter42) - { - xfer += oprot->writeI16(_iter42->first); - { - xfer += oprot->writeListBegin(::apache::thrift::protocol::T_I64, static_cast(_iter42->second.size())); - std::vector ::const_iterator _iter43; - for (_iter43 = _iter42->second.begin(); _iter43 != _iter42->second.end(); ++_iter43) - { - xfer += oprot->writeI64((*_iter43)); - } - xfer += oprot->writeListEnd(); - } - } - xfer += oprot->writeMapEnd(); - } - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("actions", ::apache::thrift::protocol::T_LIST, 8); - { - xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->actions.size())); - std::vector ::const_iterator _iter44; - for (_iter44 = this->actions.begin(); _iter44 != this->actions.end(); ++_iter44) - { - xfer += (*_iter44).write(oprot); - } - xfer += oprot->writeListEnd(); - } - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("weight", ::apache::thrift::protocol::T_DOUBLE, 9); - xfer += oprot->writeDouble(this->weight); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - -void swap(RankingObject &a, RankingObject &b) { - using ::std::swap; - swap(a.objectID, b.objectID); - swap(a.objectType, b.objectType); - swap(a.actorID, b.actorID); - swap(a.createTime, b.createTime); - swap(a.payloadIntMap, b.payloadIntMap); - swap(a.payloadStrMap, b.payloadStrMap); - swap(a.payloadVecMap, b.payloadVecMap); - swap(a.actions, b.actions); - swap(a.weight, b.weight); - swap(a.__isset, b.__isset); -} - -RankingObject::RankingObject(const RankingObject& other45) { - objectID = other45.objectID; - objectType = other45.objectType; - actorID = other45.actorID; - createTime = other45.createTime; - payloadIntMap = other45.payloadIntMap; - payloadStrMap = other45.payloadStrMap; - payloadVecMap = other45.payloadVecMap; - actions = other45.actions; - weight = other45.weight; - __isset = other45.__isset; -} -RankingObject::RankingObject( RankingObject&& other46) { - objectID = std::move(other46.objectID); - objectType = std::move(other46.objectType); - actorID = std::move(other46.actorID); - createTime = std::move(other46.createTime); - payloadIntMap = std::move(other46.payloadIntMap); - payloadStrMap = std::move(other46.payloadStrMap); - payloadVecMap = std::move(other46.payloadVecMap); - actions = std::move(other46.actions); - weight = std::move(other46.weight); - __isset = std::move(other46.__isset); -} -RankingObject& RankingObject::operator=(const RankingObject& other47) { - objectID = other47.objectID; - objectType = other47.objectType; - actorID = other47.actorID; - createTime = other47.createTime; - payloadIntMap = other47.payloadIntMap; - payloadStrMap = other47.payloadStrMap; - payloadVecMap = other47.payloadVecMap; - actions = other47.actions; - weight = other47.weight; - __isset = other47.__isset; - return *this; -} -RankingObject& RankingObject::operator=(RankingObject&& other48) { - objectID = std::move(other48.objectID); - objectType = std::move(other48.objectType); - actorID = std::move(other48.actorID); - createTime = std::move(other48.createTime); - payloadIntMap = std::move(other48.payloadIntMap); - payloadStrMap = std::move(other48.payloadStrMap); - payloadVecMap = std::move(other48.payloadVecMap); - actions = std::move(other48.actions); - weight = std::move(other48.weight); - __isset = std::move(other48.__isset); - return *this; -} -void RankingObject::printTo(std::ostream& out) const { - using ::apache::thrift::to_string; - out << "RankingObject("; - out << "objectID=" << to_string(objectID); - out << ", " << "objectType=" << to_string(objectType); - out << ", " << "actorID=" << to_string(actorID); - out << ", " << "createTime=" << to_string(createTime); - out << ", " << "payloadIntMap=" << to_string(payloadIntMap); - out << ", " << "payloadStrMap=" << to_string(payloadStrMap); - out << ", " << "payloadVecMap=" << to_string(payloadVecMap); - out << ", " << "actions=" << to_string(actions); - out << ", " << "weight=" << to_string(weight); - out << ")"; -} - - -RankingStory::~RankingStory() noexcept { -} - - -void RankingStory::__set_storyID(const int64_t val) { - this->storyID = val; -} - -void RankingStory::__set_objects(const std::vector & val) { - this->objects = val; -} - -void RankingStory::__set_weight(const double val) { - this->weight = val; -} - -void RankingStory::__set_storyType(const RankingStoryType::type val) { - this->storyType = val; -} -std::ostream& operator<<(std::ostream& out, const RankingStory& obj) -{ - obj.printTo(out); - return out; -} - - -uint32_t RankingStory::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == ::apache::thrift::protocol::T_I64) { - xfer += iprot->readI64(this->storyID); - this->__isset.storyID = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 2: - if (ftype == ::apache::thrift::protocol::T_LIST) { - { - this->objects.clear(); - uint32_t _size49; - ::apache::thrift::protocol::TType _etype52; - xfer += iprot->readListBegin(_etype52, _size49); - this->objects.resize(_size49); - uint32_t _i53; - for (_i53 = 0; _i53 < _size49; ++_i53) - { - xfer += this->objects[_i53].read(iprot); - } - xfer += iprot->readListEnd(); - } - this->__isset.objects = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_DOUBLE) { - xfer += iprot->readDouble(this->weight); - this->__isset.weight = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 4: - if (ftype == ::apache::thrift::protocol::T_I32) { - int32_t ecast54; - xfer += iprot->readI32(ecast54); - this->storyType = (RankingStoryType::type)ecast54; - this->__isset.storyType = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t RankingStory::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("RankingStory"); - - xfer += oprot->writeFieldBegin("storyID", ::apache::thrift::protocol::T_I64, 1); - xfer += oprot->writeI64(this->storyID); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("objects", ::apache::thrift::protocol::T_LIST, 2); - { - xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->objects.size())); - std::vector ::const_iterator _iter55; - for (_iter55 = this->objects.begin(); _iter55 != this->objects.end(); ++_iter55) - { - xfer += (*_iter55).write(oprot); - } - xfer += oprot->writeListEnd(); - } - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("weight", ::apache::thrift::protocol::T_DOUBLE, 3); - xfer += oprot->writeDouble(this->weight); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("storyType", ::apache::thrift::protocol::T_I32, 4); - xfer += oprot->writeI32((int32_t)this->storyType); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - -void swap(RankingStory &a, RankingStory &b) { - using ::std::swap; - swap(a.storyID, b.storyID); - swap(a.objects, b.objects); - swap(a.weight, b.weight); - swap(a.storyType, b.storyType); - swap(a.__isset, b.__isset); -} - -RankingStory::RankingStory(const RankingStory& other56) { - storyID = other56.storyID; - objects = other56.objects; - weight = other56.weight; - storyType = other56.storyType; - __isset = other56.__isset; -} -RankingStory::RankingStory( RankingStory&& other57) { - storyID = std::move(other57.storyID); - objects = std::move(other57.objects); - weight = std::move(other57.weight); - storyType = std::move(other57.storyType); - __isset = std::move(other57.__isset); -} -RankingStory& RankingStory::operator=(const RankingStory& other58) { - storyID = other58.storyID; - objects = other58.objects; - weight = other58.weight; - storyType = other58.storyType; - __isset = other58.__isset; - return *this; -} -RankingStory& RankingStory::operator=(RankingStory&& other59) { - storyID = std::move(other59.storyID); - objects = std::move(other59.objects); - weight = std::move(other59.weight); - storyType = std::move(other59.storyType); - __isset = std::move(other59.__isset); - return *this; -} -void RankingStory::printTo(std::ostream& out) const { - using ::apache::thrift::to_string; - out << "RankingStory("; - out << "storyID=" << to_string(storyID); - out << ", " << "objects=" << to_string(objects); - out << ", " << "weight=" << to_string(weight); - out << ", " << "storyType=" << to_string(storyType); - out << ")"; -} - - -RankingResponse::~RankingResponse() noexcept { -} - - -void RankingResponse::__set_queryID(const int64_t val) { - this->queryID = val; -} - -void RankingResponse::__set_rankingStories(const std::vector & val) { - this->rankingStories = val; -} - -void RankingResponse::__set_objectCounts(const std::vector & val) { - this->objectCounts = val; -} - -void RankingResponse::__set_metadata(const std::string& val) { - this->metadata = val; -} -std::ostream& operator<<(std::ostream& out, const RankingResponse& obj) -{ - obj.printTo(out); - return out; -} - - -uint32_t RankingResponse::read(::apache::thrift::protocol::TProtocol* iprot) { - - ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - - while (true) - { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == ::apache::thrift::protocol::T_I64) { - xfer += iprot->readI64(this->queryID); - this->__isset.queryID = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 2: - if (ftype == ::apache::thrift::protocol::T_LIST) { - { - this->rankingStories.clear(); - uint32_t _size60; - ::apache::thrift::protocol::TType _etype63; - xfer += iprot->readListBegin(_etype63, _size60); - this->rankingStories.resize(_size60); - uint32_t _i64; - for (_i64 = 0; _i64 < _size60; ++_i64) - { - xfer += this->rankingStories[_i64].read(iprot); - } - xfer += iprot->readListEnd(); - } - this->__isset.rankingStories = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_LIST) { - { - this->objectCounts.clear(); - uint32_t _size65; - ::apache::thrift::protocol::TType _etype68; - xfer += iprot->readListBegin(_etype68, _size65); - this->objectCounts.resize(_size65); - uint32_t _i69; - for (_i69 = 0; _i69 < _size65; ++_i69) - { - xfer += iprot->readI32(this->objectCounts[_i69]); - } - xfer += iprot->readListEnd(); - } - this->__isset.objectCounts = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 4: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->metadata); - this->__isset.metadata = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t RankingResponse::write(::apache::thrift::protocol::TProtocol* oprot) const { - uint32_t xfer = 0; - ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("RankingResponse"); - - xfer += oprot->writeFieldBegin("queryID", ::apache::thrift::protocol::T_I64, 1); - xfer += oprot->writeI64(this->queryID); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("rankingStories", ::apache::thrift::protocol::T_LIST, 2); - { - xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->rankingStories.size())); - std::vector ::const_iterator _iter70; - for (_iter70 = this->rankingStories.begin(); _iter70 != this->rankingStories.end(); ++_iter70) - { - xfer += (*_iter70).write(oprot); - } - xfer += oprot->writeListEnd(); - } - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("objectCounts", ::apache::thrift::protocol::T_LIST, 3); - { - xfer += oprot->writeListBegin(::apache::thrift::protocol::T_I32, static_cast(this->objectCounts.size())); - std::vector ::const_iterator _iter71; - for (_iter71 = this->objectCounts.begin(); _iter71 != this->objectCounts.end(); ++_iter71) - { - xfer += oprot->writeI32((*_iter71)); - } - xfer += oprot->writeListEnd(); - } - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("metadata", ::apache::thrift::protocol::T_STRING, 4); - xfer += oprot->writeString(this->metadata); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - -void swap(RankingResponse &a, RankingResponse &b) { - using ::std::swap; - swap(a.queryID, b.queryID); - swap(a.rankingStories, b.rankingStories); - swap(a.objectCounts, b.objectCounts); - swap(a.metadata, b.metadata); - swap(a.__isset, b.__isset); -} - -RankingResponse::RankingResponse(const RankingResponse& other72) { - queryID = other72.queryID; - rankingStories = other72.rankingStories; - objectCounts = other72.objectCounts; - metadata = other72.metadata; - __isset = other72.__isset; -} -RankingResponse::RankingResponse( RankingResponse&& other73) { - queryID = std::move(other73.queryID); - rankingStories = std::move(other73.rankingStories); - objectCounts = std::move(other73.objectCounts); - metadata = std::move(other73.metadata); - __isset = std::move(other73.__isset); -} -RankingResponse& RankingResponse::operator=(const RankingResponse& other74) { - queryID = other74.queryID; - rankingStories = other74.rankingStories; - objectCounts = other74.objectCounts; - metadata = other74.metadata; - __isset = other74.__isset; - return *this; -} -RankingResponse& RankingResponse::operator=(RankingResponse&& other75) { - queryID = std::move(other75.queryID); - rankingStories = std::move(other75.rankingStories); - objectCounts = std::move(other75.objectCounts); - metadata = std::move(other75.metadata); - __isset = std::move(other75.__isset); - return *this; -} -void RankingResponse::printTo(std::ostream& out) const { - using ::apache::thrift::to_string; - out << "RankingResponse("; - out << "queryID=" << to_string(queryID); - out << ", " << "rankingStories=" << to_string(rankingStories); - out << ", " << "objectCounts=" << to_string(objectCounts); - out << ", " << "metadata=" << to_string(metadata); - out << ")"; -} - -} // namespace diff --git a/packages/feedsim/third_party/src/workloads/ranking/gen-cpp/ranking_types.h b/packages/feedsim/third_party/src/workloads/ranking/gen-cpp/ranking_types.h deleted file mode 100644 index 4ac63d7e..00000000 --- a/packages/feedsim/third_party/src/workloads/ranking/gen-cpp/ranking_types.h +++ /dev/null @@ -1,442 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.13.0) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -#ifndef ranking_TYPES_H -#define ranking_TYPES_H - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include "folly/small_vector.h" -#include "folly/container/F14Map.h" - -namespace ranking { - -struct RankingStoryType { - enum type { - STORY_TYPE_A = 0, - STORY_TYPE_B = 1, - STORY_TYPE_C = 2, - STORY_TYPE_D = 3, - STORY_TYPE_E = 4, - STORY_TYPE_F = 5, - STORY_TYPE_G = 6, - STORY_TYPE_H = 7, - STORY_TYPE_I = 8, - STORY_TYPE_J = 9, - STORY_TYPE_K = 10, - STORY_TYPE_L = 11, - STORY_TYPE_M = 12, - STORY_TYPE_N = 13, - STORY_TYPE_O = 14, - STORY_TYPE_P = 15, - STORY_TYPE_Q = 16, - STORY_TYPE_R = 17, - STORY_TYPE_S = 18, - STORY_TYPE_T = 19, - STORY_TYPE_U = 20, - STORY_TYPE_V = 21, - STORY_TYPE_W = 22, - STORY_TYPE_X = 23, - STORY_TYPE_Y = 24, - STORY_TYPE_Z = 25 - }; -}; - -extern const std::map _RankingStoryType_VALUES_TO_NAMES; - -std::ostream& operator<<(std::ostream& out, const RankingStoryType::type& val); - -std::string to_string(const RankingStoryType::type& val); - -struct RankingObjectType { - enum type { - OBJ_TYPE_A = 0, - OBJ_TYPE_B = 1, - OBJ_TYPE_C = 2, - OBJ_TYPE_D = 3, - OBJ_TYPE_E = 4, - OBJ_TYPE_F = 5, - OBJ_TYPE_G = 6, - OBJ_TYPE_H = 7, - OBJ_TYPE_I = 8, - OBJ_TYPE_J = 9, - OBJ_TYPE_K = 10, - OBJ_TYPE_L = 11, - OBJ_TYPE_M = 12, - OBJ_TYPE_N = 13, - OBJ_TYPE_O = 14, - OBJ_TYPE_P = 15, - OBJ_TYPE_Q = 16, - OBJ_TYPE_R = 17, - OBJ_TYPE_S = 18, - OBJ_TYPE_T = 19, - OBJ_TYPE_U = 20, - OBJ_TYPE_V = 21, - OBJ_TYPE_W = 22, - OBJ_TYPE_X = 23, - OBJ_TYPE_Y = 24, - OBJ_TYPE_Z = 25 - }; -}; - -extern const std::map _RankingObjectType_VALUES_TO_NAMES; - -std::ostream& operator<<(std::ostream& out, const RankingObjectType::type& val); - -std::string to_string(const RankingObjectType::type& val); - -typedef std::vector SmallListI64; - -typedef std::map RankingPayloadIntMap; - -typedef std::map RankingPayloadStringMap; - -typedef std::map RankingPayloadVecMap; - -class Payload; - -class Action; - -class RankingObject; - -class RankingStory; - -class RankingResponse; - -typedef struct _Payload__isset { - _Payload__isset() : message(false) {} - bool message :1; -} _Payload__isset; - -class Payload : public virtual ::apache::thrift::TBase { - public: - - Payload(const Payload&); - Payload(Payload&&); - Payload& operator=(const Payload&); - Payload& operator=(Payload&&); - Payload() : message() { - } - - virtual ~Payload() noexcept; - std::string message; - - _Payload__isset __isset; - - void __set_message(const std::string& val); - - bool operator == (const Payload & rhs) const - { - if (!(message == rhs.message)) - return false; - return true; - } - bool operator != (const Payload &rhs) const { - return !(*this == rhs); - } - - bool operator < (const Payload & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - - virtual void printTo(std::ostream& out) const; -}; - -void swap(Payload &a, Payload &b); - -std::ostream& operator<<(std::ostream& out, const Payload& obj); - -typedef struct _Action__isset { - _Action__isset() : type(false), timeUsec(false), timeMsec(false), actorID(false) {} - bool type :1; - bool timeUsec :1; - bool timeMsec :1; - bool actorID :1; -} _Action__isset; - -class Action : public virtual ::apache::thrift::TBase { - public: - - Action(const Action&); - Action(Action&&); - Action& operator=(const Action&); - Action& operator=(Action&&); - Action() : type(0), timeUsec(0), timeMsec(0), actorID(0) { - } - - virtual ~Action() noexcept; - int16_t type; - int64_t timeUsec; - int32_t timeMsec; - int64_t actorID; - - _Action__isset __isset; - - void __set_type(const int16_t val); - - void __set_timeUsec(const int64_t val); - - void __set_timeMsec(const int32_t val); - - void __set_actorID(const int64_t val); - - bool operator == (const Action & rhs) const - { - if (!(type == rhs.type)) - return false; - if (!(timeUsec == rhs.timeUsec)) - return false; - if (!(timeMsec == rhs.timeMsec)) - return false; - if (!(actorID == rhs.actorID)) - return false; - return true; - } - bool operator != (const Action &rhs) const { - return !(*this == rhs); - } - - bool operator < (const Action & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - - virtual void printTo(std::ostream& out) const; -}; - -void swap(Action &a, Action &b); - -std::ostream& operator<<(std::ostream& out, const Action& obj); - -typedef struct _RankingObject__isset { - _RankingObject__isset() : objectID(false), objectType(false), actorID(false), createTime(false), payloadIntMap(false), payloadStrMap(false), payloadVecMap(false), actions(false), weight(false) {} - bool objectID :1; - bool objectType :1; - bool actorID :1; - bool createTime :1; - bool payloadIntMap :1; - bool payloadStrMap :1; - bool payloadVecMap :1; - bool actions :1; - bool weight :1; -} _RankingObject__isset; - -class RankingObject : public virtual ::apache::thrift::TBase { - public: - - RankingObject(const RankingObject&); - RankingObject(RankingObject&&); - RankingObject& operator=(const RankingObject&); - RankingObject& operator=(RankingObject&&); - RankingObject() : objectID(0), objectType((RankingObjectType::type)0), actorID(0), createTime(0), weight(0) { - } - - virtual ~RankingObject() noexcept; - int64_t objectID; - RankingObjectType::type objectType; - int64_t actorID; - int64_t createTime; - RankingPayloadIntMap payloadIntMap; - RankingPayloadStringMap payloadStrMap; - RankingPayloadVecMap payloadVecMap; - std::vector actions; - double weight; - - _RankingObject__isset __isset; - - void __set_objectID(const int64_t val); - - void __set_objectType(const RankingObjectType::type val); - - void __set_actorID(const int64_t val); - - void __set_createTime(const int64_t val); - - void __set_payloadIntMap(const RankingPayloadIntMap& val); - - void __set_payloadStrMap(const RankingPayloadStringMap& val); - - void __set_payloadVecMap(const RankingPayloadVecMap& val); - - void __set_actions(const std::vector & val); - - void __set_weight(const double val); - - bool operator == (const RankingObject & rhs) const - { - if (!(objectID == rhs.objectID)) - return false; - if (!(objectType == rhs.objectType)) - return false; - if (!(actorID == rhs.actorID)) - return false; - if (!(createTime == rhs.createTime)) - return false; - if (!(payloadIntMap == rhs.payloadIntMap)) - return false; - if (!(payloadStrMap == rhs.payloadStrMap)) - return false; - if (!(payloadVecMap == rhs.payloadVecMap)) - return false; - if (!(actions == rhs.actions)) - return false; - if (!(weight == rhs.weight)) - return false; - return true; - } - bool operator != (const RankingObject &rhs) const { - return !(*this == rhs); - } - - bool operator < (const RankingObject & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - - virtual void printTo(std::ostream& out) const; -}; - -void swap(RankingObject &a, RankingObject &b); - -std::ostream& operator<<(std::ostream& out, const RankingObject& obj); - -typedef struct _RankingStory__isset { - _RankingStory__isset() : storyID(false), objects(false), weight(false), storyType(false) {} - bool storyID :1; - bool objects :1; - bool weight :1; - bool storyType :1; -} _RankingStory__isset; - -class RankingStory : public virtual ::apache::thrift::TBase { - public: - - RankingStory(const RankingStory&); - RankingStory(RankingStory&&); - RankingStory& operator=(const RankingStory&); - RankingStory& operator=(RankingStory&&); - RankingStory() : storyID(0), weight(0), storyType((RankingStoryType::type)0) { - } - - virtual ~RankingStory() noexcept; - int64_t storyID; - std::vector objects; - double weight; - RankingStoryType::type storyType; - - _RankingStory__isset __isset; - - void __set_storyID(const int64_t val); - - void __set_objects(const std::vector & val); - - void __set_weight(const double val); - - void __set_storyType(const RankingStoryType::type val); - - bool operator == (const RankingStory & rhs) const - { - if (!(storyID == rhs.storyID)) - return false; - if (!(objects == rhs.objects)) - return false; - if (!(weight == rhs.weight)) - return false; - if (!(storyType == rhs.storyType)) - return false; - return true; - } - bool operator != (const RankingStory &rhs) const { - return !(*this == rhs); - } - - bool operator < (const RankingStory & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - - virtual void printTo(std::ostream& out) const; -}; - -void swap(RankingStory &a, RankingStory &b); - -std::ostream& operator<<(std::ostream& out, const RankingStory& obj); - -typedef struct _RankingResponse__isset { - _RankingResponse__isset() : queryID(false), rankingStories(false), objectCounts(false), metadata(false) {} - bool queryID :1; - bool rankingStories :1; - bool objectCounts :1; - bool metadata :1; -} _RankingResponse__isset; - -class RankingResponse : public virtual ::apache::thrift::TBase { - public: - - RankingResponse(const RankingResponse&); - RankingResponse(RankingResponse&&); - RankingResponse& operator=(const RankingResponse&); - RankingResponse& operator=(RankingResponse&&); - RankingResponse() : queryID(0), metadata() { - } - - virtual ~RankingResponse() noexcept; - int64_t queryID; - std::vector rankingStories; - std::vector objectCounts; - std::string metadata; - - _RankingResponse__isset __isset; - - void __set_queryID(const int64_t val); - - void __set_rankingStories(const std::vector & val); - - void __set_objectCounts(const std::vector & val); - - void __set_metadata(const std::string& val); - - bool operator == (const RankingResponse & rhs) const - { - if (!(queryID == rhs.queryID)) - return false; - if (!(rankingStories == rhs.rankingStories)) - return false; - if (!(objectCounts == rhs.objectCounts)) - return false; - if (!(metadata == rhs.metadata)) - return false; - return true; - } - bool operator != (const RankingResponse &rhs) const { - return !(*this == rhs); - } - - bool operator < (const RankingResponse & ) const; - - uint32_t read(::apache::thrift::protocol::TProtocol* iprot); - uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; - - virtual void printTo(std::ostream& out) const; -}; - -void swap(RankingResponse &a, RankingResponse &b); - -std::ostream& operator<<(std::ostream& out, const RankingResponse& obj); - -} // namespace - -#endif diff --git a/packages/feedsim/third_party/src/workloads/ranking/icachebuster/CMakeLists.txt b/packages/feedsim/third_party/src/workloads/ranking/icachebuster/CMakeLists.txt new file mode 100644 index 00000000..050706c0 --- /dev/null +++ b/packages/feedsim/third_party/src/workloads/ranking/icachebuster/CMakeLists.txt @@ -0,0 +1,53 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates & Contributors +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.12) +find_package(Python3 COMPONENTS Interpreter REQUIRED) + +# ICacheBuster parameters +set(ICACHEBUSTER_NUM_SPLITS 24) +set(ICACHEBUSTER_NUM_METHODS 100000) + +execute_process( + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen_icache_buster.py + --num_methods "${ICACHEBUSTER_NUM_METHODS}" + --num_splits "${ICACHEBUSTER_NUM_SPLITS}" + --output_dir ${CMAKE_CURRENT_BINARY_DIR} +) +add_custom_target( + genicache ALL + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/ICacheBuster.cc + ${CMAKE_CURRENT_BINARY_DIR}/ICacheBuster.h) + +# Define ICacheBuster library target +file(GLOB icache_srclist "${CMAKE_CURRENT_BINARY_DIR}/ICacheBuster*") +add_library(icachebuster ${icache_srclist}) + +target_include_directories(icachebuster PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/ ${JEMALLOC_INCLUDE_DIR}) +target_compile_features(icachebuster PRIVATE cxx_std_11) +add_dependencies(icachebuster genicache) +target_compile_features(icachebuster PRIVATE cxx_std_11) + +find_program(GENGETOPT_EXECUTABLE gengetopt REQUIRED) +# Generate getopts for PointerChaseTest +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ICacheBusterTestCmdline.h + ${CMAKE_CURRENT_BINARY_DIR}/ICacheBusterTestCmdline.cc + COMMAND ${GENGETOPT_EXECUTABLE} + -i ${CMAKE_CURRENT_SOURCE_DIR}/ICacheBusterTestCmdline.ggo + -F ICacheBusterTestCmdline + --output-dir=${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ICacheBusterTestCmdline.ggo +) +add_custom_target( + icacheBusterTest_gengetopt ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ICacheBusterTestCmdline.h + ${CMAKE_CURRENT_BINARY_DIR}/ICacheBusterTestCmdline.cc +) +add_executable(ICacheBusterTest ICacheBusterTest.cc ${CMAKE_CURRENT_BINARY_DIR}/ICacheBusterTestCmdline.cc) +add_dependencies(ICacheBusterTest icacheBusterTest_gengetopt) +target_link_libraries(ICacheBusterTest icachebuster OLDISim::OLDISim) +target_include_directories(ICacheBusterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) \ No newline at end of file diff --git a/packages/feedsim/third_party/src/workloads/search/ICacheBusterTest.cc b/packages/feedsim/third_party/src/workloads/ranking/icachebuster/ICacheBusterTest.cc similarity index 100% rename from packages/feedsim/third_party/src/workloads/search/ICacheBusterTest.cc rename to packages/feedsim/third_party/src/workloads/ranking/icachebuster/ICacheBusterTest.cc diff --git a/packages/feedsim/third_party/src/workloads/search/ICacheBusterTestCmdline.ggo b/packages/feedsim/third_party/src/workloads/ranking/icachebuster/ICacheBusterTestCmdline.ggo similarity index 100% rename from packages/feedsim/third_party/src/workloads/search/ICacheBusterTestCmdline.ggo rename to packages/feedsim/third_party/src/workloads/ranking/icachebuster/ICacheBusterTestCmdline.ggo diff --git a/packages/feedsim/third_party/src/workloads/search/gen_icache_buster.py b/packages/feedsim/third_party/src/workloads/ranking/icachebuster/gen_icache_buster.py old mode 100755 new mode 100644 similarity index 100% rename from packages/feedsim/third_party/src/workloads/search/gen_icache_buster.py rename to packages/feedsim/third_party/src/workloads/ranking/icachebuster/gen_icache_buster.py diff --git a/packages/feedsim/third_party/src/workloads/ranking/pointerchase/CMakeLists.txt b/packages/feedsim/third_party/src/workloads/ranking/pointerchase/CMakeLists.txt new file mode 100644 index 00000000..dd5ddcb2 --- /dev/null +++ b/packages/feedsim/third_party/src/workloads/ranking/pointerchase/CMakeLists.txt @@ -0,0 +1,29 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates & Contributors +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.12) + +add_library(PointerChaser PointerChase.cc) + +find_program(GENGETOPT_EXECUTABLE gengetopt REQUIRED) +# Generate getopts for PointerChaseTest +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/PointerChaseTestCmdline.h + ${CMAKE_CURRENT_BINARY_DIR}/PointerChaseTestCmdline.cc + COMMAND ${GENGETOPT_EXECUTABLE} + -i ${CMAKE_CURRENT_SOURCE_DIR}/PointerChaseTestCmdline.ggo + -F PointerChaseTestCmdline + --output-dir=${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/PointerChaseTestCmdline.ggo +) +add_custom_target( + pointerChaseTest_gengetopt ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/PointerChaseTestCmdline.h + ${CMAKE_CURRENT_BINARY_DIR}/PointerChaseTestCmdline.cc +) +add_executable(PointerChaseTest PointerChaseTest.cc ${CMAKE_CURRENT_BINARY_DIR}/PointerChaseTestCmdline.cc) +add_dependencies(PointerChaseTest pointerChaseTest_gengetopt) +target_link_libraries(PointerChaseTest PointerChaser OLDISim::OLDISim) +target_include_directories(PointerChaseTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) \ No newline at end of file diff --git a/packages/feedsim/third_party/src/workloads/search/PointerChase.cc b/packages/feedsim/third_party/src/workloads/ranking/pointerchase/PointerChase.cc similarity index 100% rename from packages/feedsim/third_party/src/workloads/search/PointerChase.cc rename to packages/feedsim/third_party/src/workloads/ranking/pointerchase/PointerChase.cc diff --git a/packages/feedsim/third_party/src/workloads/search/PointerChase.h b/packages/feedsim/third_party/src/workloads/ranking/pointerchase/PointerChase.h similarity index 100% rename from packages/feedsim/third_party/src/workloads/search/PointerChase.h rename to packages/feedsim/third_party/src/workloads/ranking/pointerchase/PointerChase.h diff --git a/packages/feedsim/third_party/src/workloads/search/PointerChaseTest.cc b/packages/feedsim/third_party/src/workloads/ranking/pointerchase/PointerChaseTest.cc similarity index 100% rename from packages/feedsim/third_party/src/workloads/search/PointerChaseTest.cc rename to packages/feedsim/third_party/src/workloads/ranking/pointerchase/PointerChaseTest.cc diff --git a/packages/feedsim/third_party/src/workloads/search/PointerChaseTestCmdline.ggo b/packages/feedsim/third_party/src/workloads/ranking/pointerchase/PointerChaseTestCmdline.ggo similarity index 100% rename from packages/feedsim/third_party/src/workloads/search/PointerChaseTestCmdline.ggo rename to packages/feedsim/third_party/src/workloads/ranking/pointerchase/PointerChaseTestCmdline.ggo diff --git a/packages/feedsim/third_party/src/workloads/search/CMakeLists.txt b/packages/feedsim/third_party/src/workloads/search/CMakeLists.txt deleted file mode 100644 index ca387fde..00000000 --- a/packages/feedsim/third_party/src/workloads/search/CMakeLists.txt +++ /dev/null @@ -1,202 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -cmake_minimum_required(VERSION 3.12) -project(oldisim_search) - -find_package(Python3 COMPONENTS Interpreter REQUIRED) - -# ICacheBuster parameters -set(ICACHEBUSTER_NUM_SPLITS 24) -set(ICACHEBUSTER_NUM_METHODS 100000) - -find_program(GENGETOPT_EXECUTABLE gengetopt REQUIRED) - -# Generate getopts for LeafNode -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LeafNodeCmdline.h - ${CMAKE_CURRENT_BINARY_DIR}/LeafNodeCmdline.cc - COMMAND ${GENGETOPT_EXECUTABLE} - -i ${CMAKE_CURRENT_SOURCE_DIR}/LeafNodeCmdline.ggo - -F LeafNodeCmdline - --output-dir=${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/LeafNodeCmdline.ggo -) -add_custom_target( - leafnode_gengetopt ALL - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/LeafNodeCmdline.h - ${CMAKE_CURRENT_BINARY_DIR}/LeafNodeCmdline.cc -) -add_library(leafnodecmdline - ${CMAKE_CURRENT_BINARY_DIR}/LeafNodeCmdline.h - ${CMAKE_CURRENT_BINARY_DIR}/LeafNodeCmdline.cc) - -add_dependencies(leafnodecmdline leafnode_gengetopt) - - -# Generate ICacheBuster methods -#file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -execute_process( - COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen_icache_buster.py - --num_methods "${ICACHEBUSTER_NUM_METHODS}" - --num_splits "${ICACHEBUSTER_NUM_SPLITS}" - --output_dir ${CMAKE_CURRENT_BINARY_DIR} -) -add_custom_target( - genicache ALL - DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/ICacheBuster.cc - ${CMAKE_CURRENT_BINARY_DIR}/ICacheBuster.h) - -# Define ICacheBuster library target -file(GLOB icache_srclist "${CMAKE_CURRENT_BINARY_DIR}/ICacheBuster*") -add_library(icachebuster ${icache_srclist}) - -target_include_directories(icachebuster PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/ ${JEMALLOC_INCLUDE_DIR}) -target_compile_features(icachebuster PRIVATE cxx_std_11) -add_dependencies(icachebuster genicache) - -add_library(PointerChaser PointerChase.cc) -target_compile_features(icachebuster PRIVATE cxx_std_11) - - -# Build LeafNode binary -add_executable(LeafNode - LeafNode.cc - HistogramRandomSampler.cc) - -target_compile_features(LeafNode PRIVATE cxx_std_11) -target_include_directories(LeafNode - PUBLIC ${CMAKE_CURRENT_BINARY_DIR} - ${LIBEVENT_INCLUDE_DIR} ${JEMALLOC_INCLUDE_DIR}) -target_link_libraries(LeafNode - PRIVATE OLDISim::OLDISim icachebuster PointerChaser leafnodecmdline - PUBLIC Threads::Threads ${LIBEVENT_LIB} ${JEMALLOC_LIB}) - - -# Generate getopts for ParentNode -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ParentNodeCmdline.h - ${CMAKE_CURRENT_BINARY_DIR}/ParentNodeCmdline.cc - COMMAND ${GENGETOPT_EXECUTABLE} - -i ${CMAKE_CURRENT_SOURCE_DIR}/ParentNodeCmdline.ggo - -F ParentNodeCmdline - --output-dir=${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ParentNodeCmdline.ggo -) -add_custom_target( - parentnode_gengetopt ALL - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ParentNodeCmdline.h - ${CMAKE_CURRENT_BINARY_DIR}/ParentNodeCmdline.cc -) -add_library(parentnodecmdline - ${CMAKE_CURRENT_BINARY_DIR}/ParentNodeCmdline.h - ${CMAKE_CURRENT_BINARY_DIR}/ParentNodeCmdline.cc) - -add_dependencies(parentnodecmdline parentnode_gengetopt) - - -# Build ParentNode binary -add_executable(ParentNode - ParentNode.cc) -target_compile_features(ParentNode PRIVATE cxx_std_11) -target_include_directories( - ParentNode - PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/ - ${LIBEVENT_INCLUDE_DIR} - ${JEMALLOC_INCLUDE_DIR}) -target_link_libraries( - ParentNode - PRIVATE OLDISim::OLDISim parentnodecmdline - PUBLIC Threads::Threads ${LIBEVENT_LIB} ${JEMALLOC_LIB}) - - - -# Generate getops for LoadBalancerNode -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LoadBalancerNodeCmdline.h - ${CMAKE_CURRENT_BINARY_DIR}/LoadBalancerNodeCmdline.cc - COMMAND ${GENGETOPT_EXECUTABLE} - -i ${CMAKE_CURRENT_SOURCE_DIR}/LoadBalancerNodeCmdline.ggo - -F LoadBalancerNodeCmdline - --output-dir=${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/LoadBalancerNodeCmdline.ggo -) -add_custom_target( - LoadBalancernode_gengetopt ALL - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/LoadBalancerNodeCmdline.h - ${CMAKE_CURRENT_BINARY_DIR}/LoadBalancerNodeCmdline.cc -) -add_library(LoadBalancernodecmdline - ${CMAKE_CURRENT_BINARY_DIR}/LoadBalancerNodeCmdline.h - ${CMAKE_CURRENT_BINARY_DIR}/LoadBalancerNodeCmdline.cc) - -add_dependencies(LoadBalancernodecmdline LoadBalancernode_gengetopt) - - -# Build LoadBalancerNode binary -add_executable(LoadBalancerNode - LoadBalancerNode.cc) -target_compile_features(LoadBalancerNode PRIVATE cxx_std_11) -target_include_directories( - LoadBalancerNode - PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/ - ${LIBEVENT_INCLUDE_DIR} - ${JEMALLOC_INCLUDE_DIR}) - -target_link_libraries( - LoadBalancerNode - PRIVATE OLDISim::OLDISim LoadBalancernodecmdline - PUBLIC Threads::Threads ${LIBEVENT_LIB} ${JEMALLOC_LIB}) - - -# Generate getops for DriverNode -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/DriverNodeCmdline.h - ${CMAKE_CURRENT_BINARY_DIR}/DriverNodeCmdline.cc - COMMAND ${GENGETOPT_EXECUTABLE} - -i ${CMAKE_CURRENT_SOURCE_DIR}/DriverNodeCmdline.ggo - -F DriverNodeCmdline - --output-dir=${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/DriverNodeCmdline.ggo -) -add_custom_target( - Drivernode_gengetopt ALL - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/DriverNodeCmdline.h - ${CMAKE_CURRENT_BINARY_DIR}/DriverNodeCmdline.cc -) -add_library(Drivernodecmdline - ${CMAKE_CURRENT_BINARY_DIR}/DriverNodeCmdline.h - ${CMAKE_CURRENT_BINARY_DIR}/DriverNodeCmdline.cc) - -add_dependencies(Drivernodecmdline Drivernode_gengetopt) - - -# Build DriverNode binary -add_executable(DriverNode - DriverNode.cc) -target_compile_features(DriverNode PRIVATE cxx_std_11) -target_include_directories( - DriverNode - PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/ - ${LIBEVENT_INCLUDE_DIR} - ${JEMALLOC_INCLUDE_DIR}) - -target_link_libraries( - DriverNode - PRIVATE OLDISim::OLDISim Drivernodecmdline - PUBLIC Threads::Threads ${LIBEVENT_LIB} ${JEMALLOC_LIB}) - - -# Build LeafKernel binary -add_executable(LeafKernel - LeafKernel.cc - PointerChase.cc) -target_compile_features(LeafKernel PRIVATE cxx_std_11) -target_include_directories(LeafKernel - PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/ - ${JEMALLOC_INCLUDE_DIR}) -target_link_libraries(LeafKernel - PRIVATE OLDISim::OLDISim icachebuster ${JEMALLOC_LIB}) diff --git a/packages/feedsim/third_party/src/workloads/search/DriverNode.cc b/packages/feedsim/third_party/src/workloads/search/DriverNode.cc deleted file mode 100644 index 3f33e733..00000000 --- a/packages/feedsim/third_party/src/workloads/search/DriverNode.cc +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// 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. - -#include -#include -#include - -#include - -#include "oldisim/ChildConnectionStats.h" -#include "oldisim/DriverNode.h" -#include "oldisim/Log.h" -#include "oldisim/NodeThread.h" -#include "oldisim/ResponseContext.h" -#include "oldisim/TestDriver.h" -#include "oldisim/Util.h" - -#include "DriverNodeCmdline.h" -#include "RequestTypes.h" -#include "Util.h" - -// Shared configuration flags -gengetopt_args_info args; - -// Program constants -const int kMaxRequestSize = 8192; -const int kRecomputeQPSPeriod = 5; - -struct ThreadData { - std::string random_string; - double qps_per_thread; - uint64_t search_request_delay; // This is per thread - oldisim::TestDriver* test_driver; - event* recompute_qps_timer; -}; - -// Specific timer handler to recompute inter-request delays for QPS -void AddRecomputeDelayTimer(ThreadData& this_thread); -void RecomputeDelayTimerHandler(evutil_socket_t listener, int16_t flags, - void* arg); - -// Declarations of handlers -void ThreadStartup(oldisim::NodeThread& thread, - oldisim::TestDriver& test_driver, - std::vector& thread_data); -void MakeRequest(oldisim::NodeThread& thread, oldisim::TestDriver& test_driver, - std::vector& thread_data); - -void AddRecomputeDelayTimer(ThreadData& this_thread) { - timeval t = {kRecomputeQPSPeriod, 0}; - evtimer_add(this_thread.recompute_qps_timer, &t); -} - -void RecomputeDelayTimerHandler(evutil_socket_t listener, int16_t flags, - void* arg) { - ThreadData* this_thread = reinterpret_cast(arg); - const oldisim::ChildConnectionStats& stats = - this_thread->test_driver->GetConnectionStats(); - - // Get QPS for last stats period - double qps = - static_cast(stats.query_counts_.at(search::kSearchRequestType)) / - (stats.end_time_ - stats.start_time_) * 1000000000; - - // Adjust delay based on QPS - this_thread->search_request_delay *= (qps / this_thread->qps_per_thread); - - AddRecomputeDelayTimer(*this_thread); -} - -void ThreadStartup(oldisim::NodeThread& thread, - oldisim::TestDriver& test_driver, - std::vector& thread_data) { - ThreadData& this_thread = thread_data[thread.get_thread_num()]; - - // Initialize random string with random bits - this_thread.random_string = RandomString(kMaxRequestSize); - - // Store pointer to test_driver - this_thread.test_driver = &test_driver; - - // If user gave QPS target, initialize QPS modulation - if (args.qps_arg != 0) { - this_thread.qps_per_thread = (static_cast(args.qps_arg)) / - args.threads_arg; - this_thread.recompute_qps_timer = evtimer_new( - thread.get_event_base(), RecomputeDelayTimerHandler, &this_thread); - AddRecomputeDelayTimer(this_thread); - this_thread.search_request_delay = 1000000 / this_thread.qps_per_thread; - } else { - this_thread.search_request_delay = 0; - } -} - -void MakeRequest(oldisim::NodeThread& thread, oldisim::TestDriver& test_driver, - std::vector& thread_data) { - ThreadData& this_thread = thread_data[thread.get_thread_num()]; - - test_driver.SendRequest(search::kSearchRequestType, - this_thread.random_string.c_str(), - 3000, this_thread.search_request_delay); -} - -int main(int argc, char** argv) { - // Parse arguments - if (cmdline_parser(argc, argv, &args) != 0) { - DIE("cmdline_parser failed"); - } - - // Set logging level - for (unsigned int i = 0; i < args.verbose_given; i++) { - log_level = (log_level_t)(static_cast(log_level) - 1); - } - if (args.quiet_given) { - log_level = QUIET; - } - - // Check requried arguments - if (!args.server_given) { - DIE("--server must be specified."); - } - - std::string hostname; - int port; - search::ParseServerAddress(args.server_arg, hostname, port); - - // Make storage for thread variables - std::vector thread_data(args.threads_arg); - - oldisim::DriverNode driver_node(hostname, port); - - driver_node.SetThreadStartupCallback( - std::bind(ThreadStartup, std::placeholders::_1, std::placeholders::_2, - std::ref(thread_data))); - driver_node.SetMakeRequestCallback( - std::bind(MakeRequest, std::placeholders::_1, std::placeholders::_2, - std::ref(thread_data))); - driver_node.RegisterRequestType(search::kSearchRequestType); - - // Enable remote monitoring - driver_node.EnableMonitoring(args.monitor_port_arg); - - driver_node.Run(args.threads_arg, args.affinity_given, args.connections_arg, - args.depth_arg); - - return 0; -} diff --git a/packages/feedsim/third_party/src/workloads/search/DriverNodeCmdline.ggo b/packages/feedsim/third_party/src/workloads/search/DriverNodeCmdline.ggo deleted file mode 100644 index 7e65a184..00000000 --- a/packages/feedsim/third_party/src/workloads/search/DriverNodeCmdline.ggo +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2015 Google Inc. All Rights Reserved. -# 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. - -package "DriverNode" -version "0.1" -usage "DriverNode [options]" -description "Test driving node for search" - -args "-c cc --show-required -C --default-optional -l" - -option "verbose" v "Verbosity. Repeat for more verbose." multiple -option "quiet" - "Disable log messages." - -option "threads" - "Number of threads to spawn." int default="1" -option "server" - "Address of parent node hostname[:port]." string -option "connections" - "Connections to establish per thread." int default="1" -option "depth" - "Maximum depth to pipeline requests per thread." int default="1" -option "qps" - "Rate to send requests at. 0 means send as fast as it can." float default="0" - -option "monitor_port" - "Port to run monitoring server on." int default="7777" - -option "affinity" - "Set distinct CPU affinity for threads, round-robin" diff --git a/packages/feedsim/third_party/src/workloads/search/HistogramRandomSampler.cc b/packages/feedsim/third_party/src/workloads/search/HistogramRandomSampler.cc deleted file mode 100644 index fbd72743..00000000 --- a/packages/feedsim/third_party/src/workloads/search/HistogramRandomSampler.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// -// 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. - -#include -#include -#include -#include - -#include "HistogramRandomSampler.h" - -HistogramRandomSampler::HistogramRandomSampler() : count_sum_(0) { InitRNG(); } - -HistogramRandomSampler::HistogramRandomSampler(std::string histogram_file) - : count_sum_(0) { - // Initialize RNG seed - InitRNG(); - - // Read the file, which is a tab delimited file of - // START END COUNT - std::ifstream input_file(histogram_file.c_str()); - std::string line; - - while (std::getline(input_file, line)) { - int start, end, count; - std::istringstream ss(line); - ss >> start >> end >> count; - - AddBin(start, end, count); - } -} - -void HistogramRandomSampler::AddBin(int start, int end, int count) { - bins_.push_back(Bin({start, end, count})); - count_sum_ += count; -} - -int HistogramRandomSampler::Sample() { - int r = rng_() % count_sum_; - // Locate the bin to use - for (const auto& bin : bins_) { - if (r < bin.count) { - return (rng_() % (bin.end - bin.start)) + bin.start; - } else { - r -= bin.count; - } - } - - assert(false); - return -1; -} - -void HistogramRandomSampler::InitRNG() { - unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); - rng_.seed(seed); -} diff --git a/packages/feedsim/third_party/src/workloads/search/HistogramRandomSampler.h b/packages/feedsim/third_party/src/workloads/search/HistogramRandomSampler.h deleted file mode 100644 index 9a94aedf..00000000 --- a/packages/feedsim/third_party/src/workloads/search/HistogramRandomSampler.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// -// 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. -#pragma once - -#include -#include -#include - -class HistogramRandomSampler { - public: - HistogramRandomSampler(); - explicit HistogramRandomSampler(std::string histogram_file); - void AddBin(int start, int end, int count); - int Sample(); - - private: - void InitRNG(); - struct Bin { - int start; - int end; - int count; - }; - std::vector bins_; - int count_sum_; - std::default_random_engine rng_; -}; diff --git a/packages/feedsim/third_party/src/workloads/search/LeafKernel.cc b/packages/feedsim/third_party/src/workloads/search/LeafKernel.cc deleted file mode 100644 index eab15d92..00000000 --- a/packages/feedsim/third_party/src/workloads/search/LeafKernel.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// -// 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. - -#include - -#include "oldisim/Util.h" -#include "PointerChase.h" -#include "ICacheBuster.h" - -const int kPointerChaseSize = 10000000; -const int kICacheBusterSize = 100000; -const int kNumNops = 6; -const int kNumNopIterations = 60; -const int kNumIterations = 100000000; - -int main(int argc, char** argv) { - // Create pointer chaser - search::PointerChase chaser(kPointerChaseSize); - - // Create i cache chaser - ICacheBuster buster(kICacheBusterSize); - - uint64_t start_time = GetTimeAccurateNano(); - for (int i = 0; i < kNumIterations; i++) { - buster.RunNextMethod(); - chaser.Chase(1); - for (int j = 0; j < kNumNopIterations; j++) { - for (int k = 0; k < kNumNops; k++) { - asm volatile("nop"); - } - } - } - uint64_t end_time = GetTimeAccurateNano(); - - std::cout << "Time per iteration: " - << static_cast(end_time - start_time) / - (static_cast(kNumIterations)) - << " ns" << std::endl; - - return 0; -} - diff --git a/packages/feedsim/third_party/src/workloads/search/LeafNode.cc b/packages/feedsim/third_party/src/workloads/search/LeafNode.cc deleted file mode 100644 index 539e12f0..00000000 --- a/packages/feedsim/third_party/src/workloads/search/LeafNode.cc +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// 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. - -#include -#include - -#include -#include -#include - -#include "oldisim/LeafNodeServer.h" -#include "oldisim/NodeThread.h" -#include "oldisim/ParentConnection.h" -#include "oldisim/QueryContext.h" -#include "oldisim/Util.h" - -#include "ICacheBuster.h" -#include "LeafNodeCmdline.h" -#include "PointerChase.h" -#include "RequestTypes.h" - -// Shared configuration flags -static gengetopt_args_info args; - -// Program constants -const int kPointerChaseSize = 10000000; -const int kICacheBusterSize = 100000; -const int kNumNops = 6; -const int kNumNopIterations = 60; -const int kNumIterations = 100000000; -const int kMaxResponseSize = 8192; - -struct ThreadData { - std::unique_ptr pointer_chaser; - std::unique_ptr icache_buster; - std::default_random_engine rng; - std::gamma_distribution latency_distribution; - std::string random_string; -}; - -void ThreadStartup( - oldisim::NodeThread& thread, - std::vector& thread_data) { - ThreadData& this_thread = thread_data[thread.get_thread_num()]; - - // Initialize of I$Buster - this_thread.pointer_chaser.reset(new search::PointerChase(kPointerChaseSize)); - - // Initialize PointerChaser - this_thread.icache_buster.reset(new ICacheBuster(kICacheBusterSize)); - - // Initialize RNG and latency sampler - unsigned node_seed; - if (args.node_seed_given) { - node_seed = static_cast(args.node_seed_arg); - } else { - node_seed = std::chrono::system_clock::now().time_since_epoch().count(); - } - this_thread.rng.seed(node_seed); - - const double alpha = 0.7; - const double beta = 20000; - this_thread.latency_distribution = - std::gamma_distribution(alpha, beta); - - // Initialize random string with random bits - this_thread.random_string = RandomString(kMaxResponseSize); -} - -void SearchRequestHandler( - oldisim::NodeThread& thread, - oldisim::QueryContext& context, - std::vector& thread_data) { - ThreadData& this_thread = thread_data[thread.get_thread_num()]; - search::PointerChase& chaser = *this_thread.pointer_chaser; - ICacheBuster& buster = *this_thread.icache_buster; - - // Sample distribution for work - int num_iterations = this_thread.latency_distribution(this_thread.rng); - - // Spin loop of work here - for (int i = 0; i < num_iterations; i++) { - buster.RunNextMethod(); - chaser.Chase(1); - for (int j = 0; j < kNumNopIterations; j++) { - for (int k = 0; k < kNumNops; k++) { - asm volatile("nop"); - } - } - } - - int response_size = 2048; - context.SendResponse( - reinterpret_cast(this_thread.random_string.c_str()), - response_size); -} - -int main(int argc, char** argv) { - // Parse arguments - if (cmdline_parser(argc, argv, &args) != 0) { - DIE("cmdline_parser failed"); - } - - // Set logging level - for (unsigned int i = 0; i < args.verbose_given; i++) { - log_level = (log_level_t)(static_cast(log_level) - 1); - } - if (args.quiet_given) { - log_level = QUIET; - } - - // Make storage for thread variables - std::vector thread_data(args.threads_arg); - - oldisim::LeafNodeServer server(args.port_arg); - - server.SetThreadStartupCallback( - std::bind(ThreadStartup, std::placeholders::_1, std::ref(thread_data))); - server.RegisterQueryCallback( - search::kSearchRequestType, - std::bind( - SearchRequestHandler, - std::placeholders::_1, - std::placeholders::_2, - std::ref(thread_data))); - - server.SetNumThreads(args.threads_arg); - server.SetThreadPinning(!args.noaffinity_given); - server.SetThreadLoadBalancing(!args.noloadbalance_given); - - // Enable remote monitoring - server.EnableMonitoring(args.monitor_port_arg); - - server.Run(); - - return 0; -} diff --git a/packages/feedsim/third_party/src/workloads/search/LeafNodeCmdline.ggo b/packages/feedsim/third_party/src/workloads/search/LeafNodeCmdline.ggo deleted file mode 100644 index edae7926..00000000 --- a/packages/feedsim/third_party/src/workloads/search/LeafNodeCmdline.ggo +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2015 Google Inc. All Rights Reserved. -# -# 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. - -package "LeafNode" -version "0.1" -usage "LeafNode [options]" -description "Sample web search workload: leaf node" - -args "-c cc --show-required -C --default-optional -l" - -option "verbose" v "Verbosity. Repeat for more verbose." multiple -option "quiet" - "Disable log messages." - -option "threads" - "Number of threads to use for serving." int default="1" -option "port" - "Port to run server on." int default="11222" -option "monitor_port" - "Port to run monitoring server on." int default="8888" -option "node_seed" - "Seed for random number generator. If not provided, current time will be used." long optional -option "noaffinity" - "Specify to disable thread pinning" -option "noloadbalance" - "Specify to disable thread load balancing" diff --git a/packages/feedsim/third_party/src/workloads/search/LoadBalancerNode.cc b/packages/feedsim/third_party/src/workloads/search/LoadBalancerNode.cc deleted file mode 100644 index 94349b2a..00000000 --- a/packages/feedsim/third_party/src/workloads/search/LoadBalancerNode.cc +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// -// 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. - -#include -#include - -#include -#include -#include -#include - -#include "oldisim/FanoutManager.h" -#include "oldisim/NodeThread.h" -#include "oldisim/ParentConnection.h" -#include "oldisim/ParentNodeServer.h" -#include "oldisim/QueryContext.h" -#include "oldisim/Util.h" - -#include "LoadBalancerNodeCmdline.h" -#include "RequestTypes.h" -#include "Util.h" - -// Shared configuration flags -static gengetopt_args_info args; - -// Program constants -const int kMaxLeafRequestSize = 8 * 1024; -const int kMaxResponseSize = 512 * 1024; - -struct ThreadData { - std::default_random_engine rng; - std::vector parent_connection_depths; -}; - -// Declarations of handlers -void ThreadStartup(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, - std::vector& thread_data); -void SearchRequestHandler(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, - oldisim::QueryContext& context, - std::vector& thread_data); -void SearchRequestFanoutDone(oldisim::QueryContext& originating_query, - const oldisim::FanoutReplyTracker& results, - ThreadData& this_thread, int parent_node_index); - -void ThreadStartup(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, - std::vector& thread_data) { - ThreadData& this_thread = thread_data[thread.get_thread_num()]; - - // Create child connections - for (int i = 0; i < args.parent_given; i++) { - fanout_manager.MakeChildConnections(i, args.connections_arg); - } - - // Initialize per-thread RNG - unsigned seed = std::chrono::system_clock::now().time_since_epoch().count() + - thread.get_thread_num(); - this_thread.rng.seed(seed); - - // Create # of outstanding requests structure for load balancing - this_thread.parent_connection_depths.resize(args.parent_given); -} - -void SearchRequestHandler(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, - oldisim::QueryContext& context, - std::vector& thread_data) { - ThreadData& this_thread = thread_data[thread.get_thread_num()]; - - // Find least loaded parent - int parent_node_index = - std::min_element(this_thread.parent_connection_depths.begin(), - this_thread.parent_connection_depths.end()) - - this_thread.parent_connection_depths.begin(); - - // Set up fanout structure to everyone - oldisim::FanoutRequest request; - request.child_node_id = - parent_node_index; // this_thread.rng() % args.parent_given; - request.request_type = search::kSearchRequestType; - request.request_data = context.payload; - request.request_data_length = context.payload_length; - - fanout_manager.Fanout(std::move(context), &request, 1, - std::bind(SearchRequestFanoutDone, - std::placeholders::_1, - std::placeholders::_2, - std::ref(this_thread), parent_node_index)); - this_thread.parent_connection_depths[parent_node_index]++; -} - -void SearchRequestFanoutDone(oldisim::QueryContext& originating_query, - const oldisim::FanoutReplyTracker& results, - ThreadData& this_thread, int parent_node_index) { - // Finally send back the data - originating_query.SendResponse(results.replies[0].reply_data.get(), - results.replies[0].reply_data_length); - this_thread.parent_connection_depths[parent_node_index]--; -} - -int main(int argc, char** argv) { - // Parse arguments - if (cmdline_parser(argc, argv, &args) != 0) { - DIE("cmdline_parser failed"); - } - - // Set logging level - for (unsigned int i = 0; i < args.verbose_given; i++) { - log_level = (log_level_t)(static_cast(log_level) - 1); - } - if (args.quiet_given) { - log_level = QUIET; - } - - // Check for parent servers - if (args.parent_given == 0) { - DIE("--parent must be specified."); - } - - // Make storage for thread variables - std::vector thread_data(args.threads_arg); - - oldisim::ParentNodeServer server(args.port_arg); - - server.SetThreadStartupCallback( - std::bind(ThreadStartup, std::placeholders::_1, std::placeholders::_2, - std::ref(thread_data))); - server.RegisterQueryCallback( - search::kSearchRequestType, - std::bind(SearchRequestHandler, std::placeholders::_1, - std::placeholders::_2, std::placeholders::_3, - std::ref(thread_data))); - server.RegisterRequestType(search::kSearchRequestType); - - // Add parent nodes - for (int i = 0; i < args.parent_given; i++) { - std::string hostname; - int port; - search::ParseServerAddress(args.parent_arg[i], hostname, port); - - server.AddChildNode(hostname, port); - } - - // Enable remote monitoring - server.EnableMonitoring(args.monitor_port_arg); - - server.Run(args.threads_arg, true); - - return 0; -} diff --git a/packages/feedsim/third_party/src/workloads/search/LoadBalancerNodeCmdline.ggo b/packages/feedsim/third_party/src/workloads/search/LoadBalancerNodeCmdline.ggo deleted file mode 100644 index 7c872806..00000000 --- a/packages/feedsim/third_party/src/workloads/search/LoadBalancerNodeCmdline.ggo +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2015 Google Inc. All Rights Reserved. -# -# 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. - -package "LoadBalancerNode" -version "0.1" -usage "LoadBalancerNode [options]" -description "Sample web search workload: load balancer node" - -args "-c cc --show-required -C --default-optional -l" - -option "verbose" v "Verbosity. Repeat for more verbose." multiple -option "quiet" - "Disable log messages." - -option "threads" - "Number of threads to use for serving." int default="1" -option "port" - "Port to run server on." int default="11222" -option "parent" - "search parent server hostname[:port]. Repeat to specify multiple servers." string multiple -option "monitor_port" - "Port to run monitoring server on." int default="8888" -option "connections" - "Number of connections per thread per leaf." int default="1" diff --git a/packages/feedsim/third_party/src/workloads/search/NopLoop.cc b/packages/feedsim/third_party/src/workloads/search/NopLoop.cc deleted file mode 100644 index c66ce6b4..00000000 --- a/packages/feedsim/third_party/src/workloads/search/NopLoop.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// -// 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. - -#include -#include - -#include "oldisim/Util.h" - -const int kNumNops = 6; -const uint64_t kNumIterations = 100000000; - -int main(int argc, char** argv) { - uint64_t start_time = GetTimeAccurateNano(); - for (uint64_t i = 0; i < kNumIterations; i++) { - for (int j = 0; j < kNumNops; j++) { - asm volatile("nop"); - } - } - uint64_t end_time = GetTimeAccurateNano(); - - std::cout << "Time per iteration: " - << static_cast(end_time - start_time) / - (static_cast(kNumIterations)) - << " ns" << std::endl; - - return 0; -} - diff --git a/packages/feedsim/third_party/src/workloads/search/ParentNode.cc b/packages/feedsim/third_party/src/workloads/search/ParentNode.cc deleted file mode 100644 index 1241bd60..00000000 --- a/packages/feedsim/third_party/src/workloads/search/ParentNode.cc +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// 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. - -#include -#include - -#include - -#include "oldisim/FanoutManager.h" -#include "oldisim/LeafNodeServer.h" -#include "oldisim/NodeThread.h" -#include "oldisim/ParentConnection.h" -#include "oldisim/ParentNodeServer.h" -#include "oldisim/QueryContext.h" -#include "oldisim/Util.h" - -#include "ParentNodeCmdline.h" -#include "RequestTypes.h" -#include "Util.h" - -// Shared configuration flags -static gengetopt_args_info args; - -// Program constants -const int kMaxLeafRequestSize = 8 * 1024; -const int kMaxResponseSize = 512 * 1024; - -struct ThreadData { - std::string random_string; -}; - -// Declarations of handlers -void ThreadStartup(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, - std::vector& thread_data); -void SearchRequestHandler(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, - oldisim::QueryContext& context, - std::vector& thread_data); -void SearchRequestFanoutDone(oldisim::QueryContext& originating_query, - const oldisim::FanoutReplyTracker& results, - ThreadData& this_thread); - -void ThreadStartup(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, - std::vector& thread_data) { - ThreadData& this_thread = thread_data[thread.get_thread_num()]; - - // Create child connections - for (int i = 0; i < args.leaf_given; i++) { - fanout_manager.MakeChildConnections(i, args.connections_arg); - } - - // Initialize random string with random bits - this_thread.random_string = RandomString(kMaxResponseSize); -} - -void SearchRequestHandler(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, - oldisim::QueryContext& context, - std::vector& thread_data) { - ThreadData& this_thread = thread_data[thread.get_thread_num()]; - - // Set up fanout structure to everyone - oldisim::FanoutRequest request; - request.request_type = search::kSearchRequestType; - request.request_data = this_thread.random_string.c_str(); - request.request_data_length = 3500; - - fanout_manager.FanoutAll( - std::move(context), request, - std::bind(SearchRequestFanoutDone, std::placeholders::_1, - std::placeholders::_2, std::ref(this_thread))); -} - -void SearchRequestFanoutDone(oldisim::QueryContext& originating_query, - const oldisim::FanoutReplyTracker& results, - ThreadData& this_thread) { - // Finally send back the data - originating_query.SendResponse( - reinterpret_cast(this_thread.random_string.c_str()), - 15000); -} - -int main(int argc, char** argv) { - // Parse arguments - if (cmdline_parser(argc, argv, &args) != 0) { - DIE("cmdline_parser failed"); - } - - // Set logging level - for (unsigned int i = 0; i < args.verbose_given; i++) { - log_level = (log_level_t)(static_cast(log_level) - 1); - } - if (args.quiet_given) { - log_level = QUIET; - } - - // Check for leaf servers - if (args.leaf_given == 0) { - DIE("--leaf must be specified."); - } - - // Make storage for thread variables - std::vector thread_data(args.threads_arg); - - oldisim::ParentNodeServer server(args.port_arg); - - server.SetThreadStartupCallback( - std::bind(ThreadStartup, std::placeholders::_1, std::placeholders::_2, - std::ref(thread_data))); - server.RegisterQueryCallback( - search::kSearchRequestType, - std::bind(SearchRequestHandler, std::placeholders::_1, - std::placeholders::_2, std::placeholders::_3, - std::ref(thread_data))); - server.RegisterRequestType(search::kSearchRequestType); - - // Add leaf nodes - for (int i = 0; i < args.leaf_given; i++) { - std::string hostname; - int port; - search::ParseServerAddress(args.leaf_arg[i], hostname, port); - - server.AddChildNode(hostname, port); - } - - // Enable remote monitoring - server.EnableMonitoring(args.monitor_port_arg); - - server.Run(args.threads_arg, true); - - return 0; -} - diff --git a/packages/feedsim/third_party/src/workloads/search/ParentNodeCmdline.ggo b/packages/feedsim/third_party/src/workloads/search/ParentNodeCmdline.ggo deleted file mode 100644 index b1a8073a..00000000 --- a/packages/feedsim/third_party/src/workloads/search/ParentNodeCmdline.ggo +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2015 Google Inc. All Rights Reserved. -# 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. - -package "ParentNode" -version "0.1" -usage "ParentNode [options]" -description "Sample web search workload: parent node" - -args "-c cc --show-required -C --default-optional -l" - -option "verbose" v "Verbosity. Repeat for more verbose." multiple -option "quiet" - "Disable log messages." - -option "threads" - "Number of threads to use for serving." int default="1" -option "port" - "Port to run server on." int default="11333" -option "leaf" - "search leaf server hostname[:port]. Repeat to specify multiple servers." string multiple -option "monitor_port" - "Port to run monitoring server on." int default="9999" -option "connections" - "Number of connections per thread per leaf." int default="1" diff --git a/packages/feedsim/third_party/src/workloads/search/RequestTypes.h b/packages/feedsim/third_party/src/workloads/search/RequestTypes.h deleted file mode 100644 index cc18f2df..00000000 --- a/packages/feedsim/third_party/src/workloads/search/RequestTypes.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// -// 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. - -#ifndef REQUEST_TYPES_H -#define REQUEST_TYPES_H - -namespace search { - -static const int kSearchRequestType = 0; -} // namespace search - -#endif // REQUEST_TYPES_H - diff --git a/packages/feedsim/third_party/src/workloads/search/Util.h b/packages/feedsim/third_party/src/workloads/search/Util.h deleted file mode 100644 index f33850e6..00000000 --- a/packages/feedsim/third_party/src/workloads/search/Util.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// -// 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. - -#ifndef UTIL_H -#define UTIL_H - -#include - -#include -#include -#include -#include - -#include "oldisim/Log.h" - -namespace search { - -/** - * Parse a server address specification of the form host[:port] and - * returns the host name and the port. If no port is specified, the default - * port of 11222 is used. - */ -void ParseServerAddress(const std::string& server_address, - std::string& out_host, int& out_port) { - std::unique_ptr s_copy(new char[server_address.length() + 1]); - snprintf(s_copy.get(), sizeof(char) * (server_address.length() + 1), "%s", - server_address.c_str()); - - char* saveptr = NULL; // For reentrant strtok(). - - const char* host_ptr = strtok_r(s_copy.get(), ":", &saveptr); - const char* port_ptr = strtok_r(NULL, ":", &saveptr); - - // Check to see if host could be parsed - if (host_ptr == NULL) { - DIE("strtok(.., \":\") failed to parse %s", server_address.c_str()); - } - - out_host = std::string(host_ptr); - - // Assign default port if no port specified - if (port_ptr == NULL) { - out_port = 11222; - } else { - out_port = std::strtol(port_ptr, NULL, 10); - } -} -} // namespace search - -#endif // UTIL_H diff --git a/packages/feedsim/third_party/src/workloads/simple/CMakeLists.txt b/packages/feedsim/third_party/src/workloads/simple/CMakeLists.txt deleted file mode 100644 index 681e0eba..00000000 --- a/packages/feedsim/third_party/src/workloads/simple/CMakeLists.txt +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -cmake_minimum_required(VERSION 3.12) -project(OLDISim_simple) - -find_program(GENGETOPT_EXECUTABLE gengetopt REQUIRED) - -# Build LeafNodeTest -add_executable(LeafNodeTestFramework - LeafNodeTestFramework.cc) - -target_compile_features(LeafNodeTestFramework PRIVATE cxx_std_11) -target_include_directories(LeafNodeTestFramework - PUBLIC ${LIBEVENT_INCLUDE_DIR} ${JEMALLOC_INCLUDE_DIR}) -target_link_libraries(LeafNodeTestFramework - PRIVATE OLDISim::OLDISim - PUBLIC Threads::Threads ${LIBEVENT_LIB} ${JEMALLOC_LIB}) - - -# Build ParentNodeTest -add_executable(ParentNodeTestFramework - ParentNodeTestFramework.cc) - -target_compile_features(ParentNodeTestFramework PRIVATE cxx_std_11) -target_include_directories(ParentNodeTestFramework - PUBLIC ${LIBEVENT_INCLUDE_DIR} ${JEMALLOC_INCLUDE_DIR}) -target_link_libraries(ParentNodeTestFramework - PRIVATE OLDISim::OLDISim - PUBLIC Threads::Threads ${LIBEVENT_LIB} ${JEMALLOC_LIB}) - -# Generate getops for DriverNodeTest -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/DriverNodeTestFrameworkCmdline.h - ${CMAKE_CURRENT_BINARY_DIR}/DriverNodeTestFrameworkCmdline.cc - COMMAND ${GENGETOPT_EXECUTABLE} - -i ${CMAKE_CURRENT_SOURCE_DIR}/DriverNodeTestFrameworkCmdline.ggo - -F DriverNodeTestFrameworkCmdline - --output-dir=${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/DriverNodeTestFrameworkCmdline.ggo -) -add_custom_target( - DriverNodeTestFramework_gengetopt ALL - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/DriverNodeTestFrameworkCmdline.h - ${CMAKE_CURRENT_BINARY_DIR}/DriverNodeTestFrameworkCmdline.cc -) -add_library(DriverNodeTestFrameworkcmdline - ${CMAKE_CURRENT_BINARY_DIR}/DriverNodeTestFrameworkCmdline.h - ${CMAKE_CURRENT_BINARY_DIR}/DriverNodeTestFrameworkCmdline.cc) - -add_dependencies(DriverNodeTestFrameworkcmdline DriverNodeTestFramework_gengetopt) - -# Build DriverNode binary -add_executable(DriverNodeTestFramework - DriverNodeTestFramework.cc) -target_compile_features(DriverNodeTestFramework PRIVATE cxx_std_11) -target_include_directories( - DriverNodeTestFramework - PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/ - ${LIBEVENT_INCLUDE_DIR} - ${JEMALLOC_INCLUDE_DIR}) - -target_link_libraries( - DriverNodeTestFramework - PRIVATE OLDISim::OLDISim DriverNodeTestFrameworkcmdline - PUBLIC Threads::Threads ${LIBEVENT_LIB} ${JEMALLOC_LIB}) diff --git a/packages/feedsim/third_party/src/workloads/simple/DriverNodeTestFramework.cc b/packages/feedsim/third_party/src/workloads/simple/DriverNodeTestFramework.cc deleted file mode 100644 index 9d98b13c..00000000 --- a/packages/feedsim/third_party/src/workloads/simple/DriverNodeTestFramework.cc +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// -// 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. - -#include -#include - -#include - -#include "oldisim/DriverNode.h" -#include "DriverNodeTestFrameworkCmdline.h" -#include "oldisim/Log.h" -#include "oldisim/NodeThread.h" -#include "oldisim/ResponseContext.h" -#include "oldisim/TestDriver.h" -#include "oldisim/Util.h" - -gengetopt_args_info args; - -// Declarations of handlers -void ThreadStartup(oldisim::NodeThread& thread, - oldisim::TestDriver& test_driver); -void MakeRequest(oldisim::NodeThread& thread, oldisim::TestDriver& test_driver); -void Type0Response(oldisim::NodeThread& thread, - oldisim::ResponseContext& context); - -void ThreadStartup(oldisim::NodeThread& thread, - oldisim::TestDriver& test_driver) { - printf("Started new thread\n"); - printf("pthread id: %08x\n", static_cast(thread.get_pthread())); - printf("event_base: %p\n", thread.get_event_base()); - printf("test_driver: %p\n", &test_driver); - printf("\n"); -} - -void MakeRequest(oldisim::NodeThread& thread, - oldisim::TestDriver& test_driver) { - test_driver.SendRequest(0, nullptr, 0, 0); -} - -void Type0Response(oldisim::NodeThread& thread, - oldisim::ResponseContext& context) { - printf("Got type 0 response packet\n"); - printf("pthread id: %08x\n", static_cast(thread.get_pthread())); - printf("event_base: %p\n", thread.get_event_base()); - printf("type %d\n", context.type); - printf("payload length %d\n", context.payload_length); - printf("packet length %d\n", context.packet_length); - printf("reply_data: %s\n", reinterpret_cast( - const_cast(context.payload))); - printf("\n"); -} - -int main(int argc, char** argv) { - // Parse arguments - if (cmdline_parser(argc, argv, &args) != 0) { - DIE("cmdline_parser failed"); - } - - // Set logging level - for (unsigned int i = 0; i < args.verbose_given; i++) { - log_level = (log_level_t)(static_cast(log_level) - 1); - } - if (args.quiet_given) { - log_level = QUIET; - } - - // Check requried arguments - if (!args.server_given) { - DIE("--server must be specified."); - } - if (!args.port_given) { - DIE("--port must be specified."); - } - - oldisim::DriverNode driver_node(args.server_arg, args.port_arg); - - driver_node.SetMakeRequestCallback(MakeRequest); - driver_node.RegisterRequestType(0); - - // Enable remote monitoring - driver_node.EnableMonitoring(8889); - - driver_node.Run(args.threads_arg, args.affinity_given, args.connections_arg, - args.depth_arg); - - return 0; -} diff --git a/packages/feedsim/third_party/src/workloads/simple/DriverNodeTestFrameworkCmdline.ggo b/packages/feedsim/third_party/src/workloads/simple/DriverNodeTestFrameworkCmdline.ggo deleted file mode 100644 index 884b3a36..00000000 --- a/packages/feedsim/third_party/src/workloads/simple/DriverNodeTestFrameworkCmdline.ggo +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2015 Google Inc. All Rights Reserved. -# -# 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. - -package "DriverNodeTestFramework" -version "0.1" -usage "DriverNodeTestFramework [options]" -description "Sample program to demonstrate a test driving node" - -args "-c cc --show-required -C --default-optional -l" - -option "verbose" v "Verbosity. Repeat for more verbose." multiple -option "quiet" - "Disable log messages." - -option "threads" - "Number of threads to spawn." int default="1" -option "server" - "Hostname of service to test." string -option "port" - "Port of service to test on." int default="46645" -option "connections" - "Connections to establish per thread." int default="1" -option "depth" - "Maximum depth to pipeline requests per thread." int default="1" - -option "affinity" - "Set distinct CPU affinity for threads, round-robin" diff --git a/packages/feedsim/third_party/src/workloads/simple/LeafNodeTestFramework.cc b/packages/feedsim/third_party/src/workloads/simple/LeafNodeTestFramework.cc deleted file mode 100644 index 36bd54a1..00000000 --- a/packages/feedsim/third_party/src/workloads/simple/LeafNodeTestFramework.cc +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// -// 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. - -#include -#include - -#include - -#include "oldisim/LeafNodeServer.h" -#include "oldisim/NodeThread.h" -#include "oldisim/ParentConnection.h" -#include "oldisim/QueryContext.h" - -void ThreadStartup(oldisim::NodeThread& thread, const void* data) { - printf("Started new thread\n"); - printf("pthread id: %08x\n", static_cast(thread.get_pthread())); - printf("event_base: %p\n", thread.get_event_base()); - printf("Interpreting data as string: %s\n", reinterpret_cast( - const_cast(data))); -} - -void AcceptHandler(oldisim::NodeThread& thread, oldisim::ParentConnection& conn, - const void* data) { - printf("Got new connection\n"); - printf("pthread id: %08x\n", static_cast(thread.get_pthread())); - printf("event_base: %p\n", thread.get_event_base()); - printf("conn: %p\n", &conn); - printf("Interpreting data as string: %s\n", reinterpret_cast( - const_cast(data))); -} - -void Type0Handler(oldisim::NodeThread& thread, oldisim::QueryContext& context, - const void* data) { - static const char test_response[] = - "i am a test response for 0 " - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrst" - "uvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - context.SendResponse(reinterpret_cast(test_response), - sizeof(test_response)); -} - -void Type2Handler(oldisim::NodeThread& thread, oldisim::QueryContext& context, - const void* data) { - printf("Got type 0 packet\n"); - printf("pthread id: %08x\n", static_cast(thread.get_pthread())); - printf("event_base: %p\n", thread.get_event_base()); - printf("type %d\n", context.type); - printf("payload length %d\n", context.payload_length); - printf("packet length %d\n", context.packet_length); - printf("payload: %p\n", context.payload); - printf("Interpreting data as string: %s\n", reinterpret_cast( - const_cast(data))); - - static const char test_response[] = "i am a test response for 2"; - context.SendResponse(reinterpret_cast(test_response), - sizeof(test_response)); -} - -void Type88Handler(oldisim::NodeThread& thread, oldisim::QueryContext& context, - const void* data) { - printf("Got type 0 packet\n"); - printf("pthread id: %08x\n", static_cast(thread.get_pthread())); - printf("event_base: %p\n", thread.get_event_base()); - printf("type %d\n", context.type); - printf("payload length %d\n", context.payload_length); - printf("packet length %d\n", context.packet_length); - printf("payload: %p\n", context.payload); - printf("Interpreting data as string: %s\n", reinterpret_cast( - const_cast(data))); - - static const char test_response[] = "i am a test response for 88"; - context.SendResponse(reinterpret_cast(test_response), - sizeof(test_response)); -} - -int main() { - oldisim::LeafNodeServer server(11222); - - const char* test_string1 = "hi hi hi"; - const char* test_string2 = "yay yay yay"; - const char* test_string3 = "handler handler handler000"; - const char* test_string4 = "handler handler handler222"; - const char* test_string5 = "handler handler handler8888"; - - server.RegisterQueryCallback(0, std::bind(Type0Handler, std::placeholders::_1, - std::placeholders::_2, - test_string3)); - server.RegisterQueryCallback(2, std::bind(Type2Handler, std::placeholders::_1, - std::placeholders::_2, - test_string4)); - server.RegisterQueryCallback(88, std::bind(Type88Handler, - std::placeholders::_1, - std::placeholders::_2, - test_string5)); - - server.SetNumThreads(24); - server.SetThreadPinning(true); - server.Run(); - - return 0; -} diff --git a/packages/feedsim/third_party/src/workloads/simple/ParentNodeTestFramework.cc b/packages/feedsim/third_party/src/workloads/simple/ParentNodeTestFramework.cc deleted file mode 100644 index 3f4c80d1..00000000 --- a/packages/feedsim/third_party/src/workloads/simple/ParentNodeTestFramework.cc +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// -// 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. - -#include -#include - -#include - -#include "oldisim/FanoutManager.h" -#include "oldisim/LeafNodeServer.h" -#include "oldisim/NodeThread.h" -#include "oldisim/ParentConnection.h" -#include "oldisim/ParentNodeServer.h" -#include "oldisim/QueryContext.h" - -const int kNumLeafs = 4; - -// Declarations of handlers -void ThreadStartup(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, const void* data); -void AcceptHandler(oldisim::NodeThread& thread, oldisim::ParentConnection& conn, - const void* data); -void Type0Handler(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, - oldisim::QueryContext& context, const void* data); -void Type0Handler_part1(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, - oldisim::QueryContext& originating_query, - const oldisim::FanoutReplyTracker& results); -void Type0Handler_part2(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, - oldisim::QueryContext& originating_query, - const oldisim::FanoutReplyTracker& results); -void Type0Handler_part3(oldisim::QueryContext& originating_query, - const oldisim::FanoutReplyTracker& results); - -void ThreadStartup(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, const void* data) { - // Create child connections - for (int i = 0; i < kNumLeafs; i++) { - fanout_manager.MakeChildConnections(i, 24); - } -} - -void AcceptHandler(oldisim::NodeThread& thread, oldisim::ParentConnection& conn, - const void* data) { - printf("Got new connection\n"); - printf("pthread id: %08x\n", static_cast(thread.get_pthread())); - printf("event_base: %p\n", thread.get_event_base()); - printf("conn: %p\n", &conn); - printf("Interpreting data as string: %s\n", reinterpret_cast( - const_cast(data))); -} - -void Type0Handler(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, - oldisim::QueryContext& context, const void* data) { - // Set up fanout structure to everyone - oldisim::FanoutRequest request; - request.request_type = 0; - request.request_data = nullptr; - request.request_data_length = 0; - - fanout_manager.FanoutAll(std::move(context), request, - std::bind(Type0Handler_part1, std::ref(thread), - std::ref(fanout_manager), - std::placeholders::_1, - std::placeholders::_2)); -} - -void Type0Handler_part1(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, - oldisim::QueryContext& originating_query, - const oldisim::FanoutReplyTracker& results) { - oldisim::FanoutRequest requests[] = { - {0, 0, nullptr, 0}, {2, 0, nullptr, 0}, {4, 0, nullptr, 0}}; - - fanout_manager.Fanout(std::move(originating_query), requests, 3, - std::bind(Type0Handler_part2, std::ref(thread), - std::ref(fanout_manager), - std::placeholders::_1, - std::placeholders::_2), - 3.0); -} - -void Type0Handler_part2(oldisim::NodeThread& thread, - oldisim::FanoutManager& fanout_manager, - oldisim::QueryContext& originating_query, - const oldisim::FanoutReplyTracker& results) { - oldisim::FanoutRequest requests[] = {{1, 0, nullptr, 0}, {3, 0, nullptr, 0}}; - - fanout_manager.Fanout(std::move(originating_query), requests, 2, - Type0Handler_part3, 3.0); -} - -void Type0Handler_part3(oldisim::QueryContext& originating_query, - const oldisim::FanoutReplyTracker& results) { - // Finally send back the data - static const char test_response[] = - "i am a test response for 0 " - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrst" - "uvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - originating_query.SendResponse( - reinterpret_cast(test_response), sizeof(test_response)); -} - -int main() { - oldisim::ParentNodeServer server(11223); - - const char* test_string1 = "hi hi hi"; - const char* test_string2 = "yay yay yay"; - const char* test_string3 = "handler handler handler000"; - const char* test_string4 = "handler handler handler222"; - const char* test_string5 = "handler handler handler8888"; - - server.SetThreadStartupCallback( - std::bind(ThreadStartup, std::placeholders::_1, std::placeholders::_2, - test_string1)); - - server.RegisterQueryCallback( - 0, std::bind(Type0Handler, std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3, test_string3)); - - server.RegisterRequestType(0); - - // Add some child nodes - server.AddChildNode("localhost", 11222); - server.AddChildNode("localhost", 11222); - server.AddChildNode("localhost", 11222); - server.AddChildNode("localhost", 11222); - - // Enable remote monitoring - server.EnableMonitoring(8888); - - server.Run(24, true); - - return 0; -}