Skip to content
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

Discussion draft: change DB Writer to take value references #13672

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

prestwich
Copy link
Collaborator

Includes the following changes:

  • Changes insert, upsert and append to take a &T::Value instead of T::Value.
  • Deletes unnecessary clones
  • example of benefit: Changes StateWriter to not take ownership of (potentially large?) ExecutionOutcome

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt @joshieDo @rkrasiuk

I believe we can and should do this, IIRC the reason why this even takes Value is because originally we took ownership during compact encoding but we've since changed that

@prestwich prestwich marked this pull request as ready for review January 6, 2025 16:41
@prestwich
Copy link
Collaborator Author

CI passing and ready for consideration

@gakonst
Copy link
Member

gakonst commented Jan 6, 2025

cc @hai-rise in case you wanna bench it

StorageTrieEntry { nibbles, node: node.clone() },
&StorageTrieEntry { nibbles, node: node.clone() },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this potentially be StorageTrieEntryRef so that node is not cloned either?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this will be unlocked by this

@mattsse mattsse added the A-db Related to the database label Jan 6, 2025
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

pending @joshieDo or @rkrasiuk or @shekhirin

Comment on lines +197 to +198
fn compress_to_buf<B: bytes::BufMut + AsMut<[u8]>>(&self, buf: &mut B) {
let _ = Compact::to_compact(self, buf);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this was the reason why we originally had it as self and Value

Copy link
Member

@rkrasiuk rkrasiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mattsse mattsse added this pull request to the merge queue Jan 7, 2025
Merged via the queue into main with commit 3e980e6 Jan 7, 2025
43 checks passed
@mattsse mattsse deleted the prestwich/eo-write-ref branch January 7, 2025 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-db Related to the database
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants