Skip to content

Commit

Permalink
Add limit to looping in banking-stage (#35342)
Browse files Browse the repository at this point in the history
(cherry picked from commit 990ca1d)

# Conflicts:
#	runtime/src/bank.rs
#	svm/src/transaction_processor.rs
  • Loading branch information
pgarg66 authored and mergify[bot] committed Feb 29, 2024
1 parent 1bf7b19 commit 259692f
Show file tree
Hide file tree
Showing 4 changed files with 1,011 additions and 4 deletions.
3 changes: 2 additions & 1 deletion core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@ impl Consumer {
transaction_status_sender_enabled,
&mut execute_and_commit_timings.execute_timings,
None, // account_overrides
self.log_messages_bytes_limit
self.log_messages_bytes_limit,
true,
));
execute_and_commit_timings.load_execute_us = load_execute_us;

Expand Down
9 changes: 6 additions & 3 deletions program-runtime/src/loaded_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl Stats {
("reloads", reloads, i64),
("insertions", insertions, i64),
("lost_insertions", lost_insertions, i64),
("replacements", replacements, i64),
("replace_entry", replacements, i64),
("one_hit_wonders", one_hit_wonders, i64),
("prunes_orphan", prunes_orphan, i64),
("prunes_environment", prunes_environment, i64),
Expand Down Expand Up @@ -568,6 +568,7 @@ pub struct LoadedProgramsForTxBatch {
entries: HashMap<Pubkey, Arc<LoadedProgram>>,
slot: Slot,
pub environments: ProgramRuntimeEnvironments,
pub hit_max_limit: bool,
}

impl LoadedProgramsForTxBatch {
Expand All @@ -576,6 +577,7 @@ impl LoadedProgramsForTxBatch {
entries: HashMap::new(),
slot,
environments,
hit_max_limit: false,
}
}

Expand Down Expand Up @@ -934,7 +936,7 @@ impl<FG: ForkGraph> LoadedPrograms<FG> {
slot: Slot,
key: Pubkey,
loaded_program: Arc<LoadedProgram>,
) {
) -> bool {
let second_level = self.entries.entry(key).or_default();
debug_assert_eq!(
second_level.cooperative_loading_lock,
Expand All @@ -955,8 +957,9 @@ impl<FG: ForkGraph> LoadedPrograms<FG> {
{
self.stats.lost_insertions.fetch_add(1, Ordering::Relaxed);
}
self.assign_program(key, loaded_program);
let was_occupied = self.assign_program(key, loaded_program);
self.loading_task_waiter.notify();
was_occupied
}

pub fn merge(&mut self, tx_batch_cache: &LoadedProgramsForTxBatch) {
Expand Down
25 changes: 25 additions & 0 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4289,6 +4289,7 @@ impl Bank {
&mut timings,
Some(&account_overrides),
None,
true,
);

let post_simulation_accounts = loaded_transactions
Expand Down Expand Up @@ -4524,6 +4525,7 @@ impl Bank {
balances
}

<<<<<<< HEAD
fn program_modification_slot(&self, pubkey: &Pubkey) -> Result<Slot> {
let program = self
.get_account_with_fixed_root(pubkey)
Expand Down Expand Up @@ -5073,6 +5075,9 @@ impl Bank {
}

#[allow(clippy::type_complexity)]
=======
#[allow(clippy::too_many_arguments, clippy::type_complexity)]
>>>>>>> 990ca1d0b8 (Add limit to looping in banking-stage (#35342))
pub fn load_and_execute_transactions(
&self,
batch: &TransactionBatch,
Expand All @@ -5083,6 +5088,7 @@ impl Bank {
timings: &mut ExecuteTimings,
account_overrides: Option<&AccountOverrides>,
log_messages_bytes_limit: Option<usize>,
limit_to_load_programs: bool,
) -> LoadAndExecuteTransactionsOutput {
let sanitized_txs = batch.sanitized_transactions();
debug!("processing transactions: {}", sanitized_txs.len());
Expand Down Expand Up @@ -5133,6 +5139,7 @@ impl Bank {
);
check_time.stop();

<<<<<<< HEAD
let mut program_accounts_map = self.filter_executable_program_accounts(
&self.ancestors,
sanitized_txs,
Expand Down Expand Up @@ -5241,6 +5248,23 @@ impl Bank {
.evict_using_2s_random_selection(
Percentage::from(SHRINK_LOADED_PROGRAMS_TO_PERCENTAGE),
self.slot(),
=======
let sanitized_output = self
.transaction_processor
.load_and_execute_sanitized_transactions(
self,
sanitized_txs,
&mut check_results,
&mut error_counters,
enable_cpi_recording,
enable_log_recording,
enable_return_data_recording,
timings,
account_overrides,
self.builtin_programs.iter(),
log_messages_bytes_limit,
limit_to_load_programs,
>>>>>>> 990ca1d0b8 (Add limit to looping in banking-stage (#35342))
);

debug!(
Expand Down Expand Up @@ -6304,6 +6328,7 @@ impl Bank {
timings,
None,
log_messages_bytes_limit,
false,
);

let (last_blockhash, lamports_per_signature) =
Expand Down
Loading

0 comments on commit 259692f

Please sign in to comment.