fork/static-web-server
git clone https://git.julia.blue/fork/static-web-server
ea9f43f
allow-symlink
1name : perfcheck 2on : 3issue_comment : 4types : [ created , edited ] 5paths : 6- .github/workflows/perfcheck.yml 7- .cargo/config.toml 8- scripts/ci/vegeta_report_to_csv.jq 9- Cargo.lock 10- Cargo.toml 11- src/** 12 13jobs : 14benchmark : 15if : github.event.issue.pull_request && contains(github.event.comment.body, '/try+ perfcheck') 16name : benchmark 17runs-on : ubuntu-22.04 18continue-on-error : true 19env : 20# Cargo binary 21CARGO_BIN : cargo 22# When CARGO_BIN is set to CROSS, this is set to `--target matrix.target`. 23TARGET_FLAGS : "" 24# When CARGO_BIN is set to CROSS, TARGET_DIR includes matrix.target. 25TARGET_DIR : ./target 26# Rustc flags needed by the `all` features 27RUSTFLAGS : "--cfg tokio_unstable" 28# SWS features for Cargo build 29CARGO_FEATURES : "--features=all" 30# Version of the vegeta binary 31VEGETA_VERSION : "12.11.1" 32# Command-line parameters for the vegeta binary 33VEGETA_FLAGS : "-workers=4 -connections=100 -rate=${{ matrix.rate }} -duration=10s" 34# Version of the caddy binary 35CADDY_VERSION : "2.7.6" 36 37strategy : 38fail-fast : false 39matrix : 40include : 41- title : "Small file (dynamic compression)" 42url : http://localhost:8080/small.txt 43rate : "1000/s" 44- title : "Small file (pre-compressed)" 45url : http://localhost:8080/small_precompressed.txt 46rate : "1000/s" 47- title : "Large file (dynamic compression)" 48url : http://localhost:8080/large.txt 49rate : "200/s" 50- title : "Large file (pre-compressed)" 51url : http://localhost:8080/large_precompressed.txt 52rate : "500/s" 53- title : "Directory listing (many files)" 54url : http://localhost:8080/ 55rate : "1000/s" 56- title : "Directory listing (empty directory)" 57url : http://localhost:8080/emptydir/ 58rate : "1000/s" 59- title : "Small directory index file" 60url : http://localhost:8080/dirsmallindex/ 61rate : "1000/s" 62- title : "Large directory index file" 63url : http://localhost:8080/dirlargeindex/ 64rate : "200/s" 65- title : "Not found" 66url : http://localhost:8080/not_found 67rate : "1000/s" 68 69steps : 70- name : Checkout repository 71uses : actions/checkout@v4 72with : 73fetch-depth : 1 74 75- name : Checkout benchmark-setup repository 76uses : actions/checkout@v4 77with : 78repository : static-web-server/benchmarks-setup 79ref : v0.2 80path : benchmarks-setup 81fetch-depth : 1 82 83- name : Cache Rust Cargo/Toolchain 84uses : actions/cache@v4 85with : 86path : | 87~/.cargo 88**/target 89key : rust-${{ hashFiles('**/Cargo.lock') }} 90restore-keys : | 91rust- 92 93- name : Install vegeta binary 94run : | 95curl -L https://github.com/tsenart/vegeta/releases/download/v${{ env.VEGETA_VERSION }}/vegeta_${{ env.VEGETA_VERSION }}_linux_amd64.tar.gz | tar xz 96echo "Downloaded vegeta" 97./vegeta --version 98 99- name : Install caddy binary 100run : | 101curl -L https://github.com/caddyserver/caddy/releases/download/v${{ env.CADDY_VERSION }}/caddy_${{ env.CADDY_VERSION }}_linux_amd64.tar.gz | tar xz caddy 102echo "Downloaded caddy" 103./caddy --version 104 105- name : Install web server software 106uses : awalsh128/cache-apt-pkgs-action@latest 107with : 108packages : apache2 lighttpd nginx 109version : 1.0 110 111- name : Install Rust 112uses : dtolnay/rust-toolchain@stable 113with : 114toolchain : stable 115target : x86_64-unknown-linux-gnu 116 117- name : Show command used for Cargo 118run : | 119echo "cargo command is: ${{ env.CARGO_BIN }}" 120echo "target flag is: ${{ env.TARGET_FLAGS }}" 121echo "target dir is: ${{ env.TARGET_DIR }}" 122 123- name : Build release binary 124run : ${{ env.CARGO_BIN }} build --bin static-web-server -vv --release ${{ env.CARGO_FEATURES }} ${{ env.TARGET_FLAGS }} 125 126- name : Initialize graph.csv 127run : echo "Sample, min, mean, 50th, 90th, 95th, 99th, max" > graph.csv 128 129- name : Run SWS benchmark 130run : | 131NAME=$(${{ env.TARGET_DIR }}/release/static-web-server --version | head -n 1 | sed -e 's/^Version: */sws /' -e 's/static-web-server/sws/' -e 's/$/ (src)/') 132REPORT=report_sws.bin 133${{ env.TARGET_DIR }}/release/static-web-server --config-file benchmarks-setup/config/sws.toml & 134sleep 2 135echo "GET ${{ matrix.url }}" | ./vegeta attack -name "$NAME" ${{ env.VEGETA_FLAGS }} > $REPORT 136kill %1 137./vegeta report -type=text $REPORT 138./vegeta report -type=json $REPORT | jq --arg name "$NAME" -r -f scripts/ci/vegeta_report_to_csv.jq >> graph.csv 139 140- name : Run Apache benchmark 141run : | 142NAME=$(apache2 -v | sed 's/.*: //' | sed 's/ .*//' | sed 's!/! !' | tr '[:upper:]' '[:lower:]') 143REPORT=report_apache.bin 144apache2 -D FOREGROUND -f `pwd`/benchmarks-setup/config/apache.conf & 145sleep 2 146echo "GET ${{ matrix.url }}" | ./vegeta attack -name "$NAME" ${{ env.VEGETA_FLAGS }} > $REPORT 147kill %1 148./vegeta report -type=text $REPORT 149./vegeta report -type=json $REPORT | jq --arg name "$NAME" -r -f scripts/ci/vegeta_report_to_csv.jq >> graph.csv 150 151- name : Run lighttpd benchmark 152run : | 153NAME=$(lighttpd -v | sed 's/ .*//' | sed 's!/! !') 154REPORT=report_lighttpd.bin 155lighttpd -D -f `pwd`/benchmarks-setup/config/lighttpd.conf & 156sleep 2 157URL="${{ matrix.url }}" 158if [[ $URL == *"_precompressed"* ]]; then 159# lighttpd does not really support pre-compressed files, request them explicitly 160URL="${{ matrix.url }}.gz" 161fi 162echo "GET $URL" | ./vegeta attack -name "$NAME" ${{ env.VEGETA_FLAGS }} > $REPORT 163kill %1 164./vegeta report -type=text $REPORT 165./vegeta report -type=json $REPORT | jq --arg name "$NAME" -r -f scripts/ci/vegeta_report_to_csv.jq >> graph.csv 166 167- name : Run nginx benchmark 168run : | 169NAME=$(nginx -v 2>&1 | sed 's/.*: //' | sed 's/ .*//' | sed 's!/! !') 170REPORT=report_nginx.bin 171nginx -c `pwd`/benchmarks-setup/config/nginx.conf & 172sleep 2 173echo "GET ${{ matrix.url }}" | ./vegeta attack -name "$NAME" ${{ env.VEGETA_FLAGS }} > $REPORT 174kill %1 175./vegeta report -type=text $REPORT 176./vegeta report -type=json $REPORT | jq --arg name "$NAME" -r -f scripts/ci/vegeta_report_to_csv.jq >> graph.csv 177 178- name : Run caddy benchmark 179run : | 180NAME="caddy $(./caddy -v | sed 's/ .*//')" 181REPORT=report_caddy.bin 182./caddy run -c `pwd`/benchmarks-setup/config/Caddyfile & 183sleep 2 184echo "GET ${{ matrix.url }}" | ./vegeta attack -name "$NAME" ${{ env.VEGETA_FLAGS }} > $REPORT 185kill %1 186./vegeta report -type=text $REPORT 187./vegeta report -type=json $REPORT | jq --arg name "$NAME" -r -f scripts/ci/vegeta_report_to_csv.jq >> graph.csv 188 189- name : Set up Python 190uses : actions/setup-python@v5 191with : 192python-version : '3.12' 193 194- name : Install pipx 195run : pip install pipx 196 197- name : Produce plot 198run : | 199./vegeta plot --title "${{ matrix.title }}" report_*.bin > detailed_plot.html 200cat graph.csv 201cat graph.csv | sed -e 's/,/|/g' -e 's/"//g' -e 's/^/|/' -e 's/$/|/' -e '2 i |-|-|-|-|-|-|-|-|' >> $GITHUB_STEP_SUMMARY 202pipx run graph-cli --barh --bar-label --xlabel '' --ylabel 'Latency (ms)' --title "${{ matrix.title }}" --figsize 1200x800 --fontsize 10 --ytick-angle 45 --ytick-align top -o overview.png graph.csv 203 204- name : Upload benchmark plots 205uses : actions/upload-artifact@v4 206with : 207name : ${{ matrix.title }} 208path : | 209detailed_plot.html 210overview.png 211 212merge-artifacts : 213if : github.event.issue.pull_request && contains(github.event.comment.body, '/try+ perfcheck') 214name : merge-artifacts 215needs : benchmark 216runs-on : ubuntu-22.04 217continue-on-error : true 218 219steps : 220- name : Merge benchmark plots 221uses : actions/upload-artifact/merge@v4 222with : 223name : Benchmark plots 224separate-directories : true 225delete-merged : true