Skip to content

Commit

Permalink
Do not calculate AccountHash when calculating accounts lt hash (solan…
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Nov 11, 2024
1 parent 2938526 commit b46c87e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
21 changes: 21 additions & 0 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7452,6 +7452,27 @@ impl AccountsDb {
(hashes, scan.as_us(), accumulate)
}

/// Return all of the accounts for a given slot
pub fn get_pubkey_account_for_slot(&self, slot: Slot) -> Vec<(Pubkey, AccountSharedData)> {
let scan_result = self.scan_account_storage(
slot,
|loaded_account| {
// Cache only has one version per key, don't need to worry about versioning
Some((*loaded_account.pubkey(), loaded_account.take_account()))
},
|accum: &DashMap<_, _>, loaded_account, _data| {
// Storage may have duplicates so only keep the latest version for each key
accum.insert(*loaded_account.pubkey(), loaded_account.take_account());
},
ScanAccountStorageData::NoData,
);

match scan_result {
ScanStorageResult::Cached(cached_result) => cached_result,
ScanStorageResult::Stored(stored_result) => stored_result.into_iter().collect(),
}
}

/// Return all of the accounts for a given slot
pub fn get_pubkey_hash_account_for_slot(&self, slot: Slot) -> Vec<PubkeyHashAccount> {
type ScanResult =
Expand Down
7 changes: 2 additions & 5 deletions runtime/src/bank/accounts_lt_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl Bank {
self.rc
.accounts
.accounts_db
.get_pubkey_hash_account_for_slot(slot)
.get_pubkey_account_for_slot(slot)
});
let num_accounts_total = accounts_curr.len();

Expand Down Expand Up @@ -118,10 +118,7 @@ impl Bank {
.fold_chunks(
CHUNK_SIZE,
|| (LtHash::identity(), Stats::default()),
|mut accum, elem| {
let pubkey = &elem.pubkey;
let curr_account = &elem.account;

|mut accum, (pubkey, curr_account)| {
// load the initial state of the account
let (initial_state_of_account, measure_load) = meas_dur!({
match cache_for_accounts_lt_hash.get(pubkey) {
Expand Down

0 comments on commit b46c87e

Please sign in to comment.