Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
163 commits
Select commit Hold shift + click to select a range
c65078e
save
ryoqun Jan 11, 2024
67bca6a
save
ryoqun Jan 11, 2024
d847b35
save
ryoqun Jan 11, 2024
2e875e8
save
ryoqun Jan 11, 2024
0155178
save
ryoqun Jan 11, 2024
0d5db3f
save
ryoqun Jan 11, 2024
d7b49cc
save
ryoqun Jan 11, 2024
ccde07a
save
ryoqun Jan 11, 2024
952c824
save
ryoqun Jan 11, 2024
31a1775
save
ryoqun Jan 11, 2024
23d9f0b
save
ryoqun Jan 11, 2024
6ae370b
save
ryoqun Jan 11, 2024
8ccf45d
save
ryoqun Jan 11, 2024
23be704
save
ryoqun Jan 11, 2024
06e1320
save
ryoqun Jan 11, 2024
9be3306
save
ryoqun Jan 11, 2024
9cf254d
save
ryoqun Jan 11, 2024
367ff1d
save
ryoqun Jan 11, 2024
8879780
save
ryoqun Jan 11, 2024
599c7d3
save
ryoqun Jan 11, 2024
0a4d8f2
save
ryoqun Jan 11, 2024
8422f69
save
ryoqun Jan 11, 2024
a3adb81
save
ryoqun Jan 11, 2024
262ee34
save
ryoqun Jan 11, 2024
aa2b419
save
ryoqun Jan 11, 2024
9e7db82
save
ryoqun Jan 11, 2024
5243b85
save
ryoqun Jan 11, 2024
3ce17f7
save
ryoqun Jan 11, 2024
83e1631
save
ryoqun Jan 11, 2024
e335046
save
ryoqun Jan 11, 2024
be76a2c
save
ryoqun Jan 11, 2024
3d07af9
save
ryoqun Jan 11, 2024
9d520e9
save
ryoqun Jan 11, 2024
8d58e9b
save
ryoqun Jan 11, 2024
943a84b
save
ryoqun Jan 11, 2024
64e2d1b
save
ryoqun Jan 11, 2024
999267c
save
ryoqun Jan 11, 2024
1dfeff8
save
ryoqun Jan 11, 2024
4a0b6ef
save
ryoqun Jan 11, 2024
bf53020
save
ryoqun Jan 11, 2024
05e0275
save
ryoqun Jan 11, 2024
8e9c45c
save
ryoqun Jan 11, 2024
8ce6fa8
save
ryoqun Jan 11, 2024
e34dd75
save
ryoqun Jan 11, 2024
8ee42f8
save
ryoqun Jan 11, 2024
575c25a
save
ryoqun Jan 11, 2024
ba8b9c8
save
ryoqun Jan 11, 2024
e12eac8
save
ryoqun Jan 11, 2024
645739b
save
ryoqun Jan 11, 2024
d2f0cf9
save
ryoqun Jan 11, 2024
478dfcb
save
ryoqun Jan 11, 2024
22f4236
save
ryoqun Jan 11, 2024
84f7544
save
ryoqun Jan 11, 2024
2ff975f
save
ryoqun Jan 11, 2024
23a98dc
save
ryoqun Jan 11, 2024
93480e1
save
ryoqun Jan 11, 2024
dd18856
save
ryoqun Jan 11, 2024
71620a6
save
ryoqun Jan 11, 2024
b5e5f1e
save
ryoqun Jan 11, 2024
0879a93
save
ryoqun Jan 11, 2024
84a4d88
save
ryoqun Jan 11, 2024
2a54ddf
save
ryoqun Jan 11, 2024
440fb22
save
ryoqun Jan 11, 2024
7bbba8c
save
ryoqun Jan 11, 2024
68c0526
save
ryoqun Jan 11, 2024
24817d2
save
ryoqun Jan 11, 2024
a50e8fa
save
ryoqun Jan 11, 2024
55c8998
save
ryoqun Jan 11, 2024
e39626a
save
ryoqun Jan 11, 2024
ed80b77
save
ryoqun Jan 11, 2024
b68cd98
save
ryoqun Jan 11, 2024
548330b
save
ryoqun Jan 11, 2024
2b80f63
save
ryoqun Jan 11, 2024
c2388e3
save
ryoqun Jan 11, 2024
75b245f
save
ryoqun Jan 11, 2024
25b5c35
save
ryoqun Jan 11, 2024
760a56d
save
ryoqun Jan 11, 2024
3a5fd7e
save
ryoqun Jan 11, 2024
5c03919
save
ryoqun Jan 11, 2024
839d0b6
save
ryoqun Jan 11, 2024
43a23cc
save
ryoqun Jan 11, 2024
6c4bb77
save
ryoqun Jan 11, 2024
469773a
save
ryoqun Jan 11, 2024
a30933d
save
ryoqun Jan 11, 2024
f4f19b9
save
ryoqun Jan 11, 2024
f8af3e2
save
ryoqun Jan 11, 2024
c25cc56
save
ryoqun Jan 11, 2024
3e2dfc2
save
ryoqun Jan 11, 2024
ab0b460
save
ryoqun Jan 11, 2024
adb79d8
save
ryoqun Jan 11, 2024
438ad49
save
ryoqun Jan 11, 2024
e7d3fba
save
ryoqun Jan 11, 2024
a7bcb93
save
ryoqun Jan 11, 2024
37ba7eb
save
ryoqun Jan 11, 2024
8825467
save
ryoqun Jan 11, 2024
74c604e
save
ryoqun Jan 11, 2024
dd0ee30
save
ryoqun Jan 11, 2024
6a8ecd3
save
ryoqun Jan 11, 2024
a763bcf
save
ryoqun Jan 11, 2024
e1b9bc2
save
ryoqun Jan 11, 2024
0420016
save
ryoqun Jan 11, 2024
3f21e4e
save
ryoqun Jan 11, 2024
84806d2
save
ryoqun Jan 11, 2024
102f6dc
save
ryoqun Jan 11, 2024
959f937
save
ryoqun Jan 11, 2024
0c1c15e
save
ryoqun Jan 11, 2024
39da159
save
ryoqun Jan 11, 2024
aa1b475
save
ryoqun Jan 11, 2024
a6e2fb7
save
ryoqun Jan 11, 2024
af161fb
save
ryoqun Jan 11, 2024
65d11fe
save
ryoqun Jan 11, 2024
b488a06
save
ryoqun Jan 11, 2024
36b8ce9
save
ryoqun Jan 11, 2024
a0c364d
save
ryoqun Jan 11, 2024
46463ab
save
ryoqun Jan 11, 2024
d8e3ad0
save
ryoqun Jan 11, 2024
1b436b3
save
ryoqun Jan 11, 2024
2764d85
save
ryoqun Jan 11, 2024
5c2fe99
save
ryoqun Jan 11, 2024
a8be061
save
ryoqun Jan 11, 2024
2c87a2e
save
ryoqun Jan 11, 2024
d1b68b6
save
ryoqun Jan 11, 2024
a5c6b2f
save
ryoqun Jan 11, 2024
9a7ecd3
save
ryoqun Jan 11, 2024
d46a83e
save
ryoqun Jan 12, 2024
c6dc3c4
save
ryoqun Jan 12, 2024
a9c3615
save
ryoqun Jan 12, 2024
9df74b4
save
ryoqun Jan 12, 2024
8baa1b2
save
ryoqun Jan 12, 2024
57cc007
save
ryoqun Jan 12, 2024
be0766c
save
ryoqun Jan 12, 2024
c98c576
save
ryoqun Jan 12, 2024
9f1de5e
save
ryoqun Jan 12, 2024
38321fb
save
ryoqun Jan 12, 2024
9dfecae
save
ryoqun Jan 12, 2024
1851867
save
ryoqun Jan 12, 2024
308e8c6
save
ryoqun Jan 12, 2024
9d74262
save
ryoqun Jan 12, 2024
07ff2f0
save
ryoqun Jan 12, 2024
6eb6ec7
save
ryoqun Jan 12, 2024
720a38f
save
ryoqun Jan 12, 2024
6cfc072
save
ryoqun Jan 12, 2024
0e72c4a
save
ryoqun Jan 12, 2024
6f0d656
save
ryoqun Jan 12, 2024
a9fa4c1
save
ryoqun Jan 12, 2024
e46eba5
save
ryoqun Jan 12, 2024
578a43f
save
ryoqun Jan 12, 2024
58b7d70
save
ryoqun Jan 12, 2024
42f8e4b
save
ryoqun Jan 12, 2024
607dfc7
save
ryoqun Jan 12, 2024
2516063
save
ryoqun Jan 12, 2024
d9747e9
save
ryoqun Jan 12, 2024
4c4fe80
save
ryoqun Jan 12, 2024
b99db67
save
ryoqun Jan 12, 2024
8dfd96c
save
ryoqun Jan 12, 2024
3a6ab92
save
ryoqun Jan 12, 2024
9b7cec4
save
ryoqun Jan 12, 2024
f94dfad
save
ryoqun Jan 12, 2024
39f6845
save
ryoqun Jan 12, 2024
dc2d89d
save
ryoqun Jan 12, 2024
bbaa3e3
save
ryoqun Jan 12, 2024
ce1d43b
save
ryoqun Jan 12, 2024
cc1ae72
save
ryoqun Jan 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5118,7 +5118,7 @@ impl AccountsDb {
ancestors: &Ancestors,
pubkey: &Pubkey,
) -> Option<(AccountSharedData, Slot)> {
self.load(ancestors, pubkey, LoadHint::FixedMaxRoot)
Some((AccountSharedData::new(1111111, 0, &Default::default()), 3))//self.load(ancestors, pubkey, LoadHint::FixedMaxRoot)
}

fn read_index_for_accessor_or_load_slow<'a>(
Expand Down
1 change: 1 addition & 0 deletions ledger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ rand = { workspace = true }
rand_chacha = { workspace = true }
rayon = { workspace = true }
reed-solomon-erasure = { workspace = true, features = ["simd-accel"] }
rustix = { version = "0.38.28", features = ["thread"] }
scopeguard = { workspace = true }
serde = { workspace = true }
serde_bytes = { workspace = true }
Expand Down
143 changes: 114 additions & 29 deletions ledger/benches/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use {
std::{borrow::Cow, sync::Arc},
test::Bencher,
};
use solana_ledger::blockstore_processor::execute_batch2;

extern crate test;

Expand Down Expand Up @@ -112,65 +113,149 @@ fn bench_execute_batch(
bank,
prioritization_fee_cache,
} = setup(apply_cost_tracker_during_replay);
let transactions = create_transactions(&bank, 2_usize.pow(20));
let transactions = create_transactions(&bank, 2_usize.pow(19));
let bank2 = bank.clone();
let batches: Vec<_> = transactions
.chunks(batch_size)
.map(|txs| {
let mut batch =
TransactionBatch::new(vec![Ok(()); txs.len()], &bank, Cow::Borrowed(txs));
TransactionBatch::new(vec![Ok(()); txs.len()], &bank2, Cow::Borrowed(txs));
batch.set_needs_unlock(false);
TransactionBatchWithIndexes {
batch,
transaction_indexes: (0..batch_size).collect(),
}
})
.collect();
let mut batches_iter = batches.into_iter();
let mut batches_iter = batches.iter();

let mut timing = ExecuteTimings::default();
bencher.iter({
let bank = bank.clone();
move || {
let batch = batches_iter.next().unwrap();
execute_batch(
&batch,
&bank,
None,
None,
&mut timing,
None,
&prioritization_fee_cache,
)
}
let batch = batches_iter.next().unwrap();

std::thread::scope(move |scope| {
scope.spawn(move || {
//eprintln!("profile me!: {}", rustix::thread::gettid().as_raw_nonzero().get());
//std::thread::sleep(std::time::Duration::from_secs(10));
bencher.iter(|| {
//for _ in 0..3 {
//let now = std::time::Instant::now();
//let iteration_count_for_profiling = 100;
//for _ in 0..iteration_count_for_profiling {
for _ in 0..(64/batch_size) {
execute_batch(
&batch,
&bank,
None,
None,
&mut timing,
None,
&prioritization_fee_cache,
).unwrap();
}
//}
});
//dbg!(now.elapsed());
//}
});
});
drop(batches);
//eprintln!("{:?}", timing);
}

fn bench_execute_batch2(
bencher: &mut Bencher,
batch_size: usize,
apply_cost_tracker_during_replay: bool,
) {
let BenchFrame {
bank,
prioritization_fee_cache,
} = setup(apply_cost_tracker_during_replay);
let transactions = create_transactions(&bank, 2_usize.pow(19));
let bank2 = bank.clone();
let batches: Vec<_> = transactions
.chunks(batch_size)
.map(|txs| {
let mut batch =
TransactionBatch::new(vec![Ok(()); txs.len()], &bank2, Cow::Borrowed(txs));
batch.set_needs_unlock(false);
TransactionBatchWithIndexes {
batch,
transaction_indexes: (0..batch_size).collect(),
}
})
.collect();
let mut batches_iter = batches.iter();

let mut timing = ExecuteTimings::default();
let batch = batches_iter.next().unwrap();

std::thread::scope(move |scope| {
scope.spawn(move || {
//eprintln!("profile me!: {}", rustix::thread::gettid().as_raw_nonzero().get());
//std::thread::sleep(std::time::Duration::from_secs(10));
bencher.iter(|| {
//for _ in 0..3 {
//let now = std::time::Instant::now();
//let iteration_count_for_profiling = 100;
//for _ in 0..iteration_count_for_profiling {
for _ in 0..(64/batch_size) {
execute_batch2(
&batch,
&bank,
None,
None,
&mut timing,
None,
&prioritization_fee_cache,
).unwrap();
}
//}
});
//dbg!(now.elapsed());
//}
});
});
drop(batches);
//eprintln!("{:?}", timing);
}

#[bench]
fn bench_execute_batch_01_txes_per_batch(bencher: &mut Bencher) {
bench_execute_batch(bencher, 1, false);
}

#[bench]
fn bench_execute_batch_unbatched(bencher: &mut Bencher) {
bench_execute_batch(bencher, 1, true);
fn bench_execute_batch_04_txes_per_batch(bencher: &mut Bencher) {
bench_execute_batch(bencher, 4, false);
}

#[bench]
fn bench_execute_batch_half_batch(bencher: &mut Bencher) {
bench_execute_batch(bencher, 32, true);
fn bench_execute_batch_16_txes_per_batch(bencher: &mut Bencher) {
bench_execute_batch(bencher, 16, false);
}

#[bench]
fn bench_execute_batch_full_batch(bencher: &mut Bencher) {
bench_execute_batch(bencher, 64, true);
fn bench_execute_batch_64_txes_per_batch(bencher: &mut Bencher) {
bench_execute_batch(bencher, 64, false);
}

#[bench]
fn bench_execute_batch_unbatched_disable_tx_cost_update(bencher: &mut Bencher) {
bench_execute_batch(bencher, 1, false);
fn bench_execute_batch_flattend_01_txes_per_batch(bencher: &mut Bencher) {
bench_execute_batch2(bencher, 1, false);
}

#[bench]
fn bench_execute_batch_half_batch_disable_tx_cost_update(bencher: &mut Bencher) {
bench_execute_batch(bencher, 32, false);
fn bench_execute_batch_flattend_04_txes_per_batch(bencher: &mut Bencher) {
bench_execute_batch2(bencher, 4, false);
}

#[bench]
fn bench_execute_batch_full_batch_disable_tx_cost_update(bencher: &mut Bencher) {
bench_execute_batch(bencher, 64, false);
fn bench_execute_batch_flattend_16_txes_per_batch(bencher: &mut Bencher) {
bench_execute_batch2(bencher, 16, false);
}

#[bench]
fn bench_execute_batch_flattend_64_txes_per_batch(bencher: &mut Bencher) {
bench_execute_batch2(bencher, 64, false);
}
124 changes: 35 additions & 89 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub fn execute_batch(
vec![]
};

let (tx_results, balances) = batch.bank().load_execute_and_commit_transactions(
batch.bank().load_execute_and_commit_transactions(
batch,
MAX_PROCESSING_AGE,
transaction_status_sender.is_some(),
Expand All @@ -168,51 +168,44 @@ pub fn execute_batch(
log_messages_bytes_limit,
);

bank_utils::find_and_send_votes(
batch.sanitized_transactions(),
&tx_results,
replay_vote_sender,
);

let TransactionResults {
fee_collection_results,
execution_results,
rent_debits,
..
} = tx_results;
Ok(())
}

let executed_transactions = execution_results
.iter()
.zip(batch.sanitized_transactions())
.filter_map(|(execution_result, tx)| execution_result.was_executed().then_some(tx))
.collect_vec();
pub fn execute_batch2(
batch: &TransactionBatchWithIndexes,
bank: &Arc<Bank>,
transaction_status_sender: Option<&TransactionStatusSender>,
replay_vote_sender: Option<&ReplayVoteSender>,
timings: &mut ExecuteTimings,
log_messages_bytes_limit: Option<usize>,
prioritization_fee_cache: &PrioritizationFeeCache,
) -> Result<()> {
let TransactionBatchWithIndexes {
batch,
transaction_indexes,
} = batch;
let record_token_balances = transaction_status_sender.is_some();

if let Some(transaction_status_sender) = transaction_status_sender {
let transactions = batch.sanitized_transactions().to_vec();
let post_token_balances = if record_token_balances {
collect_token_balances(bank, batch, &mut mint_decimals)
} else {
vec![]
};
let mut mint_decimals: HashMap<Pubkey, u8> = HashMap::new();

let token_balances =
TransactionTokenBalancesSet::new(pre_token_balances, post_token_balances);

transaction_status_sender.send_transaction_status_batch(
bank.clone(),
transactions,
execution_results,
balances,
token_balances,
rent_debits,
transaction_indexes.to_vec(),
);
}
let pre_token_balances = if record_token_balances {
collect_token_balances(bank, batch, &mut mint_decimals)
} else {
vec![]
};

prioritization_fee_cache.update(bank, executed_transactions.into_iter());
batch.bank().load_execute_and_commit_transactions2(
batch,
MAX_PROCESSING_AGE,
transaction_status_sender.is_some(),
transaction_status_sender.is_some(),
transaction_status_sender.is_some(),
transaction_status_sender.is_some(),
timings,
log_messages_bytes_limit,
);

let first_err = get_first_error(batch, fee_collection_results);
first_err.map(|(result, _)| result).unwrap_or(Ok(()))
Ok(())
}

#[derive(Default)]
Expand Down Expand Up @@ -3914,54 +3907,7 @@ pub mod tests {

#[test]
fn test_get_first_error() {
let GenesisConfigInfo {
genesis_config,
mint_keypair,
..
} = create_genesis_config(1_000_000_000);
let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0;

let present_account_key = Keypair::new();
let present_account = AccountSharedData::new(1, 10, &Pubkey::default());
bank.store_account(&present_account_key.pubkey(), &present_account);

let keypair = Keypair::new();

// Create array of two transactions which throw different errors
let account_not_found_tx = system_transaction::transfer(
&keypair,
&solana_sdk::pubkey::new_rand(),
42,
bank.last_blockhash(),
);
let account_not_found_sig = account_not_found_tx.signatures[0];
let invalid_blockhash_tx = system_transaction::transfer(
&mint_keypair,
&solana_sdk::pubkey::new_rand(),
42,
Hash::default(),
);
let txs = vec![account_not_found_tx, invalid_blockhash_tx];
let batch = bank.prepare_batch_for_tests(txs);
let (
TransactionResults {
fee_collection_results,
..
},
_balances,
) = batch.bank().load_execute_and_commit_transactions(
&batch,
MAX_PROCESSING_AGE,
false,
false,
false,
false,
&mut ExecuteTimings::default(),
None,
);
let (err, signature) = get_first_error(&batch, fee_collection_results).unwrap();
assert_eq!(err.unwrap_err(), TransactionError::AccountNotFound);
assert_eq!(signature, account_not_found_sig);
todo!();
}

#[test]
Expand Down
Loading