From 3d396bd6aafd709e10648a56dd36b9fd4f64410d Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Wed, 2 Feb 2022 10:46:17 -0800 Subject: [PATCH] Move benchmarks to a new `ring-bench` crate. Move the Criterion.rs dependency out of *ring* into a new `ring-benches` crate. This speeds up many build scenerios by eliminating a bunch of dependencies from *ring*'s dependency tree for `cargo test`. --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ Cargo.toml | 16 ++++++---------- bench/Cargo.toml | 21 +++++++++++++++++++++ {benches => bench}/aead.rs | 0 {benches => bench}/x25519.rs | 0 5 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 bench/Cargo.toml rename {benches => bench}/aead.rs (100%) rename {benches => bench}/x25519.rs (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c58098212d..2f478d406d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -155,6 +155,7 @@ jobs: - run: sh mk/package.sh shell: bash + # Intentionally excludes benchmarks for build performance reasons. test: # Don't run duplicate `push` jobs for the repo owner's PRs. if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository @@ -322,6 +323,28 @@ jobs: (!contains(matrix.host_os, 'macos') || matrix.mode != '--release') }} run: mk/check-symbol-prefixes.sh --target=${{ matrix.target }} + test-bench: + # Don't run duplicate `push` jobs for the repo owner's PRs. + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository + + runs-on: ubuntu-22.04 + + steps: + - run: sudo apt-get update -y + + - uses: briansmith/actions-checkout@v2 + with: + persist-credentials: false + + - run: mk/install-build-tools.sh --target=x86_64-unknown-linux-gnu + + - uses: briansmith/actions-rs-toolchain@v1 + with: + override: true + toolchain: stable + + - run: cargo test -p ring-bench --all-features --all-targets + # XXX: GitHub Actions won't let us test all the combinations of features in # the "test" matrix because the resultant matrix would be larger than the # maximum they allow. diff --git a/Cargo.toml b/Cargo.toml index cd6c608612..676a3e36df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -192,9 +192,6 @@ libc = { version = "0.2.100", default-features = false } [build-dependencies] cc = { version = "1.0.69", default-features = false } -[dev-dependencies] -criterion = { version = "0.4", default-features = false } - [features] # These features are documented in the top-level module's documentation. default = ["alloc", "dev_urandom_fallback"] @@ -225,10 +222,9 @@ lto = true debug-assertions = false codegen-units = 1 -[[bench]] -name = "aead" -harness = false - -[[bench]] -name = "x25519" -harness = false +[workspace] +members = [ + # intentionally not a default member so that `cargo test` doesn't cause criterion.rs and all its + # dependencies to get built. + "bench", +] diff --git a/bench/Cargo.toml b/bench/Cargo.toml new file mode 100644 index 0000000000..3beccd2f5a --- /dev/null +++ b/bench/Cargo.toml @@ -0,0 +1,21 @@ +[package] +edition = "2021" +name = "ring-bench" +publish = false +version = "0.1.0" + +[dependencies] +ring = { path = "../" } + +[dev-dependencies] +criterion = { version = "0.4", default-features = false } + +[[bench]] +name = "aead" +harness = false +path = "aead.rs" + +[[bench]] +name = "x25519" +harness = false +path = "x25519.rs" diff --git a/benches/aead.rs b/bench/aead.rs similarity index 100% rename from benches/aead.rs rename to bench/aead.rs diff --git a/benches/x25519.rs b/bench/x25519.rs similarity index 100% rename from benches/x25519.rs rename to bench/x25519.rs