|
| 1 | +# This is a workflow triggered by PR or triggered manually |
| 2 | +# Runs quick performance tests and reports the comparison against HEAD |
| 3 | +# Test should take less than 10 minutes to run on current self-hosted devices |
| 4 | +name: "Performance Testing" |
| 5 | + |
| 6 | +# Controls when the action will run. |
| 7 | +# Workflow runs when manually triggered using the UI or API. |
| 8 | +on: |
| 9 | + push: |
| 10 | +# pull_request: |
| 11 | +# branches: [ main ] |
| 12 | + |
| 13 | +# Env variables |
| 14 | +env: |
| 15 | + SG_COMMIT: 649509c |
| 16 | + |
| 17 | +jobs: |
| 18 | + Performance_x86-64: |
| 19 | + name: Performance x86-64 |
| 20 | + runs-on: [self-hosted, linux, x64] |
| 21 | + # Inputs the workflow accepts. |
| 22 | + steps: |
| 23 | + - run: echo "This job is now running on a ${{ runner.os }} self-hosted server." |
| 24 | + |
| 25 | + - name: Setup Rust Toolchain |
| 26 | + uses: actions-rs/toolchain@v1 |
| 27 | + with: |
| 28 | + toolchain: stable |
| 29 | + |
| 30 | + - name: Build sightglass commit ${{env.SG_COMMIT}}" |
| 31 | + run: | |
| 32 | + cd ../ && ls -l && rm -rf ./sightglass |
| 33 | + git clone https://github.com/bytecodealliance/sightglass.git && cd ./sightglass |
| 34 | + git checkout ${{env.SG_COMMIT}} |
| 35 | + cargo build --release |
| 36 | +
|
| 37 | + - name: Checkout ${{ github.ref }} from ${{ github.repository }} |
| 38 | + uses: actions/checkout@v2 |
| 39 | + with: |
| 40 | + submodules: true |
| 41 | + path: wasmtime_commit |
| 42 | + |
| 43 | + - name: Build ${{ github.ref }} |
| 44 | + working-directory: ./wasmtime_commit |
| 45 | + run: | |
| 46 | + cargo build --release -p wasmtime-bench-api |
| 47 | + cp target/release/libwasmtime_bench_api.so /tmp/wasmtime_commit.so |
| 48 | +
|
| 49 | + - name: Checkout Main |
| 50 | + uses: actions/checkout@v2 |
| 51 | + with: |
| 52 | + ref: 'main' |
| 53 | + submodules: true |
| 54 | + path: wasmtime_main |
| 55 | + |
| 56 | + - name: Build Main |
| 57 | + working-directory: ./wasmtime_main |
| 58 | + run: | |
| 59 | + cargo build --release -p wasmtime-bench-api |
| 60 | + cp target/release/libwasmtime_bench_api.so /tmp/wasmtime_main.so |
| 61 | +
|
| 62 | + - name: Run performance tests |
| 63 | + working-directory: ../sightglass |
| 64 | + run: | |
| 65 | + cargo run -- \ |
| 66 | + benchmark \ |
| 67 | + --processes 1 \ |
| 68 | + --iterations-per-process 2 \ |
| 69 | + --engine /tmp/wasmtime_main.so \ |
| 70 | + --engine /tmp/wasmtime_commit.so \ |
| 71 | + --output-format csv \ |
| 72 | + --output-file /tmp/results.csv \ |
| 73 | + --raw \ |
| 74 | + -- benchmarks-next/blake3-scalar/benchmark.wasm |
| 75 | + ./target/release/sightglass-cli summarize --input-format csv --output-format csv -f /tmp/results.csv > /tmp/results_summarized.csv |
| 76 | +
|
| 77 | + - name: Setup Python |
| 78 | + uses: actions/setup-python@v2 |
| 79 | + with: |
| 80 | + python-version: '3.9' |
| 81 | + |
| 82 | + - name: Post Process Perf Results |
| 83 | + run: | |
| 84 | + pip3 install pandas |
| 85 | + pip3 install numpy |
| 86 | + grep -v "cycles" /tmp/results_summarized.csv > /tmp/results_cycles_summarized.csv |
| 87 | + sed -i 's/\/tmp\/wasmtime_commit.so/patch/g' /tmp/results_cycles_summarized.csv |
| 88 | + sed -i 's/\/tmp\/wasmtime_main.so/main/g' /tmp/results_cycles_summarized.csv |
| 89 | + python3 -c "import pandas as pd; pp = pd.read_csv('/tmp/results_cycles_summarized.csv', usecols=['arch','engine','phase', 'mean'], header=0); pp_sorted = pp.sort_values('phase', ascending=True); print(pp_sorted.to_string(index=False));" > /tmp/results_cycles_summarized_pp_sorted.csv |
| 90 | + sed -i 's/^/ /' /tmp/results_cycles_summarized_pp_sorted.csv |
| 91 | + sed -i 's/ \+/|/g' /tmp/results_cycles_summarized_pp_sorted.csv |
| 92 | + sed -i -z 's/\n/|\n/g' /tmp/results_cycles_summarized_pp_sorted.csv |
| 93 | + sed -i '2 i\ |-|-|-|-|' /tmp/results_cycles_summarized_pp_sorted.csv |
| 94 | + sed -i '1 i\ Performance results in clockticks (lower is better):\n' /tmp/results_cycles_summarized_pp_sorted.csv |
| 95 | +
|
| 96 | + #python3 -c "import pandas as pd; pp = pd.read_csv('/tmp/results_cycles_summarized.csv', usecols=['arch','engine','phase', 'mean'], header=0); pp_sorted = pp; print(pp_sorted.to_string(index=False)); pp_sorted.insert(4, '%Change (1-Head/Patch)',[ 1 -pp_sorted.loc[0][3]/pp_sorted.loc[3][3], 0, 1-pp_sorted.loc[1][3]/pp_sorted.loc[4][3],0, 1-pp_sorted.loc[2][3]/pp_sorted.loc[5][3] ,0], True); print(pp_sorted)" > /tmp/results_cycles_summarized_pp_sorted2.csv |
| 97 | + python3 -c "import pandas as pd; pp = pd.read_csv('/tmp/results_cycles_summarized.csv', usecols=['arch','engine','phase', 'mean'], header=0); pp_sorted = pp; pp_sorted.insert(4, '%Change_(1-Head/Patch)',[ 1 -pp_sorted.loc[0][3]/pp_sorted.loc[3][3], 1-pp_sorted.loc[1][3]/pp_sorted.loc[4][3], 1-pp_sorted.loc[2][3]/pp_sorted.loc[5][3],0,0,0], True); pp_sorted.drop('mean', axis=1, inplace=True); print(pp_sorted.to_string(index=False))" > /tmp/results_cycles_summarized_pp_sorted2.csv |
| 98 | + sed -i 's/^/ /' /tmp/results_cycles_summarized_pp_sorted2.csv |
| 99 | + sed -i 's/ \+/|/g' /tmp/results_cycles_summarized_pp_sorted2.csv |
| 100 | + sed -i -z 's/\n/|\n/g' /tmp/results_cycles_summarized_pp_sorted2.csv |
| 101 | + sed -i '2 i\ |-|-|-|-|' /tmp/results_cycles_summarized_pp_sorted2.csv |
| 102 | + sed -i '/main/d' /tmp/results_cycles_summarized_pp_sorted2.csv |
| 103 | + sed -i '1 i\ Performance results based on clockticks comparison with main HEAD (higher %change shows improvement):\n' /tmp/results_cycles_summarized_pp_sorted2.csv |
| 104 | +
|
| 105 | + - id: get-comment-body |
| 106 | + name: Get Result |
| 107 | + run: | |
| 108 | + body="$(cat /tmp/results_cycles_summarized_pp_sorted.csv)" |
| 109 | + body="${body//'%'/'%25'}" |
| 110 | + body="${body//$'\n'/'%0A'}" |
| 111 | + body="${body//$'\r'/'%0D'}" |
| 112 | + echo "::set-output name=body::$body" |
| 113 | +
|
| 114 | + - name: Find PR |
| 115 | + uses: jwalton/gh-find-current-pr@v1 |
| 116 | + id: findPr |
| 117 | + with: |
| 118 | + # Can be "open", "closed", or "all". Defaults to "open". |
| 119 | + state: open |
| 120 | + |
| 121 | + - name: Publish Results |
| 122 | + uses: peter-evans/create-or-update-comment@v1 |
| 123 | + with: |
| 124 | + issue-number: ${{ steps.findPr.outputs.pr }} |
| 125 | + reactions: rocket |
| 126 | + body: ${{ steps.get-comment-body.outputs.body }} |
| 127 | + |
| 128 | + - id: get-comment-body2 |
| 129 | + name: Get Result 2 |
| 130 | + run: | |
| 131 | + body2="$(cat /tmp/results_cycles_summarized_pp_sorted2.csv)" |
| 132 | + body2="${body2//'%'/'%25'}" |
| 133 | + body2="${body2//$'\n'/'%0A'}" |
| 134 | + body2="${body2//$'\r'/'%0D'}" |
| 135 | + echo "::set-output name=body2::$body2" |
| 136 | +
|
| 137 | + - name: Publish Results 2 |
| 138 | + uses: peter-evans/create-or-update-comment@v1 |
| 139 | + with: |
| 140 | + issue-number: ${{ steps.findPr.outputs.pr }} |
| 141 | + reactions: rocket |
| 142 | + body: ${{ steps.get-comment-body2.outputs.body2 }} |
| 143 | + |
| 144 | + # Performance_Aarch64: |
| 145 | + # name: Performance Aarch64 |
| 146 | + # runs-on: [self-hosted, linux, x86-64] |
| 147 | + |
0 commit comments