-
Notifications
You must be signed in to change notification settings - Fork 175
Add fulfillment duration metric for network sp1 #2774
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,68 @@ | ||
| //! Defines utilities for collecting runtime metrics from inside a SP1 VM | ||
| use std::io::Write; | ||
|
|
||
| use sov_metrics::Metric; | ||
|
|
||
| #[cfg(feature = "bench")] | ||
| use sp1_sdk::HookEnv; | ||
|
|
||
| /// A custom callback for extracting metrics from the SP1 zkvm. | ||
| /// | ||
| /// When the "bench" feature is enabled, this callback is registered as a syscall | ||
| /// in the SP1 VM and invoked whenever a function annotated with the `cycle_tracker` | ||
| /// macro is invoked. | ||
| #[cfg(feature = "bench")] | ||
| pub fn metrics_hook(_env: HookEnv, buf: &[u8]) -> Vec<Vec<u8>> { | ||
| let _ = sov_metrics::cycle_utils::deserialize_metrics_call(buf).unwrap(); | ||
|
|
||
| vec![] | ||
| } | ||
|
|
||
| /// The type of SP1 prover that generated a proof. | ||
| #[derive(Debug)] | ||
| #[allow(dead_code)] | ||
| pub(crate) enum ProverType { | ||
| /// Local CPU prover. | ||
| Cpu, | ||
| /// Succinct proving network. | ||
| Network, | ||
| } | ||
|
|
||
| impl ProverType { | ||
| /// Returns the string representation for use in metrics serialization. | ||
| pub fn as_str(&self) -> &'static str { | ||
| match self { | ||
| ProverType::Cpu => "cpu", | ||
| ProverType::Network => "network", | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Metrics emitted when the SP1 proving network fulfills a proof request. | ||
| #[derive(Debug)] | ||
| pub(crate) struct SP1ProofFulfillmentMetrics { | ||
| /// The type of prover emitting the metric. | ||
| pub prover_type: ProverType, | ||
| /// The hex-encoded proof request ID. | ||
| pub request_id: String, | ||
| /// Time from proof request creation to fulfillment, in seconds, as reported by the SP1 | ||
| /// network. | ||
| pub fulfillment_duration_secs: u64, | ||
| } | ||
|
|
||
| impl Metric for SP1ProofFulfillmentMetrics { | ||
| fn measurement_name(&self) -> &'static str { | ||
| "sov_rollup_sp1_proof_fulfillment" | ||
| } | ||
|
|
||
| fn serialize_for_telegraf(&self, buffer: &mut Vec<u8>) -> std::io::Result<()> { | ||
| write!( | ||
| buffer, | ||
| "{},prover_type={} request_id=\"{}\",fulfillment_duration_secs={}i", | ||
| self.measurement_name(), | ||
| self.prover_type.as_str(), | ||
| self.request_id, | ||
| self.fulfillment_duration_secs, | ||
| ) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.