Skip to content

Commit

Permalink
Obtain BankForks read lock once to get ancestors and descendants (sol…
Browse files Browse the repository at this point in the history
…ana-labs#35273)

No need to get the read lock twice; instead, hold it and get both items
  • Loading branch information
steviez authored Feb 21, 2024
1 parent d223a43 commit 5c04a97
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,10 @@ impl ReplayStage {
let mut tpu_has_bank = poh_recorder.read().unwrap().has_bank();

let mut replay_active_banks_time = Measure::start("replay_active_banks_time");
let mut ancestors = bank_forks.read().unwrap().ancestors();
let mut descendants = bank_forks.read().unwrap().descendants();
let (mut ancestors, mut descendants) = {
let r_bank_forks = bank_forks.read().unwrap();
(r_bank_forks.ancestors(), r_bank_forks.descendants())
};
let did_complete_bank = Self::replay_active_banks(
&blockstore,
&bank_forks,
Expand Down

0 comments on commit 5c04a97

Please sign in to comment.