Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/hyperlight_host/benches/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,10 @@ fn guest_call_benchmark_large_param(c: &mut Criterion) {
#[cfg(target_os = "windows")]
group.sample_size(10); // This benchmark is very slow on Windows, so we reduce the sample size to avoid long test runs.

// This benchmark includes time to first clone a vector and string, so it is not a "pure' benchmark of the guest call, but it's still useful
group.bench_function("guest_call_with_large_parameters", |b| {
const SIZE: usize = 50 * 1024 * 1024; // 50 MB
let large_vec = vec![0u8; SIZE];
let large_string = unsafe { String::from_utf8_unchecked(large_vec.clone()) }; // Safety: indeed above vec is valid utf8
let large_string = String::from_utf8(large_vec.clone()).unwrap();

let mut config = SandboxConfiguration::default();
config.set_input_data_size(2 * SIZE + (1024 * 1024)); // 2 * SIZE + 1 MB, to allow 1MB for the rest of the serialized function call
Expand All @@ -397,11 +396,14 @@ fn guest_call_benchmark_large_param(c: &mut Criterion) {
.unwrap();
let mut sandbox = sandbox.evolve().unwrap();

b.iter(|| {
sandbox
.call::<()>("LargeParameters", (large_vec.clone(), large_string.clone()))
.unwrap();
});
b.iter_with_setup(
|| (large_vec.clone(), large_string.clone()),
|(vec_clone, string_clone)| {
sandbox
.call::<()>("LargeParameters", (vec_clone, string_clone))
.unwrap()
},
);
});

group.finish();
Expand Down