From b292162839769f1d6f7f7827d79f8ffa077409e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Gonz=C3=A1lez=20Calder=C3=B3n?= Date: Thu, 28 Nov 2024 16:43:09 -0300 Subject: [PATCH 1/3] Add time to CallInfo --- crates/blockifier/src/execution/call_info.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/blockifier/src/execution/call_info.rs b/crates/blockifier/src/execution/call_info.rs index e078376b48..75fce412e4 100644 --- a/crates/blockifier/src/execution/call_info.rs +++ b/crates/blockifier/src/execution/call_info.rs @@ -145,6 +145,7 @@ pub struct CallInfo { pub charged_resources: ChargedResources, // Additional information gathered during execution. + pub time: std::time::Duration, pub storage_read_values: Vec, pub accessed_storage_keys: HashSet, pub read_class_hash_values: Vec, From 2ad9ecad71bd71304b80c36992f41568c82313ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Gonz=C3=A1lez=20Calder=C3=B3n?= Date: Fri, 6 Dec 2024 16:01:04 -0300 Subject: [PATCH 2/3] Save time to CallInfo --- .../src/execution/entry_point_execution.rs | 1 + .../blockifier/src/execution/execution_utils.rs | 16 +++++++++++----- .../execution/native/entry_point_execution.rs | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/blockifier/src/execution/entry_point_execution.rs b/crates/blockifier/src/execution/entry_point_execution.rs index f1bf7ef01f..e6035c925d 100644 --- a/crates/blockifier/src/execution/entry_point_execution.rs +++ b/crates/blockifier/src/execution/entry_point_execution.rs @@ -454,6 +454,7 @@ pub fn finalize_execution( accessed_storage_keys: syscall_handler_base.accessed_keys, read_class_hash_values: syscall_handler_base.read_class_hash_values, accessed_contract_addresses: syscall_handler_base.accessed_contract_addresses, + time: std::time::Duration::default(), }) } diff --git a/crates/blockifier/src/execution/execution_utils.rs b/crates/blockifier/src/execution/execution_utils.rs index 7c093b91d6..b0732a4e46 100644 --- a/crates/blockifier/src/execution/execution_utils.rs +++ b/crates/blockifier/src/execution/execution_utils.rs @@ -124,17 +124,19 @@ pub fn execute_entry_point_call( state: &mut dyn State, context: &mut EntryPointExecutionContext, ) -> EntryPointExecutionResult { - match compiled_class { + let pre_time = std::time::Instant::now(); + + let mut result = match compiled_class { RunnableCompiledClass::V0(compiled_class) => { deprecated_entry_point_execution::execute_entry_point_call( call, compiled_class, state, context, - ) + )? } RunnableCompiledClass::V1(compiled_class) => { - entry_point_execution::execute_entry_point_call(call, compiled_class, state, context) + entry_point_execution::execute_entry_point_call(call, compiled_class, state, context)? } #[cfg(feature = "cairo_native")] RunnableCompiledClass::V1Native(compiled_class) => { @@ -153,10 +155,14 @@ pub fn execute_entry_point_call( compiled_class, state, context, - ) + )? // } } - } + }; + + result.time = pre_time.elapsed(); + + Ok(result) } pub fn update_remaining_gas(remaining_gas: &mut u64, call_info: &CallInfo) { diff --git a/crates/blockifier/src/execution/native/entry_point_execution.rs b/crates/blockifier/src/execution/native/entry_point_execution.rs index 719bbc775e..505d6b1713 100644 --- a/crates/blockifier/src/execution/native/entry_point_execution.rs +++ b/crates/blockifier/src/execution/native/entry_point_execution.rs @@ -99,5 +99,6 @@ fn create_callinfo( accessed_contract_addresses: syscall_handler.base.accessed_contract_addresses, read_class_hash_values: syscall_handler.base.read_class_hash_values, tracked_resource: TrackedResource::SierraGas, + time: std::time::Duration::default(), }) } From 5f91e8ee927b6f467d4c4098d3b5a5f2ead9cb39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Gonz=C3=A1lez=20Calder=C3=B3n?= Date: Wed, 11 Dec 2024 17:26:09 -0300 Subject: [PATCH 3/3] Move time measure to inside of the match --- .../src/execution/execution_utils.rs | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/crates/blockifier/src/execution/execution_utils.rs b/crates/blockifier/src/execution/execution_utils.rs index b0732a4e46..68f542cbc6 100644 --- a/crates/blockifier/src/execution/execution_utils.rs +++ b/crates/blockifier/src/execution/execution_utils.rs @@ -124,19 +124,28 @@ pub fn execute_entry_point_call( state: &mut dyn State, context: &mut EntryPointExecutionContext, ) -> EntryPointExecutionResult { - let pre_time = std::time::Instant::now(); - - let mut result = match compiled_class { + match compiled_class { RunnableCompiledClass::V0(compiled_class) => { - deprecated_entry_point_execution::execute_entry_point_call( + let pre_time = std::time::Instant::now(); + let mut result = deprecated_entry_point_execution::execute_entry_point_call( call, compiled_class, state, context, - )? + )?; + result.time = pre_time.elapsed(); + Ok(result) } RunnableCompiledClass::V1(compiled_class) => { - entry_point_execution::execute_entry_point_call(call, compiled_class, state, context)? + let pre_time = std::time::Instant::now(); + let mut result = entry_point_execution::execute_entry_point_call( + call, + compiled_class, + state, + context, + )?; + result.time = pre_time.elapsed(); + Ok(result) } #[cfg(feature = "cairo_native")] RunnableCompiledClass::V1Native(compiled_class) => { @@ -150,19 +159,18 @@ pub fn execute_entry_point_call( // context, // ) // } else { - native_entry_point_execution::execute_entry_point_call( + let pre_time = std::time::Instant::now(); + let mut result = native_entry_point_execution::execute_entry_point_call( call, compiled_class, state, context, - )? + )?; + result.time = pre_time.elapsed(); + Ok(result) // } } - }; - - result.time = pre_time.elapsed(); - - Ok(result) + } } pub fn update_remaining_gas(remaining_gas: &mut u64, call_info: &CallInfo) {