Skip to content

Commit

Permalink
v1.16: Update ShredFetchStage::modify_packets to drop root bank quick…
Browse files Browse the repository at this point in the history
…er (backport of #33105) (#33152)

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.

(cherry picked from commit ad33c68)

# Conflicts:
#	core/src/shred_fetch_stage.rs

Co-authored-by: steviez <[email protected]>
  • Loading branch information
mergify[bot] and steviez authored Sep 6, 2023
1 parent ea03d6c commit 90d9839
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions core/src/shred_fetch_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,27 @@ impl ShredFetchStage {
.as_ref()
.map(|(_, cluster_info)| cluster_info.keypair().clone());

// In the case of bank_forks=None, setup to accept any slot range
let mut root_bank = bank_forks.read().unwrap().root_bank();
let mut last_root = root_bank.slot();
let mut last_slot = std::u64::MAX;
let mut slots_per_epoch = 0;

let (mut last_root, mut last_slot, mut slots_per_epoch) = {
let bank_forks_r = bank_forks.read().unwrap();
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 stats = ShredFetchStats::default();

for mut packet_batch in recvr {
if last_updated.elapsed().as_millis() as u64 > DEFAULT_MS_PER_SLOT {
last_updated = Instant::now();
{
let root_bank = {
let bank_forks_r = bank_forks.read().unwrap();
last_root = bank_forks_r.root();
let working_bank = bank_forks_r.working_bank();
last_slot = working_bank.slot();
root_bank = bank_forks_r.root_bank();
slots_per_epoch = root_bank.get_slots_in_epoch(root_bank.epoch());
}
last_slot = bank_forks_r.highest_slot();
bank_forks_r.root_bank()
};
last_root = root_bank.slot();
slots_per_epoch = root_bank.get_slots_in_epoch(root_bank.epoch());
keypair = repair_context
.as_ref()
.map(|(_, cluster_info)| cluster_info.keypair().clone());
Expand Down

0 comments on commit 90d9839

Please sign in to comment.