@@ -15,11 +15,12 @@ limitations under the License.
1515*/
1616
1717use std:: sync:: { Arc , Mutex } ;
18+ use std:: time:: Duration ;
1819
1920use criterion:: { criterion_group, criterion_main, Criterion } ;
2021use hyperlight_common:: flatbuffer_wrappers:: function_types:: { ParameterValue , ReturnType } ;
2122use hyperlight_host:: func:: HostFunction2 ;
22- use hyperlight_host:: sandbox:: { MultiUseSandbox , UninitializedSandbox } ;
23+ use hyperlight_host:: sandbox:: { MultiUseSandbox , SandboxConfiguration , UninitializedSandbox } ;
2324use hyperlight_host:: sandbox_state:: sandbox:: EvolvableSandbox ;
2425use hyperlight_host:: sandbox_state:: transition:: Noop ;
2526use hyperlight_host:: GuestBinary ;
@@ -69,6 +70,40 @@ fn guest_call_benchmark(c: &mut Criterion) {
6970 } ) ;
7071 } ) ;
7172
73+ // 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
74+ group. bench_function ( "guest_call_with_large_parameters" , |b| {
75+ const SIZE : usize = 50 * 1024 * 1024 ; // 50 MB
76+ let large_vec = vec ! [ 0u8 ; SIZE ] ;
77+ let large_string = unsafe { String :: from_utf8_unchecked ( large_vec. clone ( ) ) } ; // Safety: indeed above vec is valid utf8
78+
79+ let mut config = SandboxConfiguration :: default ( ) ;
80+ config. set_input_data_size ( 2 * SIZE + ( 1024 * 1024 ) ) ; // 2 * SIZE + 1 MB, to allow 1MB for the rest of the serialized function call
81+ config. set_heap_size ( SIZE as u64 * 15 ) ;
82+ config. set_max_execution_time ( Duration :: from_secs ( 3 ) ) ;
83+
84+ let sandbox = UninitializedSandbox :: new (
85+ GuestBinary :: FilePath ( simple_guest_as_string ( ) . unwrap ( ) ) ,
86+ Some ( config) ,
87+ None ,
88+ None ,
89+ )
90+ . unwrap ( ) ;
91+ let mut sandbox = sandbox. evolve ( Noop :: default ( ) ) . unwrap ( ) ;
92+
93+ b. iter ( || {
94+ sandbox
95+ . call_guest_function_by_name (
96+ "LargeParameters" ,
97+ ReturnType :: Void ,
98+ Some ( vec ! [
99+ ParameterValue :: VecBytes ( large_vec. clone( ) ) ,
100+ ParameterValue :: String ( large_string. clone( ) ) ,
101+ ] ) ,
102+ )
103+ . unwrap ( )
104+ } ) ;
105+ } ) ;
106+
72107 // Benchmarks a guest function call calling into the host.
73108 // The benchmark does **not** include the time to reset the sandbox memory after the call.
74109 group. bench_function ( "guest_call_with_call_to_host_function" , |b| {
0 commit comments