Skip to content

Commit

Permalink
Also consider programs modified by tx
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun committed Apr 25, 2024
1 parent cc12279 commit d50c11c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions program-runtime/src/loaded_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ pub struct ProgramCacheForTxBatch {
pub latest_root_epoch: Epoch,
pub hit_max_limit: bool,
pub loaded_missing: bool,
pub merged_modified: bool,
}

impl ProgramCacheForTxBatch {
Expand All @@ -656,6 +657,7 @@ impl ProgramCacheForTxBatch {
latest_root_epoch,
hit_max_limit: false,
loaded_missing: false,
merged_modified: false,
}
}

Expand All @@ -672,6 +674,7 @@ impl ProgramCacheForTxBatch {
latest_root_epoch: cache.latest_root_epoch,
hit_max_limit: false,
loaded_missing: false,
merged_modified: false,
}
}

Expand Down Expand Up @@ -725,6 +728,7 @@ impl ProgramCacheForTxBatch {

pub fn merge(&mut self, other: &Self) {
other.entries.iter().for_each(|(key, entry)| {
self.merged_modified = true;
self.replenish(*key, entry.clone());
})
}
Expand Down
10 changes: 6 additions & 4 deletions svm/src/transaction_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,12 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
execution_time.stop();

// Skip eviction when there's no chance this particular tx batch has increased the size of
// ProgramCache entries. Note that this flag is deliberately defined, so that there's still
// at least one other batch, which will evict the program cache, even after the occurrences
// of cooperative loading.
if programs_loaded_for_tx_batch.borrow().loaded_missing {
// ProgramCache entries. Note that loaded_missing is deliberately defined, so that there's
// still at least one other batch, which will evict the program cache, even after the
// occurrences of cooperative loading.
if programs_loaded_for_tx_batch.borrow().loaded_missing
|| programs_loaded_for_tx_batch.borrow().merged_modified
{
const SHRINK_LOADED_PROGRAMS_TO_PERCENTAGE: u8 = 90;
self.program_cache
.write()
Expand Down

0 comments on commit d50c11c

Please sign in to comment.