Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into prep
Browse files Browse the repository at this point in the history
  • Loading branch information
rakita committed Dec 23, 2024
2 parents 0366c40 + e3f6a35 commit c55daba
Show file tree
Hide file tree
Showing 190 changed files with 1,701 additions and 1,478 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Benchmark

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
codspeed:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Install cargo-codspeed
uses: taiki-e/install-action@v2
with:
tool: cargo-codspeed
- name: Build the benchmark target(s)
run: cargo codspeed build --profile profiling --workspace
- name: Run the benchmarks
uses: CodSpeedHQ/action@v3
with:
run: cargo codspeed run --workspace
token: ${{ secrets.CODSPEED_TOKEN }}
50 changes: 0 additions & 50 deletions .github/workflows/cachegrind.yml

This file was deleted.

57 changes: 43 additions & 14 deletions Cargo.lock

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

23 changes: 19 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ context-interface = { path = "crates/context/interface", package = "revm-context
handler = { path = "crates/handler", package = "revm-handler", version = "1.0.0", default-features = false }
handler-interface = { path = "crates/handler/interface", package = "revm-handler-interface", version = "1.0.0", default-features = false }

# mics
# misc
cfg-if = { version = "1.0", default-features = false }
auto_impl = { version = "1.2.0" }
derive-where = { version = "1.2.7", default-features = false }
criterion = { package = "codspeed-criterion-compat", version = "2.7" }

[workspace.package]
license = "MIT"
Expand All @@ -75,9 +76,23 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[profile.release]
lto = true
codegen-units = 1
debug = true
codegen-units = 16
debug = "line-tables-only"
lto = "thin"
opt-level = 3
panic = "abort"
strip = true

# Use the `--profile profiling` flag to show symbols in release mode.
# e.g. `cargo build --profile profiling`
[profile.profiling]
debug = 2
inherits = "release"
strip = false

# Make sure debug symbols are in the bench profile
[profile.bench]
inherits = "profiling"

[profile.ethtests]
inherits = "test"
Expand Down
7 changes: 7 additions & 0 deletions bins/revme/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ thiserror = "1.0"
triehash = "0.8"
walkdir = "2.5"
k256 = { version = "0.13.3", features = ["ecdsa"] }

[dev-dependencies]
criterion.workspace = true

[[bench]]
name = "evm"
harness = false
17 changes: 17 additions & 0 deletions bins/revme/benches/evm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use criterion::{criterion_group, criterion_main, Criterion};
use revme::cmd::{
bench::{self, BenchName},
MainCmd,
};

fn evm(c: &mut Criterion) {
for &bench_name in BenchName::ALL {
let cmd = MainCmd::Bench(bench::Cmd { name: bench_name });
c.bench_function(bench_name.as_str(), |b| {
b.iter(|| cmd.run().unwrap());
});
}
}

criterion_group!(benches, evm);
criterion_main!(benches);
2 changes: 1 addition & 1 deletion bins/revme/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use clap::Parser;
pub enum MainCmd {
/// Execute Ethereum state tests.
Statetest(statetest::Cmd),
/// Execute eof validation tests.
/// Execute EOF validation tests.
EofValidation(eofvalidation::Cmd),
/// Run arbitrary EVM bytecode.
Evm(evmrunner::Cmd),
Expand Down
24 changes: 21 additions & 3 deletions bins/revme/src/cmd/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,33 @@ pub enum BenchName {
Transfer,
}

/// `bytecode` subcommand.
impl BenchName {
pub const ALL: &[BenchName] = &[
BenchName::Analysis,
BenchName::Burntpix,
BenchName::Snailtracer,
BenchName::Transfer,
];

pub fn as_str(self) -> &'static str {
match self {
BenchName::Analysis => "analysis",
BenchName::Burntpix => "burntpix",
BenchName::Snailtracer => "snailtracer",
BenchName::Transfer => "transfer",
}
}
}

/// `bytecode` subcommand
#[derive(Parser, Debug)]
pub struct Cmd {
#[arg(value_enum)]
name: BenchName,
pub name: BenchName,
}

impl Cmd {
/// Run bench command.
/// Runs bench command.
pub fn run(&self) {
match self.name {
BenchName::Analysis => analysis::run(),
Expand Down
16 changes: 2 additions & 14 deletions bins/revme/src/cmd/bench/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use revm::{
primitives::{address, bytes, hex, Bytes, TxKind},
Context, MainEvm,
};
use std::time::Instant;

const BYTES: &str = include_str!("analysis.hex");

Expand All @@ -16,23 +15,12 @@ pub fn run() {
let context = Context::builder()
.with_db(BenchmarkDB::new_bytecode(bytecode))
.modify_tx_chained(|tx| {
// execution globals block hash/gas_limit/coinbase/timestamp..
// Execution globals block hash/gas_limit/coinbase/timestamp..
tx.caller = address!("1000000000000000000000000000000000000000");
tx.transact_to = TxKind::Call(address!("0000000000000000000000000000000000000000"));
//evm.env.tx.data = Bytes::from(hex::decode("30627b7c").unwrap());
tx.data = bytes!("8035F0CE");
});
let mut evm = MainEvm::new(context, EthHandler::default());

// Just to warm up the processor.
for _ in 0..10000 {
let _ = evm.transact().unwrap();
}

let timer = Instant::now();
for _ in 0..30000 {
let _ = evm.transact().unwrap();
}
let time = timer.elapsed();
println!("Elapsed time: {:?}", time);
let _ = evm.transact().unwrap();
}
Loading

0 comments on commit c55daba

Please sign in to comment.