Skip to content

Commit

Permalink
Perf: support in-depth measurement of write_to_db. (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
anonymousGiga authored and xudaquan2003 committed Feb 23, 2024
1 parent 2fe8af1 commit 57f9814
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/storage/provider/src/bundle_state/state_changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ impl StateChanges {
// sizeof(Address) + sizeof(Account) = 100
let _record = perf_metrics::StateAccountWrite::new(100usize);
accounts_cursor.upsert(address, into_reth_acc(account))?;
#[cfg(feature = "enable_write_to_db_measure")]
// sizeof(Address) + sizeof(Account) = 100
perf_metrics::record_state_account_size(100usize);
} else if accounts_cursor.seek_exact(address)?.is_some() {
tracing::trace!(target: "provider::bundle_state", ?address, "Deleting plain state account");
accounts_cursor.delete_current()?;
Expand Down Expand Up @@ -90,6 +93,9 @@ impl StateChanges {
// sizeof(Address) + sizeof(StorageEntry) = 84
let _record = perf_metrics::StateStorageWrite::new(84usize);
storages_cursor.upsert(address, entry)?;
#[cfg(feature = "enable_write_to_db_measure")]
// sizeof(Address) + sizeof(StorageEntry) = 84
perf_metrics::record_state_storage_size(84usize);
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions crates/storage/provider/src/bundle_state/state_reverts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ impl StateReverts {
// sizeof(B256) + sizeof(StorageEntry) = 96
let _record = perf_metrics::RevertsStorageWrite::new(96usize);
storage_changeset_cursor.append_dup(storage_id, StorageEntry { key, value })?;
#[cfg(feature = "enable_write_to_db_measure")]
// sizeof(B256) + sizeof(StorageEntry) = 96
perf_metrics::record_revert_storage_size(96usize);
}
}
}
Expand All @@ -94,6 +97,9 @@ impl StateReverts {
block_number,
AccountBeforeTx { address, info: info.map(into_reth_acc) },
)?;
#[cfg(feature = "enable_write_to_db_measure")]
// sizeof(Address) + sizeof(AccountBeforeTx) = 124
perf_metrics::record_revert_account_size(124usize);
}
}
#[cfg(feature = "enable_write_to_db_measure")]
Expand Down

0 comments on commit 57f9814

Please sign in to comment.