Update ShredFetchStage::modify_packets to drop root bank quicker (#33105)
This function used to contain feature gate activation checks that required access to a bank. Those checks have been cleaned up, so we no longer need access to a full Bank. Rather, we can momentarily get a Bank from BankForks, calculate the necessary results and then drop the Bank along with the BankForks read lock.
This commit is contained in:
parent
d1b849972f
commit
ad33c68ce9
|
@ -50,24 +50,25 @@ impl ShredFetchStage {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|(_, cluster_info)| cluster_info.keypair().clone());
|
.map(|(_, cluster_info)| cluster_info.keypair().clone());
|
||||||
|
|
||||||
// Only need root bank in order to check feature statuses later on;
|
let (mut last_root, mut last_slot, mut slots_per_epoch) = {
|
||||||
// can demote to only fetching root slot once those features go away.
|
|
||||||
let (mut root_bank, mut last_slot) = {
|
|
||||||
let bank_forks_r = bank_forks.read().unwrap();
|
let bank_forks_r = bank_forks.read().unwrap();
|
||||||
(bank_forks_r.root_bank(), bank_forks_r.highest_slot())
|
let root_bank = bank_forks_r.root_bank();
|
||||||
|
(
|
||||||
|
root_bank.slot(),
|
||||||
|
root_bank.get_slots_in_epoch(root_bank.epoch()),
|
||||||
|
bank_forks_r.highest_slot(),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
let mut last_root = root_bank.slot();
|
|
||||||
let mut slots_per_epoch = root_bank.get_slots_in_epoch(root_bank.epoch());
|
|
||||||
let mut stats = ShredFetchStats::default();
|
let mut stats = ShredFetchStats::default();
|
||||||
|
|
||||||
for mut packet_batch in recvr {
|
for mut packet_batch in recvr {
|
||||||
if last_updated.elapsed().as_millis() as u64 > DEFAULT_MS_PER_SLOT {
|
if last_updated.elapsed().as_millis() as u64 > DEFAULT_MS_PER_SLOT {
|
||||||
last_updated = Instant::now();
|
last_updated = Instant::now();
|
||||||
{
|
let root_bank = {
|
||||||
let bank_forks_r = bank_forks.read().unwrap();
|
let bank_forks_r = bank_forks.read().unwrap();
|
||||||
root_bank = bank_forks_r.root_bank();
|
|
||||||
last_slot = bank_forks_r.highest_slot();
|
last_slot = bank_forks_r.highest_slot();
|
||||||
}
|
bank_forks_r.root_bank()
|
||||||
|
};
|
||||||
last_root = root_bank.slot();
|
last_root = root_bank.slot();
|
||||||
slots_per_epoch = root_bank.get_slots_in_epoch(root_bank.epoch());
|
slots_per_epoch = root_bank.get_slots_in_epoch(root_bank.epoch());
|
||||||
keypair = repair_context
|
keypair = repair_context
|
||||||
|
|
Loading…
Reference in New Issue