Skip to content
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

feat(prover): improve precision for prover timings in database #2418

Closed
wants to merge 3 commits into from

Conversation

antoniolocascio
Copy link
Collaborator

What ❔

This PR introduces two changes to the prover database:

  • time_taken for provers (in prover_jobs_fri) now is stored with millisecond precision. Note that the type of the column doesn't need to change, so no migration is needed.
  • The column time_taken_wvg is added to prover_jovs_fri to store the time taken by the WVG.

Why ❔

These two changes are useful to measure the fine-grain performance of the prover, without needing to parse logs.

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • Code has been formatted via zk fmt and zk lint.

@antoniolocascio antoniolocascio force-pushed the alocascio@wvg_time_taken branch 3 times, most recently from 66c24c3 to 8d2e87a Compare July 10, 2024 11:36
Copy link
Contributor

@EmilLuta EmilLuta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to rebase these changes and fix conflicts. Sorry for the delay. Note that @popzxc will work on the tracing area which will most likely change how these times are computed.

@@ -101,7 +102,7 @@ pub async fn save_proof(
let mut transaction = connection.start_transaction().await.unwrap();
transaction
.fri_prover_jobs_dal()
.save_proof(job_id, started_at.elapsed(), &blob_url)
.save_proof(job_id, time_taken, &blob_url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a bug. If the above code takes a lot of time, we mark time_taken differently, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm my thinking was that I wanted to keep the logs consistent with the DB entry for the time taken. I'm not sure I understand the question. If the above code takes time it doesn't matter, time_taken is computed once.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no requirement to keep the time consistent between logs. Logs are indicative of when actions happened. If you ask me, I'd add another log between the first one and the blob updated and use .elapsed() on save_proof. Sorry for being annoying on this one, but I don't want to change the semantics of our values, otherwise any other analysis I'll do in the future will be broken, given we measure time differently.

} else {
NaiveTime::from_hms_opt(hours, minutes, seconds).unwrap()
}
}
pub fn duration_to_naive_time(duration: Duration) -> NaiveTime {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can leave this function as it was, and compute ms in the _ms function and simply add it to NaiveTime generated by the function. Something across these lines:

duration_to_naive_time(...) + NaiveTime::from_hms_milli_opt(0, 0, 0, ms).

Hope that makes sense. Additionally (since you're touching this code base), let's turn the unwraps into .expect() with some nice message.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, fixed in c4973a3

Also changed the unwrap from the original function to an expect.

@EmilLuta
Copy link
Contributor

I think we need to run sqlx prepare and this PR is good to go. Check the failing CI, it'll guide you there. Also, have a look on traces recently introduced. It's very likely we'll get rid of these fields from database in favor of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants