From 7ad866cdace4951fcfd3ee070f7c884181b5b66a Mon Sep 17 00:00:00 2001 From: Fatih Acar Date: Tue, 21 May 2024 14:13:28 +0200 Subject: [PATCH] feat(utilities): add benchmark tool Signed-off-by: Fatih Acar --- .github/workflows/push-bench-image.yml | 61 ++++++++++++++++++++++++++ utilities/benchmark/Dockerfile | 14 ++++++ utilities/benchmark/entrypoint.sh | 37 ++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 .github/workflows/push-bench-image.yml create mode 100644 utilities/benchmark/Dockerfile create mode 100644 utilities/benchmark/entrypoint.sh diff --git a/.github/workflows/push-bench-image.yml b/.github/workflows/push-bench-image.yml new file mode 100644 index 0000000000..a136fbc1cf --- /dev/null +++ b/.github/workflows/push-bench-image.yml @@ -0,0 +1,61 @@ +--- +# yamllint disable rule:truthy +name: Build And Push Bench image + +on: + workflow_dispatch: + push: + branches: + - fac-bench-tool + +env: + DOCKERFILE: "utilities/benchmark/Dockerfile" + +jobs: + build: + runs-on: + group: huge-runners + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + id: login + with: + registry: ${{ vars.HARBOR_HOST }} + username: ${{ secrets.HARBOR_USERNAME }} + password: ${{ secrets.HARBOR_PASSWORD }} + + - name: Set docker image meta data + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ vars.HARBOR_HOST }}/opsmill/bench + tags: | + type=raw,value=latest + labels: | + org.opencontainers.image.source=opsmill/bench + flavor: | + latest=true + + - name: Build and push + uses: docker/build-push-action@v5 + id: push + with: + context: utilities/benchmark + file: ${{ env.DOCKERFILE }} + provenance: false # To avoid cross platform "unknown" + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/utilities/benchmark/Dockerfile b/utilities/benchmark/Dockerfile new file mode 100644 index 0000000000..9fa9b0954d --- /dev/null +++ b/utilities/benchmark/Dockerfile @@ -0,0 +1,14 @@ +FROM debian:bookworm-slim + +RUN apt-get update && \ + apt-get install -y curl libncurses5 unzip yq jq fio + +COPY entrypoint.sh /entrypoint.sh + +RUN bash -c 'curl -o pt_linux.zip https://www.passmark.com/downloads/pt_linux_$([ "$TARGETPLATFORM" == "linux/amd64" ] && echo "x64" || echo "arm64").zip' && \ + unzip pt_linux.zip && \ + mv PerformanceTest/pt_linux_* /usr/local/bin/pt_linux && \ + rm -rf PerformanceTest pt_linux.zip && \ + chmod +x /entrypoint.sh + +CMD /entrypoint.sh diff --git a/utilities/benchmark/entrypoint.sh b/utilities/benchmark/entrypoint.sh new file mode 100644 index 0000000000..6b467829dd --- /dev/null +++ b/utilities/benchmark/entrypoint.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +READ_IOPS_LIMIT=5000 +WRITE_IOPS_LIMIT=5000 +RAM_LIMIT=8000 +SINGLETHREAD_PERF_LIMIT=1500 + +fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=test --filename=randomrw.fio --bs=4k --iodepth=64 --size=128M --readwrite=randrw --rwmixread=75 --output=fio_results.json --output-format=json + +READ_IOPS=$(printf "%.0f" $(jq '.jobs[0].read.iops' fio_results.json)) +WRITE_IOPS=$(printf "%.0f" $(jq '.jobs[0].write.iops' fio_results.json)) + +TERM=xterm pt_linux -d 1 -r 1 -i 1 + +TOTAL_RAM=$(yq .SystemInformation.Memory results_cpu.yml) +SINGLETHREAD_PERF=$(printf "%.0f" $(yq .Results.CPU_SINGLETHREAD results_cpu.yml)) + +NC='\033[0m' +RED='\033[0;31m' +GREEN='\033[0;32m' + +[ $TOTAL_RAM -lt $RAM_LIMIT ] && echo -n $RED || echo -n $GREEN +echo -n "Memory: ${TOTAL_RAM} MB - Required: ${RAM_LIMIT} MB " +[ $TOTAL_RAM -lt $RAM_LIMIT ] && echo ": KO" || echo ": OK" + +[ $SINGLETHREAD_PERF -lt $SINGLETHREAD_PERF_LIMIT ] && echo -n $RED || echo -n $GREEN +echo -n "CPU Perf: ${SINGLETHREAD_PERF} - Required: ${SINGLETHREAD_PERF_LIMIT} " +[ $SINGLETHREAD_PERF -lt $SINGLETHREAD_PERF_LIMIT ] && echo ": KO" || echo ": OK" + +[ $READ_IOPS -lt $READ_IOPS_LIMIT ] && echo -n $RED || echo -n $GREEN +echo -n "Read IOPS: ${READ_IOPS} - Required: ${READ_IOPS_LIMIT} " +[ $READ_IOPS -lt $READ_IOPS_LIMIT ] && echo ": KO" || echo ": OK" + +[ $WRITE_IOPS -lt $WRITE_IOPS_LIMIT ] && echo -n $RED || echo -n $GREEN +echo -n "Write IOPS: ${WRITE_IOPS} - Required: ${WRITE_IOPS_LIMIT} " +[ $WRITE_IOPS -lt $WRITE_IOPS_LIMIT ] && echo ": KO" || echo ": OK" +