Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/adsim/build-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ install_packages() {
# Note: fast_float and boost are built from source since system packages are too old
# On CentOS Stream 10+, gcc-toolset-14 doesn't exist (GCC 14 is default);
# use libatomic-devel directly. On older systems, try gcc-toolset-14-libatomic-devel.
sudo dnf install -y clang jemalloc-devel xxhash-devel bzip2-devel libomp-devel gengetopt python3-devel gtest-devel \
sudo dnf install -y cmake bison flex openssl-devel numactl-devel clang jemalloc-devel xxhash-devel bzip2-devel libomp-devel gengetopt python3-devel gtest-devel \
double-conversion double-conversion-devel libsodium-devel \
gflags-devel glog-devel libunwind-devel libevent-devel lz4-devel libzstd-devel snappy-devel xz-devel binutils-devel
# Install libatomic — try gcc-toolset first (RHEL 9), fall back to base package (CentOS Stream 10+)
Expand All @@ -24,7 +24,7 @@ install_packages() {
# Ubuntu/Debian systems - map package names to Ubuntu equivalents
# Note: fast_float and boost are built from source since system packages are too old
sudo apt-get update
sudo apt-get install -y clang libjemalloc-dev libxxhash-dev libbz2-dev libomp-dev gengetopt libatomic1 python3-dev libgtest-dev \
sudo apt-get install -y cmake bison flex libssl-dev libnuma-dev clang libjemalloc-dev libxxhash-dev libbz2-dev libomp-dev gengetopt libatomic1 python3-dev libgtest-dev \
libdouble-conversion-dev libsodium-dev \
libgflags-dev libgoogle-glog-dev libunwind-dev libevent-dev liblz4-dev libzstd-dev libsnappy-dev liblzma-dev libiberty-dev
else
Expand Down Expand Up @@ -54,12 +54,12 @@ export CXX="${ADSIM_CXX_COMPILER}"
# Pin Facebook library versions for reproducible builds
# Note: Facebook OSS libraries (folly, fizz, wangle, mvfst, fbthrift, fb303) are released
# together with matching version tags to ensure compatibility
FOLLY_VERSION=v2025.06.23.00
FIZZ_VERSION=v2025.06.23.00
WANGLE_VERSION=v2025.06.23.00
MVFST_VERSION=v2025.06.23.00
FBTHRIFT_VERSION=v2025.06.23.00
FB303_VERSION=v2025.06.23.00
FOLLY_VERSION=v2026.08.03.00
FIZZ_VERSION=v2026.08.03.00
WANGLE_VERSION=v2026.08.03.00
MVFST_VERSION=v2026.08.03.00
FBTHRIFT_VERSION=v2026.08.03.00
FB303_VERSION=v2026.08.03.00

# fast_float v8.0.0+ is required for folly's allow_leading_plus feature
FAST_FLOAT_VERSION=v8.0.0
Expand Down
11 changes: 9 additions & 2 deletions packages/adsim/install_adsim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,15 @@ setup_directories() {
# Create final benchmark output directory
mkdir -p ${BENCHMARKS_DIR}

# Clean and recreate temporary build directory
rm -rf ${BUILD_DIR}
# Clean and recreate temporary build directory.
# SKIP_CLEAN=1 preserves an existing build dir so that deps/ and staging/ can
# be reused across iterations; otherwise every install rebuilds the whole
# dependency stack from scratch.
if [ "${SKIP_CLEAN}" = "1" ]; then
echo "[SETUP] SKIP_CLEAN=1 - preserving existing ${BUILD_DIR}"
else
rm -rf ${BUILD_DIR}
fi
mkdir -p ${BUILD_DIR}

# Enter build directory for subsequent operations
Expand Down
18 changes: 9 additions & 9 deletions packages/adsim/install_fbgemm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
MINICONDA_PREFIX=${FBGEMM_STAGING_DIR}/miniconda

# Version of FBGEMM to install
FBGEMM_VERSION=v1.4.0
FBGEMM_VERSION=v1.8.0

# Version of PyTorch to install
PYTORCH_VERSION=2.8.0
PYTORCH_VERSION=2.13.0

MINICONDA_VERSION="5.1-0"

Expand Down Expand Up @@ -809,7 +809,7 @@ setup_directories() {
# Change the current directory to the build directory
# pushd saves the current directory on a stack so we can return to it later with popd
echo "[SETUP] Changing to build directory..."
pushd ${FBGEMM_STAGING_DIR} || exist
pushd ${FBGEMM_STAGING_DIR} || exit 1

echo "[SETUP] Directory setup complete."
}
Expand Down Expand Up @@ -906,7 +906,7 @@ clone_fbgemm_repo() {
echo "#!/bin/bash" > fbgemm/.github/scripts/fbgemm_gpu_postbuild.bash

# Change the current directory to the FBGEMM GPU directory
pushd fbgemm/fbgemm_gpu || exist
pushd fbgemm/fbgemm_gpu || exit 1

echo "[SETUP] FBGEMM repository setup complete."
}
Expand Down Expand Up @@ -962,13 +962,13 @@ install_fbgemm() {
echo "[BUILD] Building and installing FBGEMM..."
# shellcheck disable=SC2086
# print_exec conda run -n $BUILD_ENV python setup.py ${run_multicore} install --package_variant=cpu
popd || exist
pushd fbgemm || exist
popd || exit 1
pushd fbgemm || exit 1
mkdir build
cp ${ADSIM_PROJ_ROOT}/buildfiles/fbgemm/cmake.txt build
pushd build || exist
pushd build || exit 1
source cmake.txt
popd || exist
popd || exit 1

# Test if the FBGEMM library can be imported in the Conda environment
# Generate a standalone executable for the project
Expand Down Expand Up @@ -1006,7 +1006,7 @@ cleanup() {

# This restores the directory we were in before entering the build directory
echo "[CLEANUP] Returning to original directory..."
popd || exist
popd || exit 1

# Remove the build directory to clean up after the build process
# This saves disk space by removing intermediate build files
Expand Down
6 changes: 4 additions & 2 deletions packages/adsim/patches/treadmill.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7416,7 +7416,7 @@ diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclud
diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclude=gen-cpp2' '--exclude=build' '--exclude=third_party' treadmill-src/src/Treadmill.cpp treadmill/src/Treadmill.cpp
--- treadmill-src/src/Treadmill.cpp 1969-12-31 16:00:00.000000000 -0800
+++ treadmill/src/Treadmill.cpp 2025-08-04 15:44:21.787727598 -0700
@@ -0,0 +1,129 @@
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2014, Facebook, Inc.
+ * All rights reserved.
Expand Down Expand Up @@ -7540,7 +7540,9 @@ diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclud
+ // Set the usage information
+ std::string usage("Treadmill loadtester");
+ google::SetUsageMessage(usage);
+ const folly::Init init(&argc, &argv);
+ // Must outlive init(): ~folly::Init calls SingletonVault::destroyInstances(),
+ // so a plain local would tear the vault down before run() uses any singleton.
+ static const folly::Init init(&argc, &argv);
+}
+
+} // namespace treadmill
Expand Down
15 changes: 8 additions & 7 deletions packages/adsim/qps_search.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function parse_opts()
}

function log() {
if [ true == $VERBOSE_LOGGING ]; then
if [ "true" = "$VERBOSE_LOGGING" ]; then
echo "$1"
fi
}
Expand All @@ -119,7 +119,7 @@ function measure_latency()
log "QPS is 0, returning large latency value to avoid blocking"
LATENCY=999999999
ACHIEVED_QPS=0
if [ true == $CSV_LOGGING ]; then
if [ "true" = "$CSV_LOGGING" ]; then
requested_qps="$1"
sequence="$2"
runtime="$3"
Expand Down Expand Up @@ -161,7 +161,7 @@ function measure_latency()
ACHIEVED_QPS=$(cat "$THROUGHPUT_LOG")
log "Latency $TGT_QUANTILE = $LATENCY; Achieved QPS = $ACHIEVED_QPS"

if [ true == $CSV_LOGGING ]; then
if [ "true" = "$CSV_LOGGING" ]; then
requested_qps="$1"
sequence="$2"
runtime="$3"
Expand All @@ -173,6 +173,7 @@ function measure_latency()

function coarse_search()
{
local start_qps=1
log "Starting coarse search to find maximum QPS..."

# Find largest power of 2 <= NWORKERS
Expand Down Expand Up @@ -241,7 +242,7 @@ function binary_search()

while [ "$qps_l" -lt $(( qps_r - 1 )) ]; do
qps_m=$(( (qps_l + qps_r) / 2 ))
measure_latency $"$qps_m" "$SEQ" "$RUNTIME"
measure_latency "$qps_m" "$SEQ" "$RUNTIME"
SEQ=$((SEQ + 1))
lat=${LATENCY%.*}

Expand All @@ -262,12 +263,12 @@ function binary_search()
qps_opt=$qps_r
lat_opt=$lat_r
fi
if [ true == "$CSV_LOGGING" ]; then
if [ "true" = "$CSV_LOGGING" ]; then
final_qps=$(cat "$THROUGHPUT_LOG")
echo "${SEQ},${qps_opt},${final_qps},${TGT_QUANTILE},${TGT_LATENCY},${lat_opt}"
fi

measure_latency $"$qps_opt" "$SEQ" "$RUNTIME"
measure_latency "$qps_opt" "$SEQ" "$RUNTIME"

log "Optimal QPS = $qps_opt, achieving latency = $lat_opt"
log "$TREADMILL_EXE --hostname $ADSIM_HOST --port $ADSIM_PORT " \
Expand All @@ -276,7 +277,7 @@ function binary_search()
}

parse_opts "$@"
if [ true == "$CSV_LOGGING" ]; then
if [ "true" = "$CSV_LOGGING" ]; then
echo "seq,requested_qps,achieved_qps,target_latency_quantile,target_latency_usec,achieved_latency_usec"
fi
# If min and max QPS are not manually specified, run coarse search to find them
Expand Down
2 changes: 1 addition & 1 deletion packages/adsim/run_adsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def run_cmd(cmd: List[str], timeout=None, dryrun=False, verbose=False) -> str:
print(" ".join(cmd))
if dryrun:
return None
if timeout <= 0:
if timeout is not None and timeout <= 0:
timeout = None

proc = subprocess.Popen(cmd)
Expand Down
4 changes: 2 additions & 2 deletions packages/adsim/src/cpp2/server/dwarfs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ add_dependencies(gemm fbgemm)
add_library(embedding Embedding.cc Embedding.h)

if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64")
target_compile_options(gemm PRIVATE
target_compile_options(embedding PRIVATE
${COROUTINES_FLAG}
-m64
-mavx2
-mfma
-masm=intel)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64")
target_compile_options(gemm PRIVATE
target_compile_options(embedding PRIVATE
${COROUTINES_FLAG}
-march=armv8.5-a+sve2
-mcpu=native)
Expand Down