Increment usage count for loaded programs and call eviction (#30900)

This commit is contained in:
Pankaj Garg 2023-03-27 06:48:05 -07:00 committed by GitHub
parent 3bc670a47b
commit 0df28f6d51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -68,7 +68,7 @@ use {
fmt::Debug,
mem,
rc::Rc,
sync::Arc,
sync::{atomic::Ordering, Arc},
},
thiserror::Error,
};
@ -588,6 +588,8 @@ fn process_instruction_common(
if let Some(load_program_metrics) = load_program_metrics {
load_program_metrics.submit_datapoint(&mut invoke_context.timings);
}
executor.usage_counter.fetch_add(1, Ordering::Relaxed);
match &executor.program {
LoadedProgramType::Invalid => Err(InstructionError::InvalidAccountData),
LoadedProgramType::LegacyV0(executable) => execute(executable, invoke_context),

View File

@ -30,7 +30,11 @@ use {
saturating_add_assign,
transaction_context::{BorrowedAccount, InstructionContext},
},
std::{cell::RefCell, rc::Rc, sync::Arc},
std::{
cell::RefCell,
rc::Rc,
sync::{atomic::Ordering, Arc},
},
};
fn get_state(data: &[u8]) -> Result<&LoaderV3State, InstructionError> {
@ -584,6 +588,7 @@ pub fn process_instruction(invoke_context: &mut InvokeContext) -> Result<(), Ins
get_or_create_executor_time.as_us()
);
drop(program);
loaded_program.usage_counter.fetch_add(1, Ordering::Relaxed);
match &loaded_program.program {
LoadedProgramType::Invalid => Err(InstructionError::InvalidAccountData),
LoadedProgramType::Typed(executable) => execute(invoke_context, executable),

View File

@ -4650,6 +4650,11 @@ impl Bank {
execution_time.stop();
self.loaded_programs_cache
.write()
.unwrap()
.sort_and_evict(None);
debug!(
"check: {}us load: {}us execute: {}us txs_len={}",
check_time.as_us(),