-
Notifications
You must be signed in to change notification settings - Fork 150
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
Changes from 7 commits
3efac22
c8cb4ef
2bb51a6
16302ea
52c205f
45df7bd
44e925c
f10e216
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,24 +14,37 @@ See the License for the specific language governing permissions and | |
limitations under the License. | ||
*/ | ||
|
||
// Benchmarks are only meaningful and should only run with optimized builds. | ||
// Unoptimized builds have different performance characteristics and would not provide | ||
// useful benchmarking data for performance regression testing. | ||
|
||
#[cfg(optimized_build)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would just be easier to use the cargo syntax There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was undone in the next commit for some reason There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed the conditional compilation approach. Instead of using |
||
use criterion::{Criterion, criterion_group, criterion_main}; | ||
#[cfg(optimized_build)] | ||
use hyperlight_host::GuestBinary; | ||
#[cfg(optimized_build)] | ||
use hyperlight_host::sandbox::{ | ||
Callable, MultiUseSandbox, SandboxConfiguration, UninitializedSandbox, | ||
}; | ||
#[cfg(optimized_build)] | ||
use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox; | ||
#[cfg(optimized_build)] | ||
use hyperlight_host::sandbox_state::transition::Noop; | ||
#[cfg(optimized_build)] | ||
use hyperlight_testing::simple_guest_as_string; | ||
|
||
#[cfg(optimized_build)] | ||
fn create_uninit_sandbox() -> UninitializedSandbox { | ||
let path = simple_guest_as_string().unwrap(); | ||
UninitializedSandbox::new(GuestBinary::FilePath(path), None).unwrap() | ||
} | ||
|
||
#[cfg(optimized_build)] | ||
fn create_multiuse_sandbox() -> MultiUseSandbox { | ||
create_uninit_sandbox().evolve(Noop::default()).unwrap() | ||
} | ||
|
||
#[cfg(optimized_build)] | ||
fn guest_call_benchmark(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("guest_functions"); | ||
|
||
|
@@ -79,6 +92,7 @@ fn guest_call_benchmark(c: &mut Criterion) { | |
group.finish(); | ||
} | ||
|
||
#[cfg(optimized_build)] | ||
fn guest_call_benchmark_large_param(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("guest_functions_with_large_parameters"); | ||
#[cfg(target_os = "windows")] | ||
|
@@ -114,6 +128,7 @@ fn guest_call_benchmark_large_param(c: &mut Criterion) { | |
group.finish(); | ||
} | ||
|
||
#[cfg(optimized_build)] | ||
fn sandbox_benchmark(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("sandboxes"); | ||
|
||
|
@@ -153,9 +168,21 @@ fn sandbox_benchmark(c: &mut Criterion) { | |
group.finish(); | ||
} | ||
|
||
#[cfg(optimized_build)] | ||
criterion_group! { | ||
name = benches; | ||
config = Criterion::default(); | ||
targets = guest_call_benchmark, sandbox_benchmark, guest_call_benchmark_large_param | ||
} | ||
|
||
#[cfg(optimized_build)] | ||
criterion_main!(benches); | ||
|
||
// Provide a fallback main function for unoptimized builds | ||
// This prevents compilation errors while providing a clear message | ||
#[cfg(unoptimized_build)] | ||
|
||
fn main() { | ||
panic!( | ||
"Benchmarks must be run with optimized builds only. Use `cargo bench --release` or `just bench`." | ||
); | ||
} |
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.
This doesn't seem right after #703
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.
Fixed the workflow to use correct feature flags after PR #703. Changed from
mshv3
tomshv
parameter handling to match the new hypervisor defaults. Fixed in commit f10e216.