-
Notifications
You must be signed in to change notification settings - Fork 758
Feat/block replay time #7205
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
base: develop
Are you sure you want to change the base?
Feat/block replay time #7205
Changes from all commits
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 |
|---|---|---|
|
|
@@ -13,6 +13,8 @@ | |
| // You should have received a copy of the GNU General Public License | ||
| // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| use std::time::{Duration, Instant}; | ||
|
|
||
| use clarity::vm::costs::ExecutionCost; | ||
| use clarity::vm::Value; | ||
| use regex::{Captures, Regex}; | ||
|
|
@@ -261,6 +263,8 @@ where | |
| for (i, tx) in transactions.iter().enumerate() { | ||
| let tx_len = tx.tx_len(); | ||
|
|
||
| let start = Instant::now(); | ||
|
|
||
| let mut profiler: Option<BlockReplayProfiler> = None; | ||
| let mut profiler_result = BlockReplayProfilerResult::default(); | ||
|
|
||
|
|
@@ -285,7 +289,7 @@ where | |
|
|
||
| let err = match tx_result { | ||
| TransactionResult::Success(tx_result) => { | ||
| txs_receipts.push((tx_result.receipt, profiler_result)); | ||
| txs_receipts.push((tx_result.receipt, start.elapsed(), profiler_result)); | ||
| Ok(()) | ||
| } | ||
| TransactionResult::ProcessingError(e) => { | ||
|
|
@@ -318,8 +322,12 @@ where | |
| let mut rpc_replayed_block = | ||
| RPCReplayedBlock::from_block(&replayed_block, block_fees, tenure_id, parent_block_id); | ||
|
|
||
| for (receipt, profiler_result) in &txs_receipts { | ||
| let transaction = RPCReplayedBlockTransaction::from_receipt(receipt, &profiler_result); | ||
| for (receipt, execution_duration, profiler_result) in &txs_receipts { | ||
| let transaction = RPCReplayedBlockTransaction::from_receipt( | ||
| receipt, | ||
| execution_duration, | ||
| &profiler_result, | ||
| ); | ||
| rpc_replayed_block.transactions.push(transaction); | ||
| } | ||
|
|
||
|
|
@@ -394,11 +402,13 @@ pub struct RPCReplayedBlockTransaction { | |
| pub cpu_instructions: Option<u64>, | ||
| pub cpu_cycles: Option<u64>, | ||
| pub cpu_ref_cycles: Option<u64>, | ||
| pub execution_time_millis: u64, | ||
| } | ||
|
|
||
| impl RPCReplayedBlockTransaction { | ||
| pub fn from_receipt( | ||
| receipt: &StacksTransactionReceipt, | ||
| execution_duration: &Duration, | ||
| profiler_result: &BlockReplayProfilerResult, | ||
| ) -> Self { | ||
| let events = if receipt.post_condition_aborted { | ||
|
|
@@ -437,6 +447,7 @@ impl RPCReplayedBlockTransaction { | |
| cpu_instructions: profiler_result.cpu_instructions, | ||
| cpu_cycles: profiler_result.cpu_cycles, | ||
| cpu_ref_cycles: profiler_result.cpu_ref_cycles, | ||
| execution_time_millis: execution_duration.as_millis() as u64, | ||
|
Contributor
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. Could be worth it to use
Comment on lines
447
to
+450
Contributor
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. I would suggest organizing the response under a profiler field, aggregating all the current profiling-related fields beneath it. This would allow us to simply mark the parent field as nullable, while also making the structure cleaner, easier to evolve and piloted by the RPC request Additionally, this approach would integrate nicely with the refactoring proposed in #7205 (comment). |
||
| } | ||
| } | ||
| } | ||
|
|
||
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.
computing
execution_time_millissounds like a profiler feature. Why not assigning this responsibility toBlockReplayProfilerto centralize all this kind of data collection? It could be available for both linux and not linux build.