Skip to content

Commit

Permalink
feat: Integrate lurk-metrics package into project workspace (PoC)
Browse files Browse the repository at this point in the history
- Added `lurk-metrics` package to the project and updated `metrics` package to version `0.21.1` in workspace
- Modified `lurk-metrics` project to use workspace `metrics` dependency instead of previous external version
- Integrated `lurk_metrics::MetricsSink` initialization into the main function, displaying metrics in the log.
  • Loading branch information
huitseeker committed Jul 27, 2023
1 parent 2e372ed commit 8d8b3b9
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 18 deletions.
21 changes: 15 additions & 6 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ indexmap = { version = "1.9.3", features = ["rayon"] }
itertools = "0.9"
log = { workspace = true }
lurk-macros = { path = "lurk-macros" }
lurk-metrics = { path = "lurk-metrics" }
metrics = { workspace = true }
neptune = { workspace = true, features = ["arity2","arity4","arity8","arity16","pasta","bls"] }
nom = "7.1.3"
nom_locate = "4.1.0"
Expand Down Expand Up @@ -105,6 +107,7 @@ blstrs = "0.7.0"
clap = "4.3.17"
ff = "0.13"
log = "0.4.19"
metrics = "0.21.1"
neptune = { version = "10.0.0" }
nova = { package = "nova-snark", version = "0.22", default-features = false }
once_cell = "1.18.0"
Expand Down
2 changes: 1 addition & 1 deletion lurk-metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description = "Metrics Sink for lurk"
repository = "https://github.com/lurk-lab/lurk-rs"

[dependencies]
metrics = "0.18"
metrics = { workspace = true }
once_cell = { workspace = true }
log = { workspace = true }
hdrhistogram = { version = "7.5.2", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion lurk-metrics/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub enum MetricType {
pub enum Metric {
Counter(ValueAndCount<u64>),
Gauge(ValueAndCount<f64>),
// We currently have a fixed scaling configuration for histograms that is tuned for
// Fixed scaling configuration for histograms, tuned for
// microsecond-scale latency timers. It saturates at 60 seconds.
Histogram(hdrhistogram::Histogram<u64>),
}
Expand Down
29 changes: 19 additions & 10 deletions src/eval/reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ fn reduce_with_witness_inner<F: LurkField, C: Coprocessor<F>>(
c: &NamedConstants<F>,
lang: &Lang<F, C>,
) -> Result<(Control<F>, Option<Ptr<F>>), ReductionError> {
// sanity-check: this should return the number of iterations
// of the last 5s of computation
metrics::counter!("evaluation", 1, "type" => "step");
let mut closure_to_extend = None;

Ok((
Expand Down Expand Up @@ -105,6 +108,8 @@ fn reduce_with_witness_inner<F: LurkField, C: Coprocessor<F>>(
// CIRCUIT: sym_is_self_evaluating
Control::ApplyContinuation(expr, env, cont)
} else {
// Register a symbol lookup
metrics::counter!("evaluation", 1, "type" => "sym lookup step");
// Otherwise, look for a matching binding in env.

// CIRCUIT: sym_otherwise
Expand Down Expand Up @@ -161,6 +166,7 @@ fn reduce_with_witness_inner<F: LurkField, C: Coprocessor<F>>(

// CIRCUIT: with_sym_binding_unmatched_new_lookup
{
metrics::counter!("evaluation", 1, "type" => "push lookup continuation");
Control::Return(
expr,
smaller_env,
Expand Down Expand Up @@ -1190,16 +1196,19 @@ fn apply_continuation<F: LurkField>(
}
_ => unreachable!(),
},
ContTag::Lookup => match cont_witness
.fetch_named_cont(ContName::ApplyContinuation, store, &cont)
.ok_or_else(|| store::Error("Fetch failed".into()))?
{
Continuation::Lookup {
saved_env,
continuation,
} => Control::MakeThunk(result, saved_env, continuation),
_ => unreachable!(),
},
ContTag::Lookup => {
metrics::counter!("evaluation", 1, "type" => "pop lookup continuation");
match cont_witness
.fetch_named_cont(ContName::ApplyContinuation, store, &cont)
.ok_or_else(|| store::Error("Fetch failed".into()))?
{
Continuation::Lookup {
saved_env,
continuation,
} => Control::MakeThunk(result, saved_env, continuation),
_ => unreachable!(),
}
}
ContTag::Tail => match cont_witness
.fetch_named_cont(ContName::ApplyContinuation, store, &cont)
.ok_or_else(|| store::Error("Fetch failed".into()))?
Expand Down
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ mod cli;
use anyhow::Result;

fn main() -> Result<()> {
// this handle should be held until the end of the program,
// do not replace by let _ = ...
let _metrics_handle = lurk_metrics::MetricsSink::init();
pretty_env_logger::init();
cli::parse_and_run()
}

0 comments on commit 8d8b3b9

Please sign in to comment.