Skip to content

Commit

Permalink
[JIT-1710] - Optimize Bundle Consumer Checks (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
esemeniuc authored and buffalu committed Dec 11, 2023
1 parent 4cd94ff commit f3a8346
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ members = [
"rpc-client-nonce-utils",
"rpc-test",
"runtime",
"runtime-transaction",
"runtime-plugin",
"runtime-transaction",
"sdk",
"sdk/cargo-build-bpf",
"sdk/cargo-build-sbf",
Expand Down
1 change: 1 addition & 0 deletions bundle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ thiserror = { workspace = true }
[dev-dependencies]
assert_matches = { workspace = true }
solana-logger = { workspace = true }
solana-runtime = { workspace = true, features = ["dev-context-only-utils"] }

[lib]
crate-type = ["lib"]
Expand Down
8 changes: 4 additions & 4 deletions bundle/src/bundle_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ mod tests {

fn create_simple_test_bank(lamports: u64) -> (GenesisConfigInfo, Arc<Bank>) {
let genesis_config_info = create_genesis_config(lamports);
let bank = Arc::new(Bank::new_for_tests(&genesis_config_info.genesis_config));
let (bank, _) = Bank::new_with_bank_forks_for_tests(&genesis_config_info.genesis_config);
(genesis_config_info, bank)
}

Expand Down Expand Up @@ -588,7 +588,7 @@ mod tests {

// check to make sure there was one batch returned with one transaction that was the same that was put in
assert_eq!(execution_result.bundle_transaction_results.len(), 1);
let tx_result = execution_result.bundle_transaction_results.get(0).unwrap();
let tx_result = execution_result.bundle_transaction_results.first().unwrap();
assert_eq!(tx_result.transactions.len(), 1);
assert_eq!(tx_result.transactions[0], bundle.transactions[0]);

Expand All @@ -603,14 +603,14 @@ mod tests {
let execution_result = tx_result
.load_and_execute_transactions_output
.execution_results
.get(0)
.first()
.unwrap();
assert!(execution_result.was_executed());
assert!(execution_result.was_executed_successfully());

// Make sure the post-balances are correct
assert_eq!(tx_result.pre_balance_info.native.len(), 1);
let post_tx_sol_balances = tx_result.post_balance_info.0.get(0).unwrap();
let post_tx_sol_balances = tx_result.post_balance_info.0.first().unwrap();

let minter_message_index =
find_account_index(&transactions[0], &genesis_config_info.mint_keypair.pubkey())
Expand Down
2 changes: 1 addition & 1 deletion ci/buildkite-pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ wait_step() {
all_test_steps() {
command_step checks1 ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-checks.sh" 20 check
command_step checks2 ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-dev-context-only-utils.sh check-bins" 15 check
command_step checks3 ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-dev-context-only-utils.sh check-all-targets" 15 check
command_step checks3 ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_nightly_docker_image ci/test-dev-context-only-utils.sh check-all-targets" 20 check
wait_step

# Full test suite
Expand Down
11 changes: 10 additions & 1 deletion core/benches/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ fn bench_consume_buffered(bencher: &mut Bencher) {
);
let (s, _r) = unbounded();
let committer = Committer::new(None, s, Arc::new(PrioritizationFeeCache::new(0u64)));
let consumer = Consumer::new(committer, recorder, QosService::new(1), None);
let consumer = Consumer::new(
committer,
recorder,
QosService::new(1),
None,
HashSet::default(),
BundleAccountLocker::default(),
);
// This tests the performance of buffering packets.
// If the packet buffers are copied, performance will be poor.
bencher.iter(move || {
Expand Down Expand Up @@ -311,6 +318,8 @@ fn bench_banking(bencher: &mut Bencher, tx_type: TransactionType) {
Arc::new(ConnectionCache::new("connection_cache_test")),
bank_forks,
&Arc::new(PrioritizationFeeCache::new(0u64)),
HashSet::default(),
BundleAccountLocker::default(),
);

let chunk_len = verified.len() / CHUNKS;
Expand Down
3 changes: 2 additions & 1 deletion core/src/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ impl BankingStage {
Self { bank_thread_hdls }
}

#[allow(clippy::too_many_arguments)]
fn spawn_thread_local_multi_iterator_thread(
id: u32,
packet_receiver: BankingPacketReceiver,
Expand Down Expand Up @@ -1311,7 +1312,7 @@ mod tests {
bank,
entries_ticks,
} = entry_receiver.recv().unwrap();
let entry = &entries_ticks.get(0).unwrap().0;
let entry = &entries_ticks.first().unwrap().0;
assert_eq!(entry.transactions, txs);

// Once bank is set to a new bank (setting bank.slot() + 1 in record_transactions),
Expand Down
2 changes: 1 addition & 1 deletion core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ mod tests {
}) = entry_receiver.recv()
{
assert!(entries_ticks.len() == 1);
let entry = &entries_ticks.get(0).unwrap().0;
let entry = &entries_ticks.first().unwrap().0;
if !entry.is_tick() {
trace!("got entry");
assert_eq!(entry.transactions.len(), transactions.len());
Expand Down
16 changes: 8 additions & 8 deletions core/src/bundle_stage/bundle_consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,11 @@ impl BundleConsumer {
return Err(BundleExecutionError::BankProcessingTimeLimitReached);
}

if Self::bundle_touches_tip_pdas(
locked_bundle.sanitized_bundle(),
&tip_manager.get_tip_accounts(),
) && bank_start.working_bank.slot() != *last_tip_updated_slot
if bank_start.working_bank.slot() != *last_tip_updated_slot
&& Self::bundle_touches_tip_pdas(
locked_bundle.sanitized_bundle(),
&tip_manager.get_tip_accounts(),
)
{
let start = Instant::now();
let result = Self::handle_tip_programs(
Expand Down Expand Up @@ -810,7 +811,6 @@ mod tests {
solana_sdk::{
bundle::{derive_bundle_id, SanitizedBundle},
clock::MAX_PROCESSING_AGE,
feature_set::delay_visibility_of_program_deployment,
fee_calculator::{FeeRateGovernor, DEFAULT_TARGET_LAMPORTS_PER_SIGNATURE},
genesis_config::ClusterType,
hash::Hash,
Expand Down Expand Up @@ -936,9 +936,9 @@ mod tests {

// workaround for https://github.com/solana-labs/solana/issues/30085
// the test can deploy and use spl_programs in the genensis slot without waiting for the next one
let mut bank = Bank::new_for_tests(&genesis_config);
bank.deactivate_feature(&delay_visibility_of_program_deployment::id());
let bank = Arc::new(bank);
let (bank, _) = Bank::new_with_bank_forks_for_tests(&genesis_config);

let bank = Arc::new(Bank::new_from_parent(bank, &Pubkey::default(), 1));

let ledger_path = get_tmp_ledger_path_auto_delete!();
let blockstore = Arc::new(
Expand Down
6 changes: 2 additions & 4 deletions core/src/bundle_stage/bundle_reserved_space_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ impl BundleReservedSpaceManager {
mod tests {
use {
crate::bundle_stage::bundle_reserved_space_manager::BundleReservedSpaceManager,
solana_ledger::genesis_utils::create_genesis_config,
solana_runtime::bank::Bank,
solana_sdk::{hash::Hash, pubkey::Pubkey},
std::sync::{Arc, RwLock},
solana_ledger::genesis_utils::create_genesis_config, solana_runtime::bank::Bank,
solana_sdk::pubkey::Pubkey, std::sync::Arc,
};

#[test]
Expand Down
1 change: 1 addition & 0 deletions tip-distributor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ thiserror = { workspace = true }
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }

[dev-dependencies]
solana-runtime = { workspace = true, features = ["dev-context-only-utils"] }
solana-sdk = { workspace = true, features = ["dev-context-only-utils"] }

[[bin]]
Expand Down
3 changes: 1 addition & 2 deletions tip-distributor/src/stake_meta_generator_workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ mod tests {
vec![INITIAL_VALIDATOR_STAKES; 3],
);

let bank = Bank::new_for_tests(&genesis_config);
let (mut bank, _) = Bank::new_with_bank_forks_for_tests(&genesis_config);

/* 2. Seed the Bank with [TipDistributionAccount]'s */
let merkle_root_upload_authority = Pubkey::new_unique();
Expand Down Expand Up @@ -585,7 +585,6 @@ mod tests {
))
}

let mut bank = Arc::new(bank);
let mut stake_pubkeys = validator_0_delegations
.iter()
.map(|v| v.stake_account_pubkey)
Expand Down
2 changes: 1 addition & 1 deletion turbine/benches/retransmit_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use {
net::{Ipv4Addr, UdpSocket},
sync::{
atomic::{AtomicUsize, Ordering},
Arc,
Arc, RwLock,
},
thread::{sleep, Builder},
time::Duration,
Expand Down

0 comments on commit f3a8346

Please sign in to comment.