Data as arc#15714
Conversation
|
Processing a ledger with ledger-tool on a recent mainnet snapshot with this change produced this difference vs master: |
936356a to
dd55541
Compare
|
note this is based off #15691 |
| #[derive(Debug, Clone)] | ||
| pub struct CachedAccount { | ||
| pub account: Account, | ||
| pub account: AccountNoData, |
There was a problem hiding this comment.
The root place this change impacts many code paths is here. The cache now holds AccountNoData, which shares its data behind an Arc. So, as an item is loaded from the cache, the data is never copied until it needs to be modified by someone. Cloning the account clones the non-data fields and addrefs the Arc to the data.
A subsequent change will attempt to move this AccountNoData struct to AccountNoDataInner and make AccountNoData have an Arc to an AccountNoDataInner. This would reduce copying of the rest of the Account contents (lamports, executable, owner, rent_epoch)
Codecov Report
@@ Coverage Diff @@
## master #15714 +/- ##
=========================================
- Coverage 80.1% 80.0% -0.1%
=========================================
Files 407 407
Lines 105449 105962 +513
=========================================
+ Hits 84488 84867 +379
- Misses 20961 21095 +134 |
a1d2dfc to
c08da33
Compare
c08da33 to
be7b618
Compare
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
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 is creating a new AccountSharedData struct which we can manipulate. That is PR #15691
Step 2 is this PR. This is to make AccountSharedData.data hold data: Arc<Vec>. The major changes have comments next to them in the source below.