Stake cache size (#26071)
* reduce threadpool for stake processing * wip * Revert "reduce threadpool for stake processing" This reverts commit 004a4f872ea7a3ef53e38d145b6350c3f57c680c. * batch update stake_cache * fix deadlock * add test * code review feedbacks * more review feedbacks * fix conflicts * report stake account len and vote account len at epoch boundary * report num_staked_nodes * remove batch store, no atomic for redeem timing
This commit is contained in:
parent
e7597ab1fe
commit
c4efb9f19e
|
@ -2710,6 +2710,10 @@ impl Bank {
|
|||
validator_rewards_paid, validator_rewards
|
||||
);
|
||||
|
||||
let num_stake_accounts = self.stakes_cache.num_stake_accounts();
|
||||
let num_vote_accounts = self.stakes_cache.num_vote_accounts();
|
||||
let num_staked_nodes = self.stakes_cache.num_staked_nodes();
|
||||
|
||||
self.capitalization
|
||||
.fetch_add(validator_rewards_paid, Relaxed);
|
||||
|
||||
|
@ -2731,7 +2735,10 @@ impl Bank {
|
|||
("validator_rewards", validator_rewards_paid, i64),
|
||||
("active_stake", active_stake, i64),
|
||||
("pre_capitalization", capitalization, i64),
|
||||
("post_capitalization", self.capitalization(), i64)
|
||||
("post_capitalization", self.capitalization(), i64),
|
||||
("num_stake_accounts", num_stake_accounts as i64, i64),
|
||||
("num_vote_accounts", num_vote_accounts as i64, i64),
|
||||
("num_staked_nodes", num_staked_nodes as i64, i64)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,21 @@ impl StakesCache {
|
|||
self.0.read().unwrap()
|
||||
}
|
||||
|
||||
pub fn num_stake_accounts(&self) -> usize {
|
||||
let stakes = self.0.read().unwrap();
|
||||
stakes.stake_delegations.len()
|
||||
}
|
||||
|
||||
pub fn num_vote_accounts(&self) -> usize {
|
||||
let stakes = self.0.read().unwrap();
|
||||
stakes.vote_accounts.num_vote_accounts()
|
||||
}
|
||||
|
||||
pub fn num_staked_nodes(&self) -> usize {
|
||||
let stakes = self.0.read().unwrap();
|
||||
stakes.vote_accounts.num_staked_nodes()
|
||||
}
|
||||
|
||||
pub fn check_and_store(&self, pubkey: &Pubkey, account: &AccountSharedData) {
|
||||
// TODO: If the account is already cached as a vote or stake account
|
||||
// but the owner changes, then this needs to evict the account from
|
||||
|
|
|
@ -60,6 +60,16 @@ pub struct VoteAccounts {
|
|||
staked_nodes_once: Once,
|
||||
}
|
||||
|
||||
impl VoteAccounts {
|
||||
pub fn num_vote_accounts(&self) -> usize {
|
||||
self.vote_accounts.len()
|
||||
}
|
||||
|
||||
pub fn num_staked_nodes(&self) -> usize {
|
||||
self.staked_nodes.read().unwrap().len()
|
||||
}
|
||||
}
|
||||
|
||||
impl VoteAccount {
|
||||
pub(crate) fn lamports(&self) -> u64 {
|
||||
self.0.account.lamports()
|
||||
|
|
Loading…
Reference in New Issue