Skip to content

Commit

Permalink
ci(bench): add exec l1 block bench (rooch-network#1535)
Browse files Browse the repository at this point in the history
* ci(bench): add l1 block tx bench

1. add l1 block tx bench
2. add data import mode for bindingtest
  • Loading branch information
popcnt1 authored Apr 8, 2024
1 parent 8d85e68 commit b49d069
Show file tree
Hide file tree
Showing 14 changed files with 224 additions and 101 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,10 @@ base64 = "0.21.3"
wasmer = "4.2.5"
ciborium = "0.2.1"
pprof = { version = "0.13.0", features = ["flamegraph", "criterion", "cpp", "frame-pointer", "protobuf-codec"] }



celestia-rpc = { git = "https://github.com/eigerco/celestia-node-rs.git", rev = "129272e8d926b4c7badf27a26dea915323dd6489" }
celestia-types = { git = "https://github.com/eigerco/celestia-node-rs.git", rev = "129272e8d926b4c7badf27a26dea915323dd6489" }

opendal = "0.44.1"
bitcoincore-rpc-json = "0.18.0"

# Note: the BEGIN and END comments below are required for external tooling. Do not remove.
# BEGIN MOVE DEPENDENCIES
Expand Down
8 changes: 6 additions & 2 deletions crates/rooch-benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ log = { workspace = true }
lazy_static = { workspace = true }
rpassword = { workspace = true }
tempfile = { workspace = true }

criterion = { workspace = true }
#criterion-cpu-time = { workspace = true }
pprof = { workspace = true, features = ["flamegraph", "criterion", "cpp", "frame-pointer", "protobuf-codec"] }
parking_lot = { workspace = true }
proptest = { workspace = true }
rand_core = { default-features = false, workspace = true }
bitcoincore-rpc-json = { workspace = true }
bitcoin = { workspace = true }

move-core-types = { workspace = true }
move-resource-viewer = { workspace = true }
Expand Down Expand Up @@ -91,6 +91,10 @@ name = "bench_tx_sequence"
harness = false
name = "bench_tx_exec"

[[bench]]
harness = false
name = "bench_tx_exec_blk"

[[bench]]
harness = false
name = "bench_tx_query"
Expand Down
42 changes: 2 additions & 40 deletions crates/rooch-benchmarks/benches/bench_tx_exec.rs
Original file line number Diff line number Diff line change
@@ -1,47 +1,9 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{criterion_group, criterion_main};
use rooch_benchmarks::helper::profiled;
use rooch_benchmarks::tx::TxType::{Blog, Empty, Transfer};
use rooch_benchmarks::tx::{create_publish_transaction, create_transaction, TX_TYPE};
use rooch_framework_tests::binding_test;
use rooch_key::keystore::account_keystore::AccountKeystore;
use rooch_key::keystore::memory_keystore::InMemKeystore;
use rooch_test_transaction_builder::TestTransactionBuilder;

pub fn tx_exec_benchmark(c: &mut Criterion) {
let mut binding_test = binding_test::RustBindingTest::new().unwrap();
let keystore = InMemKeystore::new_insecure_for_tests(10);

let default_account = keystore.addresses()[0];
let mut test_transaction_builder = TestTransactionBuilder::new(default_account.into());
let mut tx_cnt = 300;
if *TX_TYPE == Blog {
let tx = create_publish_transaction(&test_transaction_builder, &keystore).unwrap();
binding_test.execute(tx).unwrap();
}
if *TX_TYPE == Transfer {
tx_cnt = 500;
}
if *TX_TYPE == Empty {
tx_cnt = 1000;
}
let transactions: Vec<_> = (0..tx_cnt)
.map(|n| {
let tx = create_transaction(&mut test_transaction_builder, &keystore, n).unwrap();
binding_test.executor.validate_l2_tx(tx.clone()).unwrap()
})
.collect();
let mut transactions_iter = transactions.into_iter().cycle();

c.bench_function("tx_exec", |b| {
b.iter(|| {
let tx = transactions_iter.next().unwrap();
binding_test.execute_verified_tx(tx.clone()).unwrap()
});
});
}
use rooch_benchmarks::tx::tx_exec_benchmark;

criterion_group! {
name = tx_exec_bench;
Expand Down
15 changes: 15 additions & 0 deletions crates/rooch-benchmarks/benches/bench_tx_exec_blk.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use criterion::{criterion_group, criterion_main};

use rooch_benchmarks::helper::profiled;
use rooch_benchmarks::tx::tx_exec_benchmark;

criterion_group! {
name = tx_exec_blk_bench;
config = profiled(None).measurement_time(std::time::Duration::from_secs(2));
targets = tx_exec_benchmark
}

criterion_main!(tx_exec_blk_bench);
4 changes: 2 additions & 2 deletions crates/rooch-benchmarks/benches/bench_tx_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use criterion::{criterion_group, criterion_main, Criterion};
use moveos_config::temp_dir;
use rooch_benchmarks::tx::{create_publish_transaction, create_transaction, setup_service};
use rooch_benchmarks::tx::{create_l2_tx, create_publish_transaction, setup_service};
use rooch_key::keystore::account_keystore::AccountKeystore;
use rooch_key::keystore::memory_keystore::InMemKeystore;
use rooch_rpc_api::api::rooch_api::RoochAPIServer;
Expand All @@ -28,7 +28,7 @@ pub fn transaction_query_benchmark(c: &mut Criterion) {
let _publish_result = rt.block_on(async { rpc_service.execute_tx(tx).await.unwrap() });
//
for n in 1..500 {
let tx = create_transaction(&mut test_transaction_builder, &keystore, n).unwrap();
let tx = create_l2_tx(&mut test_transaction_builder, &keystore, n).unwrap();
let _ = rt.block_on(async { rpc_service.execute_tx(tx).await.unwrap() });
}

Expand Down
11 changes: 8 additions & 3 deletions crates/rooch-benchmarks/benches/bench_tx_sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

use criterion::{criterion_group, criterion_main, Criterion};
use rooch_benchmarks::helper::profiled;
use rooch_benchmarks::tx::{create_transaction, gen_sequencer};
use rooch_benchmarks::tx::{create_l2_tx, gen_sequencer};
use rooch_framework_tests::binding_test;
use rooch_key::keystore::account_keystore::AccountKeystore;
use rooch_key::keystore::memory_keystore::InMemKeystore;
use rooch_test_transaction_builder::TestTransactionBuilder;
use rooch_types::transaction::LedgerTxData;
use std::time::Duration;

pub fn tx_sequence_benchmark(c: &mut Criterion) {
let mut binding_test = binding_test::RustBindingTest::new().unwrap();
Expand All @@ -25,7 +27,10 @@ pub fn tx_sequence_benchmark(c: &mut Criterion) {
let mut test_transaction_builder = TestTransactionBuilder::new(rooch_account.into());
let tx_cnt = 100;
let transactions: Vec<_> = (0..tx_cnt)
.map(|n| create_transaction(&mut test_transaction_builder, &keystore, n).unwrap())
.map(|n| {
let tx = create_l2_tx(&mut test_transaction_builder, &keystore, n).unwrap();
LedgerTxData::L2Tx(tx.clone())
})
.collect();
let mut transactions_iter = transactions.into_iter().cycle();

Expand All @@ -39,7 +44,7 @@ pub fn tx_sequence_benchmark(c: &mut Criterion) {

criterion_group! {
name = tx_sequence_bench;
config = profiled(None);
config = profiled(None).measurement_time(Duration::from_millis(500));
targets = tx_sequence_benchmark
}

Expand Down
7 changes: 4 additions & 3 deletions crates/rooch-benchmarks/benches/bench_tx_validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
use criterion::{criterion_group, criterion_main, Criterion};
use rooch_benchmarks::helper::profiled;
use rooch_benchmarks::tx::TxType::{Blog, Empty, Transfer};
use rooch_benchmarks::tx::{create_publish_transaction, create_transaction, TX_TYPE};
use rooch_benchmarks::tx::{create_l2_tx, create_publish_transaction, TX_TYPE};
use rooch_framework_tests::binding_test;
use rooch_key::keystore::account_keystore::AccountKeystore;
use rooch_key::keystore::memory_keystore::InMemKeystore;
use rooch_test_transaction_builder::TestTransactionBuilder;
use std::time::Duration;

pub fn tx_validate_benchmark(c: &mut Criterion) {
let mut binding_test = binding_test::RustBindingTest::new().unwrap();
Expand All @@ -29,7 +30,7 @@ pub fn tx_validate_benchmark(c: &mut Criterion) {
tx_cnt = 1000;
}
let transactions: Vec<_> = (0..tx_cnt)
.map(|n| create_transaction(&mut test_transaction_builder, &keystore, n).unwrap())
.map(|n| create_l2_tx(&mut test_transaction_builder, &keystore, n).unwrap())
.collect();
let mut transactions_iter = transactions.into_iter().cycle();

Expand All @@ -43,7 +44,7 @@ pub fn tx_validate_benchmark(c: &mut Criterion) {

criterion_group! {
name = tx_validate_bench;
config = profiled(None);
config = profiled(None).measurement_time(Duration::from_millis(500));
targets = tx_validate_benchmark
}

Expand Down
4 changes: 2 additions & 2 deletions crates/rooch-benchmarks/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ impl Default for ProfileConfig {
fn default() -> Self {
Self {
sample_size: 10,
warm_up_time: Duration::from_millis(10),
warm_up_time: Duration::from_millis(1), // no need to warm this heavy operation
frequency: 2000,
measurement_time: Duration::from_millis(500),
measurement_time: Duration::from_millis(2000),
}
}
}
Expand Down
Loading

0 comments on commit b49d069

Please sign in to comment.