-
Notifications
You must be signed in to change notification settings - Fork 134
Make benchmarks only run with release builds #641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@copilot |
Co-authored-by: simongdavies <1397489+simongdavies@users.noreply.github.com>
5c65276
to
892af06
Compare
// Debug builds have different performance characteristics and would not provide | ||
// useful benchmarking data for performance regression testing. | ||
#[cfg(debug_assertions)] | ||
compile_error!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes I run benchmarks in release mode with debug symbols, for better stacktraces. Can we check opt level instead of debug symbols?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, I think we have a release config with symbols, I think we could use that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right! I've updated the implementation to check the actual optimization level instead of debug assertions. The new approach uses a build script to detect opt-level
and sets custom cfg flags: unoptimized_build
for opt-level 0 and optimized_build
for opt-level 1+.
This now allows running benchmarks in release mode with debug symbols (like the existing release-with-debug
profile) while still preventing execution with unoptimized builds. Fixed in commit 646e8fd.
…hmarks Co-authored-by: ludfjig <4257730+ludfjig@users.noreply.github.com>
The The clippy commands now work correctly:
This approach allows benchmarks to run with any optimized build (opt-level 1+) while preventing execution in unoptimized builds (opt-level 0). |
Justfile
Outdated
@@ -163,7 +163,7 @@ fmt-apply: | |||
cargo +nightly fmt --manifest-path src/hyperlight_guest_capi/Cargo.toml | |||
|
|||
clippy target=default-target: (witguest-wit) | |||
cargo clippy --all-targets --all-features --profile={{ if target == "debug" { "dev" } else { target } }} -- -D warnings | |||
cargo clippy {{ if target == "debug" { "--lib --bins --tests --examples" } else { "--all-targets" } }} --all-features --profile={{ if target == "debug" { "dev" } else { target } }} -- -D warnings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot please undo these changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot try again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted the clippy command changes in the Justfile as requested. The command now uses --all-targets
again instead of conditional target selection. Fixed in commit 1eafa6f.
Co-authored-by: simongdavies <1397489+simongdavies@users.noreply.github.com>
This PR enforces that benchmarks can only be run with release builds, preventing execution with debug builds which would provide inconsistent and misleading performance data.
Changes Made
1. Updated Justfile Commands
target
parameter frombench
andbench-ci
commands--profile=release
Before:
After:
2. Added Compile-Time Enforcement
Added a compile-time check in the benchmark source code that prevents compilation in debug mode:
3. Updated GitHub Workflows
release
parameter frombench-ci
call (now defaults to release)${{ matrix.config }}
parameter frombench-ci
call (already had release-only guard)4. Updated Documentation
Updated
docs/benchmarking-hyperlight.md
to reflect that only release builds are supported, removing references to debug benchmark support.Validation
All changes have been tested to ensure:
just bench
andjust bench-ci
commands use release profileThis ensures benchmarks provide consistent, meaningful performance data for regression testing while preventing accidental execution with debug builds.
Fixes #638.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.