-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
perf(provider): compute hashes and trie updates before opening write tx #5505
Conversation
crates/storage/provider/src/bundle_state/bundle_state_with_receipts.rs
Outdated
Show resolved
Hide resolved
@@ -2321,7 +2323,11 @@ impl<TX: DbTxMut + DbTx> BlockWriter for DatabaseProvider<TX> { | |||
state.write_to_db(self.tx_ref(), OriginalValuesKnown::No)?; | |||
durations_recorder.record_relative(metrics::Action::InsertState); | |||
|
|||
self.insert_hashes(first_number..=last_block_number, last_block_hash, expected_state_root)?; |
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.
there's now insert_hashes
inside the provider and new HashedStateChanges::write_to_db
, can we merge them somehow? IIUC the provider one is used now only in the test
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.
we might want to remove insert_hashes
, will think about it
|
||
impl HashedStateChanges { | ||
/// Write the bundle state to the database. | ||
pub fn write_to_db<TX: DbTxMut + DbTx>(self, tx: &TX) -> Result<(), DatabaseError> { |
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.
it would be nice to add the timings breakdown here too, same as in insert_hashes
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.
also a bit concerning that this is almost the same logic as in insert_(account|storage)_for_hashing
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.
will address in a follow up
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.
lgtm, pending @shekhirin + some sanity testing
31a72d7
to
25c8129
Compare
Description
Continuation of the freelist saga #5228
This PR aims to decrease the duration for which the write transaction is open during canonical commit. This is done by computing state hashes and merkle root with updates before opening a write transaction.