Skip to content

Commit

Permalink
Update benchmark message (subquery#1898)
Browse files Browse the repository at this point in the history
* Update benchmark message

* add calculation for bps

---------

Co-authored-by: JQQQ <[email protected]>
  • Loading branch information
jamesbayly and jiqiang90 authored Jul 25, 2023
1 parent 382af1a commit 4ad25e0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ jobs:
run: |
apt-get install --yes postgresql-client
# Install bc used in convert time in seconds
- name: Install bc
run: apt-get install -y bc

# queries database with postgres client
- name: Setup historical database
run: psql -h postgres -d postgres -U postgres -c 'CREATE EXTENSION IF NOT EXISTS btree_gist;'
Expand Down Expand Up @@ -116,7 +120,7 @@ jobs:
PGPASSWORD: postgres
run: |
chmod +x .github/workflows/scripts/benchmark/queryMeta.sh
.github/workflows/scripts/benchmark/queryMeta.sh
.github/workflows/scripts/benchmark/queryMeta.sh ${{github.event.inputs.benchmark-time}}
- name: Pre-save running specs
run: |
Expand Down Expand Up @@ -175,7 +179,7 @@ jobs:
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Results: ${{ job.status }}\n CPUs: ${{github.event.inputs.cpus}}\n Memory: ${{github.event.inputs.memory}}\n Indexer: ${{steps.query_meta.outputs.runner_node}}@${{steps.query_meta.outputs.indexer_version}}\n Deployment: ${{github.event.inputs.deployment}}\n Workers: ${{github.event.inputs.workers}}\n Batch-size: ${{github.event.inputs.batch-size}}\n Performance: block [${{steps.query_meta.outputs.start_height}}-${{steps.query_meta.outputs.last_processed_height}}], total ${{steps.query_meta.outputs.total_height}} blocks in ${{github.event.inputs.benchmark-time}}\n More details: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
"text": "Results: ${{ job.status }} with ${{steps.query_meta.outputs.bps}} bps\n Performance: Block [${{steps.query_meta.outputs.start_height}}-${{steps.query_meta.outputs.last_processed_height}}], total ${{steps.query_meta.outputs.total_height}} blocks in ${{github.event.inputs.benchmark-time}}\n More details: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\n Indexer: ${{steps.query_meta.outputs.runner_node}}@${{steps.query_meta.outputs.indexer_version}}\n Deployment: ${{github.event.inputs.deployment}}\n CPUs: ${{github.event.inputs.cpus}}\n Memory: ${{github.event.inputs.memory}}\n Workers: ${{github.event.inputs.workers}}\n Batch-size: ${{github.event.inputs.batch-size}}"
}
}
]
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/scripts/benchmark/benchmarking.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ subql-node -f ipfs://$input_deployment --network-endpoint=$input_endpoint --batc

APP_PID=$!

#echo "Path from Benchmarking"
#ls "${PWD}/${output_dir}"

echo "Benchmarking, please wait $input_duration."
# Wait for timeout
sleep $input_duration
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/scripts/benchmark/queryMeta.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
#!/bin/bash

# Query the database and store the result in variables
input_duration=$1

# Function to convert time string to seconds
t2s() {
sed 's/d/*24*3600 +/g; s/h/*3600 +/g; s/m/*60 +/g; s/s/\+/g; s/+[ ]*$//g' <<< "$1" | bc
}

# Query the database and store the result in variables
runner_node=$(psql -h postgres -d postgres -U postgres -c "SELECT value FROM app._metadata WHERE key = 'runnerNode';" | awk 'NR == 3 {print $1}' | tr -d '"')
indexer_version=$(psql -h postgres -d postgres -U postgres -c "SELECT value FROM app._metadata WHERE key = 'indexerNodeVersion';" | awk 'NR == 3 {print $1}' | tr -d '"')
start_height=$(psql -h postgres -d postgres -U postgres -c "SELECT value::integer FROM app._metadata WHERE key = 'startHeight';" | awk 'NR == 3 {print $1}')
last_processed_height=$(psql -h postgres -d postgres -U postgres -c "SELECT value::integer FROM app._metadata WHERE key = 'lastProcessedHeight';" | awk 'NR == 3 {print $1}')
total_height=$((last_processed_height-start_height+1))
time_in_seconds=$(t2s "$input_duration")
bps=$(awk "BEGIN {printf \"%.2f\", $total_height / $time_in_seconds}")
# Set outputs for subsequent steps
echo "::set-output name=runner_node::$runner_node"
echo "::set-output name=indexer_version::$indexer_version"
echo "::set-output name=start_height::$start_height"
echo "::set-output name=last_processed_height::$last_processed_height"
echo "::set-output name=total_height::$total_height"
echo "::set-output name=bps::$bps"

0 comments on commit 4ad25e0

Please sign in to comment.