From 96b3f2de84f77fc219fff752fdcc8621cec32a5e Mon Sep 17 00:00:00 2001 From: Jiacai Liu Date: Wed, 21 Sep 2022 12:01:41 +0800 Subject: [PATCH] feat: add tsbs CI (#264) * add tsbs CI * add pull request condition * Update summary after benchmark --- .github/workflows/tsbs.yml | 46 ++++++++++++++++++++++++ scripts/run-tsbs.sh | 72 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 .github/workflows/tsbs.yml create mode 100755 scripts/run-tsbs.sh diff --git a/.github/workflows/tsbs.yml b/.github/workflows/tsbs.yml new file mode 100644 index 0000000000..d9dc60f691 --- /dev/null +++ b/.github/workflows/tsbs.yml @@ -0,0 +1,46 @@ +name: TSBS Benchmark + +on: + workflow_dispatch: + pull_request: + paths: + - '.github/workflows/tsbs.yml' + - 'scrits/run-tsbs.sh' + paths-ignore: + schedule: + - cron: '2 0 * * *' + +jobs: + run-tsbs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: Cache Rust Dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cargo + ./target + key: rust-${{ runner.os }}-release-${{ hashFiles('rust-toolchain') }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + rust-${{ runner.os }}-release-${{ hashFiles('rust-toolchain') }}- + rust-${{ runner.os }}-release- + rust-${{ runner.os }} + - name: Build server + run: | + make build + - name: Run TSBS + run: | + ./scripts/run-tsbs.sh + echo "NOW=$(TZ=':Asia/Shanghai' date +'%Y-%m-%dT%H_%M_%S')" >> $GITHUB_ENV + - name: Update Summary + run: | + cat tsbs/result.md >> $GITHUB_STEP_SUMMARY + - uses: actions/upload-artifact@v3 + with: + name: bench-${{ env.NOW }} + path: | + logs/** + tsbs/result.md diff --git a/scripts/run-tsbs.sh b/scripts/run-tsbs.sh new file mode 100755 index 0000000000..2ebc72af6d --- /dev/null +++ b/scripts/run-tsbs.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +export CURR_DIR=$(pwd) +# used to create issue in https://github.com/CeresDB/tsbs/labels +export RESULT_FILE=${CURR_DIR}/tsbs/result.md +export CONFIG_FILE=${CONFIG_FILE:-docs/minimal.toml} +export LOG_DIR=${CURR_DIR}/logs +# where generated data stored +export DATA_FILE=${DATA_FILE:-data.out} +# how many values in host tag +export HOST_NUM=${HOST_NUM:-10000} +export TS_START="2022-09-05T00:00:00Z" +export TS_END="2022-09-05T12:00:01Z" +export EXE_FILE_NAME=${CURR_DIR}/tsbs/tsbs_generate_queries +# where generated queries stored +export BULK_DATA_DIR=${CURR_DIR}/tsbs/data +export FORMATS=ceresdb +export QUERY_TYPES="\ +single-groupby-1-1-1 \ +single-groupby-1-1-12 \ +single-groupby-1-8-1 \ +single-groupby-5-1-1 \ +single-groupby-5-1-12 \ +single-groupby-5-8-1" + +set -x +trap cleanup EXIT +cleanup() { + ls -lha ${LOG_DIR} + ls -lha ${CURR_DIR}/tsbs + ls -lha ${BULK_DATA_DIR} +} + +mkdir -p ${LOG_DIR} + +nohup ./target/release/ceresdb-server -c ${CONFIG_FILE} > ${LOG_DIR}/server.log & + +git clone -b feat-ceresdb --depth 1 --single-branch https://github.com/CeresDB/tsbs.git + +cd tsbs +go build ./cmd/tsbs_generate_data +go build ./cmd/tsbs_load_ceresdb +go build ./cmd/tsbs_generate_queries +go build ./cmd/tsbs_run_queries_ceresdb + +# generate benchmark data +./tsbs_generate_data --use-case="cpu-only" --seed=123 --initial-scale=${HOST_NUM} --scale=${HOST_NUM} \ + --timestamp-start="${TS_START}" \ + --timestamp-end="${TS_END}" \ + --log-interval="60s" --format="${FORMATS}" > ${DATA_FILE} + + +# write data to ceresdb +./tsbs_load_ceresdb --file ${DATA_FILE} | tee ${LOG_DIR}/write.log + +# generate queries +./scripts/generate_queries.sh + +# run queries against ceresdb +# Note: only run 5-8-1 now +cat ${BULK_DATA_DIR}/ceresdb-single-groupby-5-8-1-queries.gz | gunzip | ./tsbs_run_queries_ceresdb | tee ${LOG_DIR}/5-8-1.log + +# Output write & query result +echo '# Write' >> ${RESULT_FILE} +echo '```bash' >> ${RESULT_FILE} +cat ${LOG_DIR}/write.log >> ${RESULT_FILE} +echo '```' >> ${RESULT_FILE} + +echo '# Query' >> ${RESULT_FILE} +echo '```bash' >> ${RESULT_FILE} +cat ${LOG_DIR}/5-8-1.log >> ${RESULT_FILE} +echo '```' >> ${RESULT_FILE}