Skip to content

QEMU costing - CPU instructions, branch = feature/crypto_utils_costing_with_tests #26

QEMU costing - CPU instructions, branch = feature/crypto_utils_costing_with_tests

QEMU costing - CPU instructions, branch = feature/crypto_utils_costing_with_tests #26

name: QEMU costing - CPU instructions
run-name: QEMU costing - CPU instructions, branch = ${{ github.ref_name }}
on:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
build-radix-engine-tests:
name: Build radix engine tests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Build radix-engine-tests
run: |
cd radix-engine-tests
cargo test --release --no-run --features resource_tracker
rm -f ../target/release/deps/transaction_multi_threaded-*
rm -f ../target/release/deps/*.d
rm -f ../target/release/deps/*.o
rm -f ../target/release/deps/*.rlib
rm -f ../target/release/deps/*.rmeta
- name: Preapare files for cache
run: |
cd target/release
mkdir deps_1
cd deps
count=`ls | wc -l`
half=`echo $(($count / 2))`
ls | head -n$half | xargs mv -t ../deps_1
cd ..
mv deps deps_2
- name: Cache build results 1
uses: actions/cache/save@v3
with:
path: ./target/release/deps_1
key: ${{ runner.os }}-build-cache-1-radix-engine-tests-${{ github.run_id }}
- name: Cache build results 2
uses: actions/cache/save@v3
with:
path: ./target/release/deps_2
key: ${{ runner.os }}-build-cache-2-radix-engine-tests-${{ github.run_id }}
build-other-tests:
name: Build other tests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Build tests
run: |
cargo test --release --no-run --features resource_tracker --workspace --exclude radix-engine-tests
rm -f ./target/release/deps/*.d
rm -f ./target/release/deps/*.o
rm -f ./target/release/deps/*.rlib
rm -f ./target/release/deps/*.rmeta
- name: Preapare files for cache
run: |
cd target/release
mkdir deps_3
cd deps
count=`ls fuzz* | wc -l`
half=`echo $(($count / 2))`
ls fuzz* | head -n$half | xargs mv -t ../deps_3
cd ..
mv deps deps_4
- name: Cache build results 1
uses: actions/cache/save@v3
with:
path: ./target/release/deps_3
key: ${{ runner.os }}-build-cache-3-radix-engine-tests-${{ github.run_id }}
- name: Cache build results 2
uses: actions/cache/save@v3
with:
path: ./target/release/deps_4
key: ${{ runner.os }}-build-cache-4-radix-engine-tests-${{ github.run_id }}
qemu-build:
name: QEMU build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Setup dependencies
run: |
sudo apt-get update
sudo apt-get install build-essential pkg-config ninja-build libglib2.0-dev meson
- name: Setup QEMU v8.0.3
run: |
cd ..
wget -nv https://download.qemu.org/qemu-8.0.3.tar.xz
tar xJf qemu-8.0.3.tar.xz
cd qemu-8.0.3
./configure --disable-system --enable-user --target-list=x86_64-linux-user --enable-plugins
make
cd ..
- name: Compile Scrypto QEMU plugin
run: |
cd radix-engine-profiling/qemu-plugin
sed -i 's/^qemu_source_dir.*/qemu_source_dir=\x27\/home\/runner\/work\/radixdlt-scrypto\/qemu-8.0.3\/\x27/' ./meson.build
bash ./build.sh
- name: Cache QEMU binary
uses: actions/cache/save@v3
with:
path: /home/runner/work/radixdlt-scrypto/qemu-8.0.3/build/qemu-x86_64
key: ${{ runner.os }}-cache-qemu-bin-${{ github.run_id }}
- name: Cache QEMU plugin
uses: actions/cache/save@v3
with:
path: ./radix-engine-profiling/qemu-plugin/build
key: ${{ runner.os }}-cache-qemu-plugin-${{ github.run_id }}
qemu-costing-evaluation-run:
name: QEMU costing - CPU instructions
runs-on: ubuntu-22.04
needs: [build-radix-engine-tests, build-other-tests, qemu-build]
strategy:
matrix:
bin-cache: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v3
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Read cache QEMU binary
uses: actions/cache/restore@v3
with:
path: /home/runner/work/radixdlt-scrypto/qemu-8.0.3/build/qemu-x86_64
key: ${{ runner.os }}-cache-qemu-bin-${{ github.run_id }}
fail-on-cache-miss: true
- name: Read cache QEMU plugin
uses: actions/cache/restore@v3
with:
path: ./radix-engine-profiling/qemu-plugin/build
key: ${{ runner.os }}-cache-qemu-plugin-${{ github.run_id }}
fail-on-cache-miss: true
- name: Update paths in scripts
run: |
cd radix-engine-profiling/resources-tracker-macro/scripts
sed -i 's/^qemu_app.*/qemu_app=\/home\/runner\/work\/radixdlt-scrypto\/qemu-8.0.3\/build\/qemu-x86_64/' ./run_tests.sh
sed -i 's/^qemu_plugin.*/qemu_plugin=\/home\/runner\/work\/radixdlt-scrypto\/radixdlt-scrypto\/radix-engine-profiling\/qemu-plugin\/build\/libscrypto-qemu-plugin.so/' ./run_tests.sh
- name: Read cache build results
uses: actions/cache/restore@v3
with:
path: ${{ format('./target/release/deps_{0}', matrix.bin-cache) }}
key: ${{ format('{0}-build-cache-{1}-radix-engine-tests-{2}', runner.os, matrix.bin-cache, github.run_id) }}
fail-on-cache-miss: true
- name: Run radix-engine-tests using QEMU
run: |
mkdir /tmp/scrypto-resources-usage
cd radix-engine-tests
bash ../radix-engine-profiling/resources-tracker-macro/scripts/run_tests.sh ${{ format('../target/release/deps_{0}', matrix.bin-cache) }}
- name: Cache QEMU run results
uses: actions/cache/save@v3
with:
path: /tmp/scrypto-resources-usage
key: ${{ format('{0}-build-cache-{1}-radix-engine-tests-{2}-qemu-results', runner.os, matrix.bin-cache, github.run_id) }}
generate-results:
name: Generate results
runs-on: ubuntu-22.04
needs: qemu-costing-evaluation-run
steps:
- uses: actions/checkout@v3
- name: Setup dependencies
run: pip3 install lxml tabulate numpy scikit-learn statsmodels
- name: Read cache QEMU run 1 results
uses: actions/cache/restore@v3
with:
path: /tmp/scrypto-resources-usage
key: ${{ runner.os }}-build-cache-1-radix-engine-tests-${{ github.run_id }}-qemu-results
fail-on-cache-miss: true
- name: Read cache QEMU run 2 results
uses: actions/cache/restore@v3
with:
path: /tmp/scrypto-resources-usage
key: ${{ runner.os }}-build-cache-2-radix-engine-tests-${{ github.run_id }}-qemu-results
fail-on-cache-miss: true
- name: Read cache QEMU run 3 results
uses: actions/cache/restore@v3
with:
path: /tmp/scrypto-resources-usage
key: ${{ runner.os }}-build-cache-3-radix-engine-tests-${{ github.run_id }}-qemu-results
fail-on-cache-miss: true
- name: Read cache QEMU run 4 results
uses: actions/cache/restore@v3
with:
path: /tmp/scrypto-resources-usage
key: ${{ runner.os }}-build-cache-4-radix-engine-tests-${{ github.run_id }}-qemu-results
fail-on-cache-miss: true
- name: Upload xml files
uses: actions/upload-artifact@v3
with:
name: QEMU generated XML files
path: /tmp/scrypto-resources-usage
- name: Generate results
run: python3 ./radix-engine-profiling/resources-tracker-macro/scripts/convert.py /tmp/scrypto-resources-usage
- name: Upload results
uses: actions/upload-artifact@v3
with:
name: Results
path: |
/tmp/_out_table.txt
/tmp/_out_table_detailed.txt
/tmp/_out_linear_regression_coeff.txt
/tmp/native_function_base_costs.csv