-
Notifications
You must be signed in to change notification settings - Fork 12
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
add feature 'enable_execution_duration_record' #6
Changes from 1 commit
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
mod listener; | ||
mod sync_metrics; | ||
mod util; | ||
|
||
pub use listener::{MetricEvent, MetricEventsSender, MetricsListener}; | ||
pub(crate) use util::*; | ||
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. add #[cfg(feature = "enable_execution_duration_record")] |
||
use sync_metrics::*; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
|
||
#[cfg(feature = "enable_execution_duration_record")] | ||
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. delete |
||
#[derive(Debug, Default)] | ||
pub(crate) struct ExecutionDurationRecord { | ||
/// execute inner time recorder | ||
inner_recorder: revm_utils::time::TimeRecorder, | ||
/// time recorder | ||
time_recorder: revm_utils::time::TimeRecorder, | ||
|
||
/// total time of execute_inner | ||
pub(crate) execute_inner: u64, | ||
/// total time of get block td and block_with_senders | ||
pub(crate) read_block: u64, | ||
/// time of revm execute tx(execute_and_verify_receipt) | ||
pub(crate) execute_tx: u64, | ||
/// time of process state(state.extend) | ||
pub(crate) process_state: u64, | ||
/// time of write to db | ||
pub(crate) write_to_db: u64, | ||
} | ||
|
||
#[cfg(feature = "enable_execution_duration_record")] | ||
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. delete |
||
impl ExecutionDurationRecord { | ||
/// start inner time recorder | ||
pub(crate) fn start_inner_time_recorder(&mut self) { | ||
self.inner_recorder = revm_utils::time::TimeRecorder::now(); | ||
} | ||
/// start time recorder | ||
pub(crate) fn start_time_recorder(&mut self) { | ||
self.time_recorder = revm_utils::time::TimeRecorder::now(); | ||
} | ||
/// add time of execute_inner | ||
pub(crate) fn add_execute_inner(&mut self) { | ||
self.execute_inner = self | ||
.execute_inner | ||
.checked_add(self.inner_recorder.elapsed().to_cycles()) | ||
.expect("overflow"); | ||
} | ||
/// add time of get block td and block_with_senders | ||
pub(crate) fn add_read_block(&mut self) { | ||
self.read_block = self | ||
.read_block | ||
.checked_add(self.time_recorder.elapsed().to_cycles()) | ||
.expect("overflow"); | ||
} | ||
/// add time of revm execute tx | ||
pub(crate) fn add_execute_tx(&mut self) { | ||
self.execute_tx = self | ||
.execute_tx | ||
.checked_add(self.time_recorder.elapsed().to_cycles()) | ||
.expect("overflow"); | ||
} | ||
/// add time of process state | ||
pub(crate) fn add_process_state(&mut self) { | ||
self.process_state = self | ||
.process_state | ||
.checked_add(self.time_recorder.elapsed().to_cycles()) | ||
.expect("overflow"); | ||
} | ||
/// add time of write to db | ||
pub(crate) fn add_write_to_db(&mut self) { | ||
self.write_to_db = self | ||
.write_to_db | ||
.checked_add(self.time_recorder.elapsed().to_cycles()) | ||
.expect("overflow"); | ||
} | ||
} |
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.
add #[cfg(feature = "enable_execution_duration_record")]