Skip to content

Commit

Permalink
Perf: Add metrics to facilitate performance testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
anonymousGiga committed Mar 13, 2024
1 parent 2b92948 commit 59c242f
Show file tree
Hide file tree
Showing 17 changed files with 369 additions and 17 deletions.
120 changes: 110 additions & 10 deletions Cargo.lock

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

11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ reth-transaction-pool = { path = "crates/transaction-pool" }
reth-trie = { path = "crates/trie" }

# revm
revm = { version = "6.0", features = ["std", "secp256k1"], default-features = false }
revm-primitives = { version = "2.0", features = ["std"], default-features = false }
revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "ac63f06" }
revm = { git = "https://github.com/megaeth-labs/revm.git", branch = "andy/debug/make-utils-independent", features = ["std", "secp256k1"], default-features = false }
revm-primitives = { git = "https://github.com/megaeth-labs/revm.git", branch = "andy/debug/make-utils-independent", features = ["std"], default-features = false }
revm-inspectors = { git = "https://github.com/megaeth-labs/evm-inspectors.git", branch = "make-utils-independent" }

# eth
alloy-chains = { version = "0.1", feature = ["serde", "rlp", "arbitrary"] }
Expand Down Expand Up @@ -269,6 +269,9 @@ proptest-derive = "0.4"
serial_test = "3"
similar-asserts = "1.5.0"

## support perf test
perf-metrics = { git = "https://github.com/megaeth-labs/reth-perf-utils.git" }

[workspace.metadata.cargo-udeps.ignore]
# ignored because this is mutually exclusive with the optimism payload builder via feature flags
normal = ["reth-ethereum-payload-builder", "reth-node-ethereum"]
normal = ["reth-ethereum-payload-builder", "reth-node-ethereum"]
38 changes: 37 additions & 1 deletion bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ reth-node-optimism = { workspace = true, optional = true, features = [
] }
reth-node-core.workspace = true

revm = { workspace = true, optional = true}

# crypto
alloy-rlp.workspace = true
alloy-chains.workspace = true
Expand Down Expand Up @@ -88,6 +90,7 @@ reth-metrics.workspace = true
metrics.workspace = true
once_cell.workspace = true


# test vectors generation
proptest.workspace = true
rand.workspace = true
Expand Down Expand Up @@ -124,6 +127,10 @@ itertools.workspace = true
rayon.workspace = true
boyer-moore-magiclen = "0.2.16"

minstant = { version = "0.1.3", optional = true }
perf-metrics = { workspace = true, optional = true }


[target.'cfg(not(windows))'.dependencies]
jemallocator = { version = "0.5.0", optional = true }

Expand Down Expand Up @@ -168,6 +175,35 @@ optimism = [

# no-op feature flag for switching between the `optimism` and default functionality in CI matrices
ethereum = []
# support perf test
open_performance_dashboard = [
"reth-stages/open_performance_dashboard",
"perf-metrics",
]
enable_opcode_metrics = [
"perf-metrics/enable_opcode_metrics",
"reth-revm/enable_opcode_metrics",
"reth-stages/enable_opcode_metrics",
"open_performance_dashboard",
]
enable_cache_record = [
"perf-metrics/enable_cache_record",
"reth-revm/enable_cache_record",
"reth-stages/enable_cache_record",
"open_performance_dashboard",
]
enable_tps_gas_record = [
"perf-metrics/enable_tps_gas_record",
"reth-stages/enable_tps_gas_record",
"open_performance_dashboard",
]
finish_after_execution_stage = ["reth-stages/finish_after_execution_stage"]
enable_execution_duration_record = [
"perf-metrics/enable_execution_duration_record",
"reth-stages/enable_execution_duration_record",
"reth-revm/enable_execution_duration_record",
"open_performance_dashboard",
]

[[bin]]
name = "reth"
Expand All @@ -176,4 +212,4 @@ path = "src/main.rs"
[[bin]]
name = "op-reth"
path = "src/optimism.rs"
required-features = ["optimism"]
required-features = ["optimism"]
11 changes: 11 additions & 0 deletions bin/reth/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ use std::{path::PathBuf, sync::Arc};
use tokio::sync::{mpsc::unbounded_channel, oneshot};
use tracing::*;

#[cfg(feature = "open_performance_dashboard")]
use perf_metrics::dashboard::DashboardListener;

/// Re-export `NodeConfig` from `reth_node_core`.
pub use reth_node_core::node_config::NodeConfig;

Expand Down Expand Up @@ -146,6 +149,14 @@ impl<DB: Database + DatabaseMetrics + DatabaseMetadata + 'static> NodeBuilderWit

info!(target: "reth::cli", "{}", DisplayHardforks::new(self.config.chain.hardforks()));

#[cfg(feature = "open_performance_dashboard")]
{
let (dashboard_tx, dashboard_rx) = unbounded_channel();
let dashboard_listener = DashboardListener::new(dashboard_rx);
executor.spawn_critical("dashboard listener task", dashboard_listener);
perf_metrics::set_metric_event_sender(dashboard_tx);
}

let consensus = self.config.consensus();

debug!(target: "reth::cli", "Spawning stages metrics listener task");
Expand Down
3 changes: 3 additions & 0 deletions bin/reth/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ impl<Ext: RethCliExt> Cli<Ext> {
Commands::Init(command) => runner.run_blocking_until_ctrl_c(command.execute()),
Commands::Import(command) => runner.run_blocking_until_ctrl_c(command.execute()),
Commands::Db(command) => runner.run_blocking_until_ctrl_c(command.execute()),
#[cfg(not(feature = "open_performance_dashboard"))]
Commands::Stage(command) => runner.run_blocking_until_ctrl_c(command.execute()),
#[cfg(feature = "open_performance_dashboard")]
Commands::Stage(command) => runner.run_command_until_exit(|ctx| command.execute(ctx)),
Commands::P2P(command) => runner.run_until_ctrl_c(command.execute()),
Commands::TestVectors(command) => runner.run_until_ctrl_c(command.execute()),
Commands::Config(command) => runner.run_until_ctrl_c(command.execute()),
Expand Down
Loading

0 comments on commit 59c242f

Please sign in to comment.