forked from kaspanet/rusty-kaspa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimized Rothschild performance on high TPS (kaspanet#371)
* Add rothschild tx benchmark So we can compare the performance difference between serial generation and parallel generation * Optimize high TPS generation 1. Parallelize TX generation - hashing is a bottleneck so generating TXs seriallize will slow the entire loop down significantly 2. Optimize UTXO selection - previously it was running at O(UTXO) due to filtering logic * Move criterion to dev-dependency * Some more rothschild improvements * Fix from_fmillis typo * Add flags * Parallelize txid hashing in simpa * Moving ClientPool to grpc/client * Fix rothschild sending less than 100 txs Due to integer divide, when tps is < 100, we end up creating no tx * Remove obsolete temp init comment --------- Co-authored-by: Ori Newman <orinewman1@gmail.com>
- Loading branch information
1 parent
b3b19f4
commit 9d74c61
Showing
11 changed files
with
271 additions
and
68 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use rayon::prelude::*; | ||
|
||
use kaspa_consensus_core::{ | ||
constants::TX_VERSION, | ||
subnets::SUBNETWORK_ID_NATIVE, | ||
tx::{ScriptPublicKey, Transaction, TransactionInput, TransactionOutpoint, TransactionOutput}, | ||
Hash, | ||
}; | ||
|
||
fn constuct_tx() -> Transaction { | ||
let inputs = vec![TransactionInput { | ||
previous_outpoint: TransactionOutpoint { transaction_id: Hash::from_bytes([0xFF; 32]), index: 0 }, | ||
signature_script: vec![], | ||
sequence: 0, | ||
sig_op_count: 1, | ||
}]; | ||
let outputs = vec![TransactionOutput { value: 10000, script_public_key: ScriptPublicKey::from_vec(0, vec![0xff; 35]) }]; | ||
Transaction::new(TX_VERSION, inputs, outputs, 0, SUBNETWORK_ID_NATIVE, 0, vec![]) | ||
} | ||
|
||
fn construct_txs_serially() { | ||
let _ = (0..10000) | ||
.map(|_| { | ||
constuct_tx(); | ||
}) | ||
.collect::<Vec<_>>(); | ||
} | ||
|
||
fn construct_txs_parallel() { | ||
let _ = (0..10000) | ||
.into_par_iter() | ||
.map(|_| { | ||
constuct_tx(); | ||
}) | ||
.collect::<Vec<_>>(); | ||
} | ||
|
||
pub fn bench_compare_tx_generation(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("compare txs"); | ||
group.bench_function("Transaction::SerialCreation", |b| b.iter(construct_txs_serially)); | ||
group.bench_function("Transaction::ParallelCreation", |b| b.iter(construct_txs_parallel)); | ||
group.finish(); | ||
} | ||
|
||
criterion_group!(benches, bench_compare_tx_generation); | ||
criterion_main!(benches); |
Oops, something went wrong.