Skip to content

Commit

Permalink
test-validator: Always use overridden compute budget in bank (solana-…
Browse files Browse the repository at this point in the history
  • Loading branch information
joncinque authored May 11, 2022
1 parent 766e361 commit 542a14d
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4372,34 +4372,37 @@ impl Bank {
feature_set_clone_time.as_us()
);

let tx_wide_compute_cap = feature_set.is_active(&tx_wide_compute_cap::id());
let compute_budget_max_units = if tx_wide_compute_cap {
compute_budget::MAX_UNITS
let compute_budget = if let Some(compute_budget) = self.compute_budget {
compute_budget
} else {
compute_budget::DEFAULT_UNITS
};
let mut compute_budget = self
.compute_budget
.unwrap_or_else(|| ComputeBudget::new(compute_budget_max_units));
if tx_wide_compute_cap {
let mut compute_budget_process_transaction_time =
Measure::start("compute_budget_process_transaction_time");
let process_transaction_result = compute_budget.process_message(
tx.message(),
feature_set.is_active(&requestable_heap_size::id()),
feature_set.is_active(&default_units_per_instruction::id()),
);
compute_budget_process_transaction_time.stop();
saturating_add_assign!(
timings
.execute_accessories
.compute_budget_process_transaction_us,
compute_budget_process_transaction_time.as_us()
);
if let Err(err) = process_transaction_result {
return TransactionExecutionResult::NotExecuted(err);
let tx_wide_compute_cap = feature_set.is_active(&tx_wide_compute_cap::id());
let compute_budget_max_units = if tx_wide_compute_cap {
compute_budget::MAX_UNITS
} else {
compute_budget::DEFAULT_UNITS
};
let mut compute_budget = ComputeBudget::new(compute_budget_max_units);
if tx_wide_compute_cap {
let mut compute_budget_process_transaction_time =
Measure::start("compute_budget_process_transaction_time");
let process_transaction_result = compute_budget.process_message(
tx.message(),
feature_set.is_active(&requestable_heap_size::id()),
feature_set.is_active(&default_units_per_instruction::id()),
);
compute_budget_process_transaction_time.stop();
saturating_add_assign!(
timings
.execute_accessories
.compute_budget_process_transaction_us,
compute_budget_process_transaction_time.as_us()
);
if let Err(err) = process_transaction_result {
return TransactionExecutionResult::NotExecuted(err);
}
}
}
compute_budget
};

self.execute_loaded_transaction(
tx,
Expand Down

0 comments on commit 542a14d

Please sign in to comment.