implements copy-on-write for vote-accounts (#19362)

Bank::vote_accounts redundantly clones vote-accounts HashMap even though
an immutable reference will suffice:
https://github.com/solana-labs/solana/blob/95c998a19/runtime/src/bank.rs#L5174-L5186

This commit implements copy-on-write semantics for vote-accounts by
wrapping the underlying HashMap in Arc<...>.
This commit is contained in:
behzad nouri
2021-08-30 15:54:01 +00:00
committed by GitHub
parent f19ff84593
commit 8ad52fa095
11 changed files with 215 additions and 175 deletions

View File

@@ -1544,7 +1544,8 @@ fn get_stake_percent_in_gossip(bank: &Bank, cluster_info: &ClusterInfo, log: boo
let my_shred_version = cluster_info.my_shred_version();
let my_id = cluster_info.id();
for (_, (activated_stake, vote_account)) in bank.vote_accounts() {
for (activated_stake, vote_account) in bank.vote_accounts().values() {
let activated_stake = *activated_stake;
total_activated_stake += activated_stake;
if activated_stake == 0 {