Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add memory performance tests #439

Merged
merged 17 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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
161 changes: 154 additions & 7 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ keywords = ["starknet", "cairo", "testnet", "local", "server"]


[workspace.dependencies]

# axum
axum = { version = "0.5" }
hyper = "0.14.12"
Expand Down Expand Up @@ -107,3 +108,6 @@ lazy_static = { version = "1.4.0" }
ethers = { version = "2.0.11" }

openssl = { version = "0.10", features = ["vendored"] }

hhamud marked this conversation as resolved.
Show resolved Hide resolved


13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,19 @@ The previous command might cause your testing to die along the way due to memory
$ cargo test --jobs <N>
```

### Bench execution
To run the benchmarks and generate a performance report:

```
$ cargo bench
```

This command will compile the benchmarks and run them using all available CPUs on your machine. Criterion will perform multiple iterations of each benchmark to collect performance data and generate statistical analysis.

Check the report created at `target/criterion/report/index.html`
FabijanC marked this conversation as resolved.
Show resolved Hide resolved

Criterion is highly configurable and offers various options to customise the benchmarking process. You can find more information about Criterion and its features in the [Criterion documentation](https://bheisler.github.io/criterion.rs/book/index.html).

### Development - Docker

Due to internal needs, images with arch suffix are built and pushed to Docker Hub, but this is not mentioned in the user docs as users should NOT be needing it.
Expand Down
8 changes: 8 additions & 0 deletions crates/starknet-devnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,11 @@ starknet-rs-core = { workspace = true }
starknet-rs-accounts = { workspace = true }
hyper = { workspace = true }
usc = { workspace = true }
criterion = { version = "0.3.4", features = ["async_tokio"] }
peak_alloc = "0.2.0"


[[bench]]
name = "mint_bench"
harness = false
path = "benches/mint_bench.rs"
32 changes: 32 additions & 0 deletions crates/starknet-devnet/benches/mint_bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use crate::common::background_devnet::BackgroundDevnet;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use tokio::runtime::Runtime;

#[path = "../tests/common/mod.rs"]
pub mod common;

static DUMMY_ADDRESS: u128 = 1;
static DUMMY_AMOUNT: u128 = 1;

async fn mint_iter(f: &str) {
hhamud marked this conversation as resolved.
Show resolved Hide resolved
let devnet = BackgroundDevnet::spawn_with_additional_args(&["--state-archive-capacity", f])
FabijanC marked this conversation as resolved.
Show resolved Hide resolved
.await
.expect("Could not start Devnet");

for _n in 1..=5000 {
devnet.mint(DUMMY_ADDRESS, DUMMY_AMOUNT).await;
}
}

fn bench_memory(c: &mut Criterion) {
let rt = Runtime::new().unwrap();
let mut group = c.benchmark_group("Mint");
group.significance_level(0.1).sample_size(10);
FabijanC marked this conversation as resolved.
Show resolved Hide resolved
group.bench_function("full", |b| b.to_async(&rt).iter(|| black_box(mint_iter("full"))));
group.bench_function("none", |b| b.to_async(&rt).iter(|| black_box(mint_iter("none"))));
hhamud marked this conversation as resolved.
Show resolved Hide resolved

group.finish();
}

criterion_group!(benches, bench_memory);
criterion_main!(benches);
4 changes: 3 additions & 1 deletion crates/starknet-devnet/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ pub(crate) struct Args {
#[arg(long = "account-class-custom")]
#[arg(value_name = "PATH")]
#[arg(conflicts_with = "account_class_choice")]
#[arg(help = "Specify the path to a Cairo Sierra artifact to be used by predeployed accounts;")]
#[arg(
help = "Specify the path to a Cairo Sierra artifact to be used by predeployed accounts;"
)]
account_class_custom: Option<AccountClassWrapper>,

/// Initial balance of predeployed accounts
Expand Down
Loading