Skip to content

Commit

Permalink
fix: fix a minor error in the measurement code.
Browse files Browse the repository at this point in the history
  • Loading branch information
anonymousGiga committed Mar 13, 2024
1 parent f08b574 commit 7b89141
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
36 changes: 12 additions & 24 deletions crates/perf-metrics/src/metrics/execute_measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pub mod write_to_db {
}

/// start write_to_db write record.
fn start_write_to_db_write_record() {
fn start_write_record() {
recorder().duration_record.write_to_db.start_write_record();
}

Expand All @@ -219,11 +219,9 @@ pub mod write_to_db {
// Encapsulate this structure to record write_storage in revert state in a RAII manner.
impl_write_macro!(
RevertsStorageWrite,
start_write_to_db_write_record,
start_write_record,
record_revert_storage_append_time,
record_revert_storage_size,
record_receipts_append_time,
record_write_receipts_size
record_revert_storage_size
);

/// Record time of write storage changes in StateReverts's write_to_db.
Expand All @@ -244,11 +242,9 @@ pub mod write_to_db {
// Encapsulate this structure to record write_account in revert state in a RAII manner.
impl_write_macro!(
RevertsAccountWrite,
start_write_to_db_write_record,
start_write_record,
record_revert_account_append_time,
record_revert_account_size,
record_receipts_append_time,
record_write_receipts_size
record_revert_account_size
);

/// Record time of write account changes in StateReverts's write_to_db.
Expand All @@ -269,9 +265,7 @@ pub mod write_to_db {
// Encapsulate this structure to record write receipts in a RAII manner.
impl_write_macro!(
ReceiptsWrite,
start_write_to_db_write_record,
record_receipts_append_time,
record_write_receipts_size,
start_write_record,
record_receipts_append_time,
record_write_receipts_size
);
Expand Down Expand Up @@ -299,11 +293,9 @@ pub mod write_to_db {
// Encapsulate this structure to record write_account in state changes in a RAII manner.
impl_write_macro!(
StateAccountWrite,
start_write_to_db_write_record,
start_write_record,
record_state_account_upsert_time,
record_state_account_size,
record_receipts_append_time,
record_write_receipts_size
record_state_account_size
);

/// Record time of write account in StateChanges's write_to_db.
Expand All @@ -324,11 +316,9 @@ pub mod write_to_db {
// Encapsulate this structure to record write_bytecode in state changes in a RAII manner.
impl_write_macro!(
StateBytecodeWrite,
start_write_to_db_write_record,
start_write_record,
record_state_bytecode_upsert_time,
record_state_bytecode_size,
record_receipts_append_time,
record_write_receipts_size
record_state_bytecode_size
);

/// Record time of write bytecode in StateChanges's write_to_db.
Expand All @@ -349,11 +339,9 @@ pub mod write_to_db {
// Encapsulate this structure to record write_storage in state changes in a RAII manner.
impl_write_macro!(
StateStorageWrite,
start_write_to_db_write_record,
start_write_record,
record_state_storage_upsert_time,
record_state_storage_size,
record_receipts_append_time,
record_write_receipts_size
record_state_storage_size
);

/// Record time of write storage in StateChanges's write_to_db.
Expand Down
2 changes: 1 addition & 1 deletion crates/perf-metrics/src/metrics/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ macro_rules! define_start_functions {
// #[cfg(feature = "enable_execution_duration_record")]
#[allow(unused_macros)]
macro_rules! impl_write_macro {
($struct_name:ident, $start_record_fn:ident, $record_upsert_time_fn:ident, $record_size_fn:ident, $append_time_fn:ident, $write_size_fn:ident) => {
($struct_name:ident, $start_record_fn:ident, $record_upsert_time_fn:ident, $record_size_fn:ident) => {
#[cfg(feature = "enable_execution_duration_record")]
pub struct $struct_name(usize);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,14 @@ impl BundleStateWithReceipts {
for (tx_idx, receipt) in receipts.into_iter().enumerate() {
if let Some(receipt) = receipt {
#[cfg(feature = "enable_execution_duration_record")]
{
let size = std::mem::size_of::<Receipt>() +
let _record = perf_metrics::ReceiptsWrite::new(
std::mem::size_of::<Receipt>() +
receipt
.logs
.iter()
.map(|log| log.topics.len() * 32 + log.data.0.len())
.sum::<usize>();
let _record = perf_metrics::ReceiptsWrite::new(size);
}
.sum::<usize>(),
);
receipts_cursor.append(first_tx_index + tx_idx as u64, receipt)?;
}
}
Expand Down

0 comments on commit 7b89141

Please sign in to comment.