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

perf: query accounts with &Address to avoid copying address #13554

Merged
merged 1 commit into from
Dec 25, 2024

Conversation

hai-rise
Copy link
Contributor

Following #13171 towards #12838.

@@ -367,7 +367,7 @@ where
let state = maybe_state.as_deref().expect("provider is set");

// Use provider to get account info
let account = match state.basic_account(transaction.sender()) {
let account = match state.basic_account(transaction.sender_ref()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Main dance.

fn basic_account(&self, address: Address) -> ProviderResult<Option<Account>> {
Ok(self.tx.get::<tables::PlainAccountState>(address)?)
fn basic_account(&self, address: &Address) -> ProviderResult<Option<Account>> {
Ok(self.tx.get_by_encoded_key::<tables::PlainAccountState>(address)?)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Main dance.

Copy link
Collaborator

Choose a reason for hiding this comment

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

makes sense to avoid the copy here

fn basic_account(&self, address: Address) -> ProviderResult<Option<Account>> {
self.tx().get::<tables::PlainAccountState>(address).map_err(Into::into)
fn basic_account(&self, address: &Address) -> ProviderResult<Option<Account>> {
self.tx().get_by_encoded_key::<tables::PlainAccountState>(address).map_err(Into::into)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Main dance.

Copy link

codspeed-hq bot commented Dec 25, 2024

CodSpeed Performance Report

Merging #13554 will improve performances by 10.48%

Comparing risechain:basic-account-ref (6e8b2ed) with main (3fbb230)

Summary

⚡ 1 improvements
✅ 76 untouched benchmarks

Benchmarks breakdown

Benchmark main risechain:basic-account-ref Change
`hash builder[init size 1000 update size 100 num updates 1]` 2.7 ms

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.

cool, this makes sense

fn basic_account(&self, address: Address) -> ProviderResult<Option<Account>> {
Ok(self.tx.get::<tables::PlainAccountState>(address)?)
fn basic_account(&self, address: &Address) -> ProviderResult<Option<Account>> {
Ok(self.tx.get_by_encoded_key::<tables::PlainAccountState>(address)?)
Copy link
Collaborator

Choose a reason for hiding this comment

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

makes sense to avoid the copy here

@mattsse mattsse added this pull request to the merge queue Dec 25, 2024
Merged via the queue into paradigmxyz:main with commit 031f430 Dec 25, 2024
44 checks passed
@hai-rise hai-rise deleted the basic-account-ref branch December 25, 2024 12:47
@mattsse mattsse added the C-perf A change motivated by improving speed, memory usage or disk footprint label Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-perf A change motivated by improving speed, memory usage or disk footprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants