diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 3631878189..dad76db238 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -16,6 +16,11 @@ jobs: runs-on: ubuntu steps: - uses: actions/checkout@v4 + - name: Setup AWS CLI + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: arn:aws:iam::375504701696:role/GitHubBenchmarkRole + aws-region: us-east-1 - name: Upload Commit Metadata shell: bash run: | @@ -57,23 +62,14 @@ jobs: RUSTFLAGS: '-C target-cpu=native' run: | cargo install cargo-criterion - - cargo criterion --bench ${{ matrix.benchmark.id }} --message-format=json 2>&1 | tee out.json - - cat out.json - sudo apt-get update && sudo apt-get install -y jq - jq --raw-input --compact-output ' - fromjson? - | [ (if .mean != null then {name: .id, value: .mean.estimate, unit: .unit, range: ((.mean.upper_bound - .mean.lower_bound) / 2) } else {} end), - (if .throughput != null then {name: (.id + " throughput"), value: .throughput[].per_iteration, unit: .throughput[].unit, range: 0} else {} end), - {name, value, unit, range} ] - | .[] - | select(.value != null) - ' \ - out.json \ - | jq --slurp --compact-output '.' >${{ matrix.benchmark.id }}.json + cargo criterion \ + --bench ${{ matrix.benchmark.id }} \ + --message-format=json \ + | bash scripts/coerce-criterion-json.sh | + > ${{ matrix.benchmark.id }}.json + - name: Setup AWS CLI uses: aws-actions/configure-aws-credentials@v1 with: diff --git a/bench-vortex/src/lib.rs b/bench-vortex/src/lib.rs index 3bf535bb02..af5abff3f2 100644 --- a/bench-vortex/src/lib.rs +++ b/bench-vortex/src/lib.rs @@ -4,6 +4,7 @@ use std::env::temp_dir; use std::fs::{create_dir_all, File}; use std::future::Future; use std::path::{Path, PathBuf}; +use std::process::Command; use std::sync::{Arc, LazyLock}; use std::time::Duration; @@ -279,8 +280,20 @@ pub struct JsonValue { pub name: String, pub unit: String, pub value: u128, + pub commit_id: String, } +pub static GIT_COMMIT_ID: LazyLock = LazyLock::new(|| { + String::from_utf8( + Command::new("git") + .args(["rev-parse", "HEAD"]) + .output() + .unwrap() + .stdout, + ) + .unwrap() +}); + impl Measurement { pub fn to_json(&self) -> JsonValue { let name = format!( @@ -294,6 +307,7 @@ impl Measurement { name, unit: "ns".to_string(), value: self.time.as_nanos(), + commit_id: GIT_COMMIT_ID.to_string(), } } }