Skip to content

Commit 4e51e3b

Browse files
committed
Don't clone params on measured hotpath
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
1 parent 620339a commit 4e51e3b

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/hyperlight_host/benches/benchmarks.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,10 @@ fn guest_call_benchmark_large_param(c: &mut Criterion) {
379379
#[cfg(target_os = "windows")]
380380
group.sample_size(10); // This benchmark is very slow on Windows, so we reduce the sample size to avoid long test runs.
381381

382-
// 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
383382
group.bench_function("guest_call_with_large_parameters", |b| {
384383
const SIZE: usize = 50 * 1024 * 1024; // 50 MB
385384
let large_vec = vec![0u8; SIZE];
386-
let large_string = unsafe { String::from_utf8_unchecked(large_vec.clone()) }; // Safety: indeed above vec is valid utf8
385+
let large_string = String::from_utf8(large_vec.clone()).unwrap();
387386

388387
let mut config = SandboxConfiguration::default();
389388
config.set_input_data_size(2 * SIZE + (1024 * 1024)); // 2 * SIZE + 1 MB, to allow 1MB for the rest of the serialized function call

0 commit comments

Comments
 (0)