Skip to content

Commit

Permalink
avoid giant memory allocation in hash calc (solana-labs#32646)
Browse files Browse the repository at this point in the history
* avoid giant memory allocation in hash calc

* update comment

* reorder to avoid clone

* simplify references

* update comment on get_item
  • Loading branch information
jeffwashington committed Jul 31, 2023
1 parent f4504d0 commit 3dcb382
Show file tree
Hide file tree
Showing 3 changed files with 268 additions and 201 deletions.
9 changes: 1 addition & 8 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7654,16 +7654,9 @@ impl AccountsDb {
.map(|d| d.get_cache_hash_data())
.collect::<Vec<_>>();

// rework slices of data into bins for parallel processing and to match data shape expected by 'rest_of_hash_calculation'
let result = AccountsHasher::get_binned_data(
&cache_hash_intermediates,
PUBKEY_BINS_FOR_CALCULATING_HASHES,
&bounds,
);

// turn raw data into merkle tree hashes and sum of lamports
let (accounts_hash, capitalization) =
accounts_hasher.rest_of_hash_calculation(result, &mut stats);
accounts_hasher.rest_of_hash_calculation(&cache_hash_intermediates, &mut stats);
let accounts_hash = match flavor {
CalcAccountsHashFlavor::Full => AccountsHashEnum::Full(AccountsHash(accounts_hash)),
CalcAccountsHashFlavor::Incremental => {
Expand Down
Loading

0 comments on commit 3dcb382

Please sign in to comment.