Skip to content

Commit fecbe44

Browse files
Copilotjsturtevant
andcommitted
Enforce release builds for benchmarks in Justfile and source code
Co-authored-by: jsturtevant <[email protected]>
1 parent 1c7330f commit fecbe44

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

Justfile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,15 @@ bench-download os hypervisor cpu tag="":
271271
tar -zxvf target/benchmarks_{{ os }}_{{ hypervisor }}_{{ cpu }}.tar.gz -C target/criterion/ --strip-components=1
272272

273273
# Warning: compares to and then OVERWRITES the given baseline
274-
bench-ci baseline target=default-target features="":
275-
cargo bench --profile={{ if target == "debug" { "dev" } else { target } }} {{ if features =="" {''} else { "--features " + features } }} -- --verbose --save-baseline {{ baseline }}
276-
277-
bench target=default-target features="":
278-
cargo bench --profile={{ if target == "debug" { "dev" } else { target } }} {{ if features =="" {''} else { "--features " + features } }} -- --verbose
274+
bench-ci baseline target="release" features="":
275+
@# Benchmarks should only be run with release builds for meaningful results
276+
@if [ "{{ target }}" != "release" ]; then echo "Error: Benchmarks can only be run with release builds. Use 'just bench-ci <baseline> release' instead."; exit 1; fi
277+
cargo bench --profile=release {{ if features =="" {''} else { "--features " + features } }} -- --verbose --save-baseline {{ baseline }}
278+
279+
bench target="release" features="":
280+
@# Benchmarks should only be run with release builds for meaningful results
281+
@if [ "{{ target }}" != "release" ]; then echo "Error: Benchmarks can only be run with release builds. Use 'just bench release' instead."; exit 1; fi
282+
cargo bench --profile=release {{ if features =="" {''} else { "--features " + features } }} -- --verbose
279283

280284
###############
281285
### FUZZING ###

docs/benchmarking-hyperlight.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,6 @@ 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 with release builds (the only supported configuration). Comparing local benchmark 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.
76+
77+
**Important**: Benchmarks can only be run with release builds to ensure meaningful performance measurements. Debug builds are not supported for benchmarking.

src/hyperlight_host/benches/benchmarks.rs

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

17+
// Ensure benchmarks only run with release builds for meaningful performance measurements
18+
#[cfg(debug_assertions)]
19+
compile_error!(
20+
"Benchmarks can only be run with release builds. Use '--release' flag when running benchmarks."
21+
);
22+
1723
use criterion::{Criterion, criterion_group, criterion_main};
1824
use hyperlight_host::GuestBinary;
1925
use hyperlight_host::sandbox::{

src/tests/rust_guests/witguest/Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)