Skip to content

Commit

Permalink
v1.17: Set a global fork graph in program cache (backport of #33776) (#…
Browse files Browse the repository at this point in the history
…33809)

Set a global fork graph in program cache (#33776)

* Set a global fork graph in program cache

* fix deadlock

* review feedback

(cherry picked from commit 59cb3b5)

Co-authored-by: Pankaj Garg <pankaj@solana.com>
  • Loading branch information
mergify[bot] and pgarg66 authored Oct 21, 2023
1 parent 9021d22 commit cc4b71a
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 83 deletions.
1 change: 1 addition & 0 deletions core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3869,6 +3869,7 @@ impl ReplayStage {
epoch_slots_frozen_slots: &mut EpochSlotsFrozenSlots,
drop_bank_sender: &Sender<Vec<Arc<Bank>>>,
) {
bank_forks.read().unwrap().prune_program_cache(new_root);
let removed_banks = bank_forks.write().unwrap().set_root(
new_root,
accounts_background_request_sender,
Expand Down
9 changes: 9 additions & 0 deletions ledger/src/bank_forks_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ pub fn load_bank_forks(
(bank_forks, None)
};

bank_forks
.read()
.expect("Failed to read lock the bank forks")
.root_bank()
.loaded_programs_cache
.write()
.expect("Failed to write lock the program cache")
.set_fork_graph(bank_forks.clone());

let mut leader_schedule_cache =
LeaderScheduleCache::new_from_bank(&bank_forks.read().unwrap().root_bank());
if process_options.full_leader_cache {
Expand Down
5 changes: 5 additions & 0 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,11 @@ fn load_frozen_forks(
root = new_root_bank.slot();

leader_schedule_cache.set_root(new_root_bank);
new_root_bank
.loaded_programs_cache
.write()
.unwrap()
.prune(root, new_root_bank.epoch());
let _ = bank_forks.write().unwrap().set_root(
root,
accounts_background_request_sender,
Expand Down
Loading

0 comments on commit cc4b71a

Please sign in to comment.