Skip to content

Commit

Permalink
QoS refactor: Allow pre-filtering (solana-labs#31542)
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge authored and pull[bot] committed Nov 20, 2023
1 parent 3829c1d commit 7feefc5
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 195 deletions.
23 changes: 14 additions & 9 deletions core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,18 +394,24 @@ impl Consumer {
chunk_offset: usize,
) -> ProcessTransactionBatchOutput {
let (
(transaction_costs, transactions_qos_results, cost_model_throttled_transactions_count),
(transaction_qos_cost_results, cost_model_throttled_transactions_count),
cost_model_us,
) = measure_us!(self
.qos_service
.select_and_accumulate_transaction_costs(bank, txs));
) = measure_us!(self.qos_service.select_and_accumulate_transaction_costs(
bank,
txs,
std::iter::repeat(Ok(())) // no filtering before QoS
));

// Only lock accounts for those transactions are selected for the block;
// Once accounts are locked, other threads cannot encode transactions that will modify the
// same account state
let (batch, lock_us) = measure_us!(
bank.prepare_sanitized_batch_with_results(txs, transactions_qos_results.iter())
);
let (batch, lock_us) = measure_us!(bank.prepare_sanitized_batch_with_results(
txs,
transaction_qos_cost_results.iter().map(|r| match r {
Ok(_cost) => Ok(()),
Err(err) => Err(err.clone()),
})
));

// retryable_txs includes AccountInUse, WouldExceedMaxBlockCostLimit
// WouldExceedMaxAccountCostLimit, WouldExceedMaxVoteCostLimit
Expand All @@ -424,8 +430,7 @@ impl Consumer {
} = execute_and_commit_transactions_output;

QosService::update_or_remove_transaction_costs(
transaction_costs.iter(),
transactions_qos_results.iter(),
transaction_qos_cost_results.iter(),
commit_transactions_result.as_ref().ok(),
bank,
);
Expand Down
Loading

0 comments on commit 7feefc5

Please sign in to comment.