Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Account -> AccountSharedData#15691

Merged
jeffwashington merged 1 commit intosolana-labs:masterfrom
jeffwashington:account_no_data
Mar 9, 2021
Merged

Account -> AccountSharedData#15691
jeffwashington merged 1 commit intosolana-labs:masterfrom
jeffwashington:account_no_data

Conversation

@jeffwashington
Copy link
Copy Markdown
Contributor

@jeffwashington jeffwashington commented Mar 3, 2021

Problem

We don't want to copy account and account data around unnecessarily.
Account structure is fixed for abi. It needs to remain.

Summary of Changes

Step 1 in creating a new AccountSharedData struct which holds data in an Arc.
This change intends to be as much as possible just a rename since the rename touches many files.
Subsequent changes will change the implementation of AccountSharedData and handle its fallout.
I accomplished this by creating a parallel AccountSharedData which is a duplicate of Account. This let me produce something that should be identical in performance and allow us to review the mass rename changes separately from what should be interesting changes.
#15714
Fixes #

@jeffwashington jeffwashington force-pushed the account_no_data branch 4 times, most recently from ad77c46 to 6a8f6fc Compare March 4, 2021 21:12
@jeffwashington jeffwashington mentioned this pull request Mar 4, 2021
@jeffwashington
Copy link
Copy Markdown
Contributor Author

I ran ledger-tool verify on a colo machine against a recent mainnet snapshot. This change should have no or minimal effect.
master:
ledger processed in 1 minute and 31 seconds. 8053 MB allocated. root slot is 67566632 2 forks at 67566647 67566674 with 42 frozen banks
this pr:
ledger processed in 1 minute and 31 seconds. 7982 MB allocated. root slot is 67566632 2 forks at 67566647 67566674 with 42 frozen banks

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 4, 2021

Codecov Report

Merging #15691 (ed16a59) into master (a7d5645) will increase coverage by 0.0%.
The diff coverage is 90.1%.

@@           Coverage Diff            @@
##           master   #15691    +/-   ##
========================================
  Coverage    80.1%    80.1%            
========================================
  Files         407      407            
  Lines      105422   105849   +427     
========================================
+ Hits        84457    84828   +371     
- Misses      20965    21021    +56     

@jeffwashington jeffwashington requested a review from carllin March 4, 2021 23:25
Comment thread account-decoder/src/lib.rs Outdated
Comment thread sdk/src/account.rs
@jeffwashington
Copy link
Copy Markdown
Contributor Author

Some archived discussion here:
#15639

Comment thread client/src/rpc_client.rs Outdated

/// Note that `get_account` returns `Err(..)` if the account does not exist whereas
/// `get_account_with_commitment` returns `Ok(None)` if the account does not exist.
pub fn get_account_no_data(&self, pubkey: &Pubkey) -> ClientResult<AccountNoData> {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@CriesofCarrots @jackcmay : @carllin suggested I call this type of rpc change out to you two in case we needed to do something different here.

Copy link
Copy Markdown
Contributor

@CriesofCarrots CriesofCarrots Mar 6, 2021

Choose a reason for hiding this comment

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

Thanks for the heads up! Is there anything in particular in the client or rpc tooling about which you have questions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@CriesofCarrots: @carllin and I expressed some lack of knowledge in the rpc area. @sakridge raised rpc as a concern early on with this refactoring and rename. So, we need an expert to make sure we can add methods here and things will work ok and to see if we missed something.

Comment thread sdk/src/account.rs Outdated
@jeffwashington
Copy link
Copy Markdown
Contributor Author

jeffwashington commented Mar 6, 2021 via email

@jeffwashington jeffwashington changed the title Account -> AccountNoData Account -> AccountSharedData Mar 6, 2021
@jeffwashington jeffwashington force-pushed the account_no_data branch 3 times, most recently from 17cc9de to 96a784b Compare March 6, 2021 05:26
@jeffwashington jeffwashington marked this pull request as ready for review March 6, 2021 05:52
@jeffwashington jeffwashington requested a review from jackcmay March 8, 2021 18:44
Copy link
Copy Markdown
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

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

Is the intent to deprecate Account altogether? I am wondering if the rpc_client changes are necessary, or if downstream clients should still be operating using Account (with AccountSharedData just an internal node concept). The account will always have to be copied to be returned from RPC anyway, so could use an AccountSharedData::into<Account>() method.

Comment thread client/src/rpc_client.rs Outdated
Comment thread sdk/src/account.rs Outdated
@jeffwashington
Copy link
Copy Markdown
Contributor Author

Is the intent to deprecate Account altogether? I am wondering if the rpc_client changes are necessary, or if downstream clients should still be operating using Account (with AccountSharedData just an internal node concept). The account will always have to be copied to be returned from RPC anyway, so could use an AccountSharedData::into<Account>() method.

The intuition of @carllin , @sakridge , @jackcmay appears to be that we will need to keep the existing Account struct around for things like 'downstream projects' that will have to be modified if we make the fields of 'Account' private and abstract away how the conceptual account is actually stored in memory. For example, if lamports becomes private, and we require traits to access ie. account.lamports**()** or account.set_lamports(new_lamports), then existing code in downstream projects or 3rd parties could break.

I tried to walk the right line for things like rpc where we could at the beginning get an account in either format (Account or AccountSharedData). The existing function call (.get_account()) still needed to return Account. This would require us to litter in various places AccountSharedData::from(_.get_account()). This at a minimum could result in extra struct copying and such on every account load. Perhaps this is inlined and optimized away. I went with the approach that in the few origins of Account[SharedData], the caller could be explicit about what storage they wanted initially, which should result in higher performance code. It didn't seem there were too many places where we needed to replicate the 'get' functions. I am happy to consider other options.

Comment thread sdk/src/account.rs
Comment thread sdk/src/account.rs Outdated
@jeffwashington
Copy link
Copy Markdown
Contributor Author

I just pushed commits to respond to pr feedback and rebase on master.

Comment thread cli/src/program.rs Outdated
Comment thread cli/src/stake.rs Outdated
@jeffwashington
Copy link
Copy Markdown
Contributor Author

bench-tps #s
master: Average TPS: 52101.16
shareddata: Average TPS: 52483.273

colo machine, single node testnet

@jeffwashington
Copy link
Copy Markdown
Contributor Author

I reworked a lot, squashed it all, rolled back some changes. Squashed it.

}
}

impl From<AccountSharedData> for VoteAccount {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@behzadnouri does this look ok now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the issue was changing Serialize/Deserialize impl which is now reverted.
changes to new_rand_vote_account also seem redundant but i guess it does not make a difference.

@jeffwashington jeffwashington merged commit 8a3135d into solana-labs:master Mar 9, 2021
@jeffwashington jeffwashington deleted the account_no_data branch March 9, 2021 21:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants