2023-12-15 20:33:46 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-02-05 00:14:40 +00:00
|
|
|
set -x
|
|
|
|
|
2024-01-29 15:38:44 +00:00
|
|
|
# shellcheck source=/dev/null
|
|
|
|
source "$HOME"/.cargo/env
|
|
|
|
source "$(dirname "$0")"/test-util.sh
|
2022-02-05 00:14:40 +00:00
|
|
|
|
2024-01-29 15:38:44 +00:00
|
|
|
TEST_ARCH=$(uname -m)
|
|
|
|
export TEST_ARCH
|
2022-02-05 00:14:40 +00:00
|
|
|
|
|
|
|
WORKLOADS_DIR="$HOME/workloads"
|
|
|
|
mkdir -p "$WORKLOADS_DIR"
|
|
|
|
|
2022-03-18 03:00:02 +00:00
|
|
|
build_fio() {
|
|
|
|
FIO_DIR="$WORKLOADS_DIR/fio_build"
|
|
|
|
FIO_REPO="https://github.com/axboe/fio.git"
|
|
|
|
|
|
|
|
checkout_repo "$FIO_DIR" "$FIO_REPO" master "1953e1adb5a28ed21370e85991d7f5c3cdc699f3"
|
|
|
|
if [ ! -f "$FIO_DIR/.built" ]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
pushd "$FIO_DIR" || exit
|
2022-03-18 03:00:02 +00:00
|
|
|
./configure
|
2024-01-29 15:38:44 +00:00
|
|
|
make -j "$(nproc)"
|
2022-03-18 03:00:02 +00:00
|
|
|
cp fio "$WORKLOADS_DIR/fio"
|
|
|
|
touch .built
|
2024-01-29 15:38:44 +00:00
|
|
|
popd || exit
|
2022-03-18 03:00:02 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-02-05 00:14:40 +00:00
|
|
|
process_common_args "$@"
|
|
|
|
|
2024-01-29 15:38:44 +00:00
|
|
|
cp scripts/sha1sums-"${TEST_ARCH}" "$WORKLOADS_DIR"
|
2022-03-11 02:26:30 +00:00
|
|
|
|
2024-01-29 15:38:44 +00:00
|
|
|
if [ "${TEST_ARCH}" == "aarch64" ]; then
|
2024-01-26 15:30:32 +00:00
|
|
|
FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-arm64-custom-20210929-0.qcow2"
|
2022-03-11 02:26:30 +00:00
|
|
|
else
|
2024-01-26 15:30:32 +00:00
|
|
|
FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0.qcow2"
|
2022-03-11 02:26:30 +00:00
|
|
|
fi
|
2022-02-05 00:14:40 +00:00
|
|
|
|
2024-02-28 09:51:10 +00:00
|
|
|
FOCAL_OS_IMAGE_URL="https://ch-images.azureedge.net/$FOCAL_OS_IMAGE_NAME"
|
2022-02-05 00:14:40 +00:00
|
|
|
FOCAL_OS_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_IMAGE_NAME"
|
|
|
|
if [ ! -f "$FOCAL_OS_IMAGE" ]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
pushd "$WORKLOADS_DIR" || exit
|
2022-02-05 00:14:40 +00:00
|
|
|
time wget --quiet $FOCAL_OS_IMAGE_URL || exit 1
|
2024-01-29 15:38:44 +00:00
|
|
|
popd || exit
|
2022-02-05 00:14:40 +00:00
|
|
|
fi
|
|
|
|
|
2024-01-29 15:38:44 +00:00
|
|
|
if [ "${TEST_ARCH}" == "aarch64" ]; then
|
2022-03-11 02:26:30 +00:00
|
|
|
FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-arm64-custom-20210929-0.raw"
|
|
|
|
else
|
|
|
|
FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0.raw"
|
|
|
|
fi
|
|
|
|
|
2022-02-05 00:14:40 +00:00
|
|
|
FOCAL_OS_RAW_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_NAME"
|
|
|
|
if [ ! -f "$FOCAL_OS_RAW_IMAGE" ]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
pushd "$WORKLOADS_DIR" || exit
|
2022-02-05 00:14:40 +00:00
|
|
|
time qemu-img convert -p -f qcow2 -O raw $FOCAL_OS_IMAGE_NAME $FOCAL_OS_RAW_IMAGE_NAME || exit 1
|
2024-01-29 15:38:44 +00:00
|
|
|
popd || exit
|
2022-02-05 00:14:40 +00:00
|
|
|
fi
|
|
|
|
|
2024-01-29 15:38:44 +00:00
|
|
|
pushd "$WORKLOADS_DIR" || exit
|
|
|
|
if ! grep focal sha1sums-"${TEST_ARCH}" | sha1sum --check; then
|
2022-02-05 00:14:40 +00:00
|
|
|
echo "sha1sum validation of images failed, remove invalid images to fix the issue."
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-01-29 15:38:44 +00:00
|
|
|
popd || exit
|
2022-02-05 00:14:40 +00:00
|
|
|
|
2024-01-29 15:38:44 +00:00
|
|
|
if [ "${TEST_ARCH}" == "aarch64" ]; then
|
2022-03-18 03:00:02 +00:00
|
|
|
build_fio
|
|
|
|
|
|
|
|
# Update the fio in the cloud image to use io_uring on AArch64
|
|
|
|
FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_NAME="focal-server-cloudimg-arm64-custom-20210929-0-update-tool.raw"
|
|
|
|
cp "$FOCAL_OS_RAW_IMAGE" "$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_NAME"
|
|
|
|
FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR="$WORKLOADS_DIR/focal-server-cloudimg-root"
|
|
|
|
if [ ! -d "$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR" ]; then
|
|
|
|
mkdir -p "$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR"
|
|
|
|
fi
|
|
|
|
# Mount the 'raw' image, replace the fio and umount the working folder
|
|
|
|
guestmount -a "$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_NAME" -m /dev/sda1 "$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR" || exit 1
|
|
|
|
cp "$WORKLOADS_DIR"/fio "$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR"/usr/bin/fio
|
|
|
|
guestunmount "$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR"
|
|
|
|
fi
|
|
|
|
|
2022-02-05 00:14:40 +00:00
|
|
|
# Build custom kernel based on virtio-pmem and virtio-fs upstream patches
|
2022-03-25 05:56:20 +00:00
|
|
|
build_custom_linux
|
2022-02-05 00:14:40 +00:00
|
|
|
|
|
|
|
CFLAGS=""
|
2022-03-11 02:26:30 +00:00
|
|
|
if [[ "${BUILD_TARGET}" == "${TEST_ARCH}-unknown-linux-musl" ]]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
# shellcheck disable=SC2034
|
2022-03-11 02:26:30 +00:00
|
|
|
CFLAGS="-I /usr/include/${TEST_ARCH}-linux-musl/ -idirafter /usr/include/"
|
2022-02-05 00:14:40 +00:00
|
|
|
fi
|
|
|
|
|
2024-01-29 15:38:44 +00:00
|
|
|
cargo build --features mshv --all --release --target "$BUILD_TARGET"
|
2022-02-05 00:14:40 +00:00
|
|
|
|
|
|
|
# setup hugepages
|
2024-01-26 15:30:32 +00:00
|
|
|
HUGEPAGESIZE=$(grep Hugepagesize /proc/meminfo | awk '{print $2}')
|
2024-01-29 15:38:44 +00:00
|
|
|
PAGE_NUM=$((12288 * 1024 / HUGEPAGESIZE))
|
|
|
|
echo "$PAGE_NUM" | sudo tee /proc/sys/vm/nr_hugepages
|
2022-02-05 00:14:40 +00:00
|
|
|
sudo chmod a+rwX /dev/hugepages
|
|
|
|
|
2022-03-07 13:39:26 +00:00
|
|
|
if [ -n "$test_filter" ]; then
|
|
|
|
test_binary_args+=("--test-filter $test_filter")
|
|
|
|
fi
|
|
|
|
|
2022-06-10 15:12:02 +00:00
|
|
|
# Ensure that git commands can be run in this directory (for metrics report)
|
2024-01-29 15:38:44 +00:00
|
|
|
git config --global --add safe.directory "$PWD"
|
2022-06-10 15:12:02 +00:00
|
|
|
|
2024-01-29 15:38:44 +00:00
|
|
|
RUST_BACKTRACE_VALUE=$RUST_BACKTRACE
|
|
|
|
if [ -z "$RUST_BACKTRACE_VALUE" ]; then
|
2024-01-26 15:30:32 +00:00
|
|
|
export RUST_BACKTRACE=1
|
2023-04-10 14:19:50 +00:00
|
|
|
else
|
2024-01-26 15:30:32 +00:00
|
|
|
echo "RUST_BACKTRACE is set to: $RUST_BACKTRACE_VALUE"
|
2023-04-10 14:19:50 +00:00
|
|
|
fi
|
2024-01-29 15:38:44 +00:00
|
|
|
# shellcheck disable=SC2048,SC2086
|
|
|
|
time target/"$BUILD_TARGET"/release/performance-metrics ${test_binary_args[*]}
|
2022-02-05 00:14:40 +00:00
|
|
|
RES=$?
|
|
|
|
|
|
|
|
exit $RES
|