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

More benchmarks in stylus_benchmark #2870

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
ad0160d
Adds CI step to check if stylus_benchmark can be built
diegoximenes Dec 27, 2024
962d0b6
Renames exec_program to launch_program_thread
diegoximenes Dec 27, 2024
8d0c6cb
stylus_benchmark: Prints available scenarios in help
diegoximenes Jan 6, 2025
ed480a0
Prints ink per nano second instead of micro second
diegoximenes Jan 6, 2025
c6f0ec8
CallIndirect benchmark
diegoximenes Jan 6, 2025
6f71e92
ScenarioWatGenerator trait
diegoximenes Jan 7, 2025
d6a92ad
If scenario
diegoximenes Jan 7, 2025
84839ef
Fix: removes start_benchmark inside loop
diegoximenes Jan 7, 2025
5ea72c0
GlobalGet
diegoximenes Jan 7, 2025
8c10174
add_i32 -> i32_add, xor_i32 -> i32_xor
diegoximenes Jan 7, 2025
b47fc57
GlobalSet
diegoximenes Jan 7, 2025
78efd18
Call
diegoximenes Jan 7, 2025
7f24562
Select
diegoximenes Jan 7, 2025
4f797c1
I32Eqz
diegoximenes Jan 7, 2025
fb4fcf0
I32Eq
diegoximenes Jan 7, 2025
7bc887b
I32Ne
diegoximenes Jan 7, 2025
6e0758e
i32_lt_s
diegoximenes Jan 7, 2025
c6e2b0f
i32_lt_u
diegoximenes Jan 7, 2025
5f2b8c8
stylus_benchmark: i32_gt_s
diegoximenes Jan 7, 2025
4546807
stylus_benchmark: i32_gt_u
diegoximenes Jan 7, 2025
f802dbe
stylus_benchmark: i32_le_s
diegoximenes Jan 7, 2025
b744806
stylus_benchmark: i32_le_u
diegoximenes Jan 7, 2025
ec72c2a
stylus_benchmark: i32.ge_s
diegoximenes Jan 7, 2025
6c0ed57
stylus_benchmark: i32.ge_u
diegoximenes Jan 7, 2025
0e440c5
stylus_benchmark: i32.clz
diegoximenes Jan 7, 2025
4ab50eb
stylus_benchmark: i32.ctz
diegoximenes Jan 7, 2025
2f95a47
stylus_benchmark: i32.popcnt
diegoximenes Jan 8, 2025
badbb5b
stylus_benchmark: i32.sub
diegoximenes Jan 8, 2025
92f8756
stylus_benchmark: i32.mul
diegoximenes Jan 8, 2025
535a2f5
stylus_benchmark: i32.div_s
diegoximenes Jan 8, 2025
c602d73
stylus_benchmark: i32.div_u
diegoximenes Jan 8, 2025
5088d6e
stylus_benchmark: i32.rem_s
diegoximenes Jan 8, 2025
a06b854
stylus_benchmark: i32.rem_u
diegoximenes Jan 8, 2025
9264823
stylus_benchmark: i32.and
diegoximenes Jan 8, 2025
eeb1aaf
stylus_benchmark: i32.or
diegoximenes Jan 8, 2025
929ad07
stylus_benchmark: i32.shl
diegoximenes Jan 8, 2025
559f083
stylus_benchmark: i32.shr_s
diegoximenes Jan 8, 2025
f43c579
stylus_benchmark: i32.shr_u
diegoximenes Jan 8, 2025
6f9a9f3
stylus_benchmark: i32.rotl
diegoximenes Jan 8, 2025
05c4288
stylus_benchmark: i32.rotr
diegoximenes Jan 8, 2025
7bfc31a
stylus_benchmark: i32.wrap_i64
diegoximenes Jan 8, 2025
b0a8e38
instruction_with_2_args_1_return
diegoximenes Jan 8, 2025
b122e70
instruction_with_1_arg_1_return
diegoximenes Jan 8, 2025
fbecd0f
Adds DataType to intruction_with_1_arg_1_return
diegoximenes Jan 8, 2025
134c64a
Adds DataType to intruction_with_2_args_1_return
diegoximenes Jan 8, 2025
f19ddc5
stylus_benchmark: generate random values
diegoximenes Jan 9, 2025
9413683
stylus_benchmark: local.get
diegoximenes Jan 9, 2025
a0aeffe
stylus_benchmark: local.set
diegoximenes Jan 9, 2025
bedf6d8
stylus_benchmark: local.tee
diegoximenes Jan 9, 2025
86a6b25
Removes unused fn
diegoximenes Jan 9, 2025
d418958
convert mod instead of i32_wrap_i64 mod
diegoximenes Jan 9, 2025
71c2ec8
stylus_benchmark: i64.extend_i32_s
diegoximenes Jan 9, 2025
67ff063
stylus_benchmark: i64.extend_i32_u
diegoximenes Jan 9, 2025
bd59692
stylus_benchmark: i32.load
diegoximenes Jan 9, 2025
43ab532
stylus_benchmark: i32.store
diegoximenes Jan 9, 2025
309e79c
stylus_benchmark: I64 ops
diegoximenes Jan 9, 2025
20c7d4a
Uses local instead of global for ops_counter
diegoximenes Jan 9, 2025
02f9249
stylus_benchmark: br
diegoximenes Jan 10, 2025
7298af4
stylus_benchmark: br_if
diegoximenes Jan 10, 2025
8ec1f56
stylus_benchmark: br_table
diegoximenes Jan 10, 2025
751d623
Updates date in copyright
diegoximenes Jan 10, 2025
4fe605b
Fix load
diegoximenes Jan 10, 2025
2cae13b
Fix store
diegoximenes Jan 10, 2025
d6f01ff
Fix fmt
diegoximenes Jan 10, 2025
d328ed4
ops_counter as global again
diegoximenes Jan 10, 2025
3cd6b0a
Update comments related to branch instructions
diegoximenes Jan 10, 2025
8d25910
Fix br_table
diegoximenes Jan 10, 2025
fe323f6
Fixes data_type.gen
diegoximenes Jan 10, 2025
aef94dc
Generates number in local.set
diegoximenes Jan 10, 2025
fb1e838
Fixes select
diegoximenes Jan 10, 2025
34ef4c2
Uses catch all in match
diegoximenes Jan 10, 2025
35ae6f3
Fixes data_type.gen
diegoximenes Jan 10, 2025
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
3 changes: 3 additions & 0 deletions .github/workflows/arbitrator-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ jobs:
- name: Run rust tests
run: cargo test -p arbutil -p prover -p jit -p stylus --release --manifest-path arbitrator/prover/Cargo.toml

- name: Check stylus_bechmark
run: cargo check --manifest-path arbitrator/tools/stylus_benchmark/Cargo.toml

- name: Rustfmt
run: cargo fmt -p arbutil -p prover -p jit -p stylus --manifest-path arbitrator/Cargo.toml -- --check

Expand Down
4 changes: 2 additions & 2 deletions arbitrator/jit/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ pub fn new_program(
)));
};

exec_program(exec, module, calldata, config, evm_data, gas)
launch_program_thread(exec, module, calldata, config, evm_data, gas)
}

pub fn exec_program(
pub fn launch_program_thread(
exec: &mut WasmEnv,
module: Arc<[u8]>,
calldata: Vec<u8>,
Expand Down
13 changes: 7 additions & 6 deletions arbitrator/tools/stylus_benchmark/Cargo.lock

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

1 change: 1 addition & 0 deletions arbitrator/tools/stylus_benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ stylus = { path = "../../stylus/", default-features = false }
clap = { version = "4.4.8", features = ["derive"] }
strum = "0.26"
strum_macros = "0.26"
rand = "0.8.5"
10 changes: 5 additions & 5 deletions arbitrator/tools/stylus_benchmark/src/benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021-2024, Offchain Labs, Inc.
// Copyright 2021-2025, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE

use arbutil::evm::{api::Ink, EvmData};
Expand Down Expand Up @@ -45,7 +45,7 @@ fn run(compiled_module: Vec<u8>) -> (Duration, Ink) {

let exec = &mut WasmEnv::default();

let module = jit::program::exec_program(
let module = jit::program::launch_program_thread(
exec,
compiled_module.into(),
calldata,
Expand Down Expand Up @@ -94,11 +94,11 @@ pub fn benchmark(wat: Vec<u8>) -> eyre::Result<()> {
durations = durations[l..r].to_vec();

let avg_duration = durations.iter().sum::<Duration>() / (r - l) as u32;
let avg_ink_spent_per_micro_second = ink_spent.0 / avg_duration.as_micros() as u64;
let avg_ink_spent_per_nano_second = ink_spent.0 / avg_duration.as_nanos() as u64;
println!("After discarding top and bottom runs: ");
println!(
"avg_duration: {:?}, avg_ink_spent_per_micro_second: {:?}",
avg_duration, avg_ink_spent_per_micro_second
"avg_duration: {:?}, avg_ink_spent_per_nano_second: {:?}",
avg_duration, avg_ink_spent_per_nano_second
);

Ok(())
Expand Down
12 changes: 6 additions & 6 deletions arbitrator/tools/stylus_benchmark/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright 2021-2024, Offchain Labs, Inc.
// Copyright 2021-2025, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE

mod benchmark;
mod scenario;
mod scenarios;

use clap::Parser;
use clap::{Parser, ValueEnum};
use scenario::Scenario;
use std::path::PathBuf;
use strum::IntoEnumIterator;

#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
Expand All @@ -20,7 +20,7 @@ struct Args {
}

fn handle_scenario(scenario: Scenario, output_wat_dir_path: Option<PathBuf>) -> eyre::Result<()> {
println!("Benchmarking {}", scenario);
println!("Benchmarking {:?}", scenario);
let wat = scenario::generate_wat(scenario, output_wat_dir_path);
benchmark::benchmark(wat)
}
Expand All @@ -32,8 +32,8 @@ fn main() -> eyre::Result<()> {
Some(scenario) => handle_scenario(scenario, args.output_wat_dir_path),
None => {
println!("No scenario specified, benchmarking all scenarios\n");
for scenario in Scenario::iter() {
let benchmark_result = handle_scenario(scenario, args.output_wat_dir_path.clone());
for scenario in Scenario::value_variants() {
let benchmark_result = handle_scenario(*scenario, args.output_wat_dir_path.clone());
if let Err(err) = benchmark_result {
return Err(err);
}
Expand Down
Loading
Loading