Skip to content

Commit 892af06

Browse files
Copilotsimongdavies
andcommitted
Restrict benchmarks to release builds only
Co-authored-by: simongdavies <1397489+simongdavies@users.noreply.github.com>
1 parent 30e1ff2 commit 892af06

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

.github/workflows/Benchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5858

5959
- name: Run Benchmarks
60-
run: just bench-ci main release ${{ matrix.hypervisor == 'mshv3' && 'mshv3' || ''}}
60+
run: just bench-ci main ${{ matrix.hypervisor == 'mshv3' && 'mshv3' || ''}}
6161

6262
- uses: actions/upload-artifact@v4
6363
with:

.github/workflows/dep_rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,5 @@ jobs:
151151

152152
- name: Run benchmarks
153153
run: |
154-
just bench-ci main ${{ matrix.config }} ${{ matrix.hypervisor == 'mshv3' && 'mshv3' || ''}}
154+
just bench-ci main ${{ matrix.hypervisor == 'mshv3' && 'mshv3' || ''}}
155155
if: ${{ matrix.config == 'release' }}

Justfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fmt-apply:
163163
cargo +nightly fmt --manifest-path src/hyperlight_guest_capi/Cargo.toml
164164

165165
clippy target=default-target: (witguest-wit)
166-
cargo clippy --all-targets --all-features --profile={{ if target == "debug" { "dev" } else { target } }} -- -D warnings
166+
cargo clippy {{ if target == "debug" { "--lib --bins --tests --examples" } else { "--all-targets" } }} --all-features --profile={{ if target == "debug" { "dev" } else { target } }} -- -D warnings
167167

168168
clippy-guests target=default-target: (witguest-wit)
169169
cd src/tests/rust_guests/simpleguest && cargo clippy --profile={{ if target == "debug" { "dev" } else { target } }} -- -D warnings
@@ -229,11 +229,13 @@ bench-download os hypervisor cpu tag="":
229229
tar -zxvf target/benchmarks_{{ os }}_{{ hypervisor }}_{{ cpu }}.tar.gz -C target/criterion/ --strip-components=1
230230

231231
# Warning: compares to and then OVERWRITES the given baseline
232-
bench-ci baseline target=default-target features="":
233-
cargo bench --profile={{ if target == "debug" { "dev" } else { target } }} {{ if features =="" {''} else { "--features " + features } }} -- --verbose --save-baseline {{ baseline }}
232+
# Benchmarks only run with release builds for performance consistency
233+
bench-ci baseline features="":
234+
cargo bench --profile=release {{ if features =="" {''} else { "--features " + features } }} -- --verbose --save-baseline {{ baseline }}
234235

235-
bench target=default-target features="":
236-
cargo bench --profile={{ if target == "debug" { "dev" } else { target } }} {{ if features =="" {''} else { "--features " + features } }} -- --verbose
236+
# Benchmarks only run with release builds for performance consistency
237+
bench features="":
238+
cargo bench --profile=release {{ if features =="" {''} else { "--features " + features } }} -- --verbose
237239

238240
###############
239241
### FUZZING ###

docs/benchmarking-hyperlight.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ Found 1 outliers among 100 measurements (1.00%)
7272
7373
## Running benchmarks locally
7474
75-
Use `just bench [debug/release]` parameter to run benchmarks. Comparing local benchmarks results to github-saved benchmarks doesn't make much sense, since you'd be using different hardware, but you can use `just bench-download os hypervisor [tag] ` to download and extract the GitHub release benchmarks to the correct place folder. You can then run `just bench-ci main` to compare to (and overwrite) the previous release benchmarks. Note that `main` is the name of the baselines stored in GitHub.
75+
Use `just bench` to run benchmarks. Benchmarks only run with release builds for performance consistency. Comparing local benchmarks results to github-saved benchmarks doesn't make much sense, since you'd be using different hardware, but you can use `just bench-download os hypervisor [tag] ` to download and extract the GitHub release benchmarks to the correct place folder. You can then run `just bench-ci main` to compare to (and overwrite) the previous release benchmarks. Note that `main` is the name of the baselines stored in GitHub.

src/hyperlight_host/benches/benchmarks.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// Benchmarks are only meaningful and should only run with release builds.
18+
// Debug builds have different performance characteristics and would not provide
19+
// useful benchmarking data for performance regression testing.
20+
#[cfg(debug_assertions)]
21+
compile_error!(
22+
"Benchmarks must be run with release builds only. Use `cargo bench --release` or `just bench`."
23+
);
24+
1725
use criterion::{Criterion, criterion_group, criterion_main};
1826
use hyperlight_host::GuestBinary;
1927
use hyperlight_host::sandbox::{

0 commit comments

Comments
 (0)