Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 19 additions & 1 deletion Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ members = [
"svm-feature-set",
"svm-log-collector",
"svm-measure",
"svm-metrics",
"svm-timings",
"svm-transaction",
"svm-type-overrides",
Expand Down Expand Up @@ -525,6 +526,7 @@ solana-svm-callback = { path = "svm-callback", version = "=3.0.0" }
solana-svm-feature-set = { path = "svm-feature-set", version = "=3.0.0" }
solana-svm-log-collector = { path = "svm-log-collector", version = "=3.0.0" }
solana-svm-measure = { path = "svm-measure", version = "=3.0.0" }
solana-svm-metrics = { path = "svm-metrics", version = "=3.0.0" }
solana-svm-timings = { path = "svm-timings", version = "=3.0.0" }
solana-svm-transaction = { path = "svm-transaction", version = "=3.0.0" }
solana-svm-type-overrides = { path = "svm-type-overrides", version = "=3.0.0" }
Expand Down
4 changes: 2 additions & 2 deletions program-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ name = "solana_program_runtime"
dev-context-only-utils = []
dummy-for-ci-check = ["metrics"]
frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro"]
metrics = ["dep:solana-metrics"]
metrics = ["dep:solana-svm-metrics"]
shuttle-test = ["solana-sbpf/shuttle-test", "solana-svm-type-overrides/shuttle-test"]

[dependencies]
Expand All @@ -45,7 +45,6 @@ solana-frozen-abi-macro = { workspace = true, optional = true, features = [
solana-hash = { workspace = true }
solana-instruction = { workspace = true }
solana-last-restart-slot = { workspace = true }
solana-metrics = { workspace = true, optional = true }
solana-program-entrypoint = { workspace = true }
solana-pubkey = { workspace = true }
solana-rent = { workspace = true }
Expand All @@ -56,6 +55,7 @@ solana-svm-callback = { workspace = true }
solana-svm-feature-set = { workspace = true }
solana-svm-log-collector = { workspace = true }
solana-svm-measure = { workspace = true }
solana-svm-metrics = { workspace = true, optional = true }
solana-svm-timings = { workspace = true }
solana-svm-transaction = { workspace = true }
solana-svm-type-overrides = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion program-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#[cfg(feature = "metrics")]
#[macro_use]
extern crate solana_metrics;
extern crate solana_svm_metrics;

pub use solana_sbpf;
pub mod execution_budget;
Expand Down
16 changes: 15 additions & 1 deletion programs/sbf/Cargo.lock

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

36 changes: 36 additions & 0 deletions svm-metrics/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[package]
name = "solana-svm-metrics"
description = "Metrics collection for SVM"
documentation = "https://docs.rs/solana-svm-metrics"
version = { workspace = true }
authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
edition = { workspace = true }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[lib]
name = "solana_svm_metrics"

[dependencies]
crossbeam-channel = { workspace = true }
gethostname = { workspace = true }
log = { workspace = true }
reqwest = { workspace = true, features = ["blocking", "brotli", "deflate", "gzip", "rustls-tls", "json"] }
solana-cluster-type = { workspace = true }
solana-sha256-hasher = { workspace = true }
solana-time-utils = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
bencher = { workspace = true }
env_logger = { workspace = true }
rand = { workspace = true }
serial_test = { workspace = true }

[[bench]]
name = "metrics"
harness = false
92 changes: 92 additions & 0 deletions svm-metrics/benches/metrics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
use {
bencher::{benchmark_group, benchmark_main, Bencher},
log::*,
rand::distributions::{Distribution, Uniform},
solana_svm_metrics::{
counter::CounterPoint,
datapoint::DataPoint,
metrics::{serialize_points, test_mocks::MockMetricsWriter, MetricsAgent},
},
std::{hint::black_box, sync::Arc, time::Duration},
};

fn bench_write_points(b: &mut Bencher) {
let points = (0..10)
.map(|_| {
DataPoint::new("measurement")
.add_field_i64("i", 0)
.add_field_i64("abc123", 2)
.add_field_i64("this-is-my-very-long-field-name", 3)
.clone()
})
.collect();
let host_id = "benchmark-host-id";
b.iter(|| {
for _ in 0..10 {
black_box(serialize_points(&points, host_id));
}
})
}

fn bench_datapoint_submission(b: &mut Bencher) {
let writer = Arc::new(MockMetricsWriter::new());
let agent = MetricsAgent::new(writer, Duration::from_secs(10), 1000);

b.iter(|| {
for i in 0..1000 {
agent.submit(
DataPoint::new("measurement")
.add_field_i64("i", i)
.to_owned(),
Level::Info,
);
}
agent.flush();
})
}

fn bench_counter_submission(b: &mut Bencher) {
let writer = Arc::new(MockMetricsWriter::new());
let agent = MetricsAgent::new(writer, Duration::from_secs(10), 1000);

b.iter(|| {
for i in 0..1000 {
agent.submit_counter(CounterPoint::new("counter 1"), Level::Info, i);
}
agent.flush();
})
}

fn bench_random_submission(b: &mut Bencher) {
let writer = Arc::new(MockMetricsWriter::new());
let agent = MetricsAgent::new(writer, Duration::from_secs(10), 1000);
let mut rng = rand::thread_rng();
let die = Uniform::<i32>::from(1..7);

b.iter(|| {
for i in 0..1000 {
let dice = die.sample(&mut rng);

if dice == 6 {
agent.submit_counter(CounterPoint::new("counter 1"), Level::Info, i);
} else {
agent.submit(
DataPoint::new("measurement")
.add_field_i64("i", i as i64)
.to_owned(),
Level::Info,
);
}
}
agent.flush();
})
}

benchmark_group!(
benches,
bench_write_points,
bench_datapoint_submission,
bench_counter_submission,
bench_random_submission
);
benchmark_main!(benches);
Loading
Loading