-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(prover): Add prover_cli stats command (#2362)
Adds stats commands, which provides information (batch number, when the request for proving was created and how long it took) for all L1 Batch proofs. This speeds up proving time reduction (by giving everyone visibility into current process) and can serve as further automation in the future (for instance, emit metrics, or use the tooling for automated reports).
- Loading branch information
Showing
17 changed files
with
364 additions
and
203 deletions.
There are no files selected for viewing
This file contains 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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,8 +1,9 @@ | ||
pub(crate) use status::StatusCommand; | ||
pub(crate) mod config; | ||
pub(crate) mod debug_proof; | ||
pub(crate) mod delete; | ||
pub(crate) mod get_file_info; | ||
pub(crate) mod requeue; | ||
pub(crate) mod restart; | ||
pub(crate) mod stats; | ||
pub(crate) mod status; | ||
pub(crate) use status::StatusCommand; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use anyhow::Context; | ||
use chrono::{self, NaiveTime}; | ||
use clap::{Args, ValueEnum}; | ||
use zksync_basic_types::prover_dal::ProofGenerationTime; | ||
use zksync_db_connection::connection_pool::ConnectionPool; | ||
use zksync_prover_dal::{Prover, ProverDal}; | ||
|
||
use crate::cli::ProverCLIConfig; | ||
|
||
#[derive(ValueEnum, Clone)] | ||
enum StatsPeriod { | ||
Day, | ||
Week, | ||
} | ||
|
||
#[derive(Args)] | ||
pub(crate) struct Options { | ||
#[clap( | ||
short = 'p', | ||
long = "period", | ||
help = "Specify the time frame to look for stats", | ||
default_value = "day" | ||
)] | ||
period: StatsPeriod, | ||
} | ||
|
||
pub(crate) async fn run(opts: Options, config: ProverCLIConfig) -> anyhow::Result<()> { | ||
let prover_connection_pool = ConnectionPool::<Prover>::singleton(config.db_url) | ||
.build() | ||
.await | ||
.context("failed to build a prover_connection_pool")?; | ||
let mut conn = prover_connection_pool | ||
.connection() | ||
.await | ||
.context("failed to get connection from pool")?; | ||
|
||
let start_date = match opts.period { | ||
StatsPeriod::Day => chrono::offset::Local::now().date_naive(), | ||
StatsPeriod::Week => { | ||
(chrono::offset::Local::now() - chrono::Duration::days(7)).date_naive() | ||
} | ||
}; | ||
let start_date = | ||
start_date.and_time(NaiveTime::from_num_seconds_from_midnight_opt(0, 0).unwrap()); | ||
let proof_generation_times = conn | ||
.fri_witness_generator_dal() | ||
.get_proof_generation_times_for_time_frame(start_date) | ||
.await?; | ||
display_proof_generation_time(proof_generation_times); | ||
Ok(()) | ||
} | ||
|
||
fn display_proof_generation_time(proof_generation_times: Vec<ProofGenerationTime>) { | ||
println!("Batch\tTime Taken\t\tCreated At"); | ||
for proof_generation_time in proof_generation_times { | ||
println!( | ||
"{}\t{:?}\t\t{}", | ||
proof_generation_time.l1_batch_number, | ||
proof_generation_time.time_taken, | ||
proof_generation_time.created_at | ||
); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ver_dal/.sqlx/query-081e2b928f0816c41d6645c1dedbb3402044d201e85e114ff4582394c32bd2bf.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
...ver_dal/.sqlx/query-33d6be45b246523ad76f9ae512322ff6372f63ecadb504a329499b02e7d3550e.json
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
...ver_dal/.sqlx/query-3941da180ee62a7c5d4e392ff4fe2d3a6ebb3657862b91e3ece34119f098fc2d.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
...ver_dal/.sqlx/query-8182690d0326b820d23fba49d391578db18c29cdca85b8b6aad86fe2a9bf6bbe.json
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
...ver_dal/.sqlx/query-aa91697157517322b0dbb53dca99f41220c51f58a03c61d6b7789eab0504e320.json
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
...ver_dal/.sqlx/query-abc93d27a8673b23e18d050e84c43c868c63c853edb5c4f41e48a3cc6378eca9.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.