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

Open the database in a blocking tokio thread #4821

Closed
Tracked by #3096
teor2345 opened this issue Jul 25, 2022 · 5 comments · Fixed by #5228
Closed
Tracked by #3096

Open the database in a blocking tokio thread #4821

teor2345 opened this issue Jul 25, 2022 · 5 comments · Fixed by #5228
Assignees
Labels
A-state Area: State / database changes C-bug Category: This is a bug I-slow Problems with performance or responsiveness I-usability Zebra is hard to understand or use

Comments

@teor2345
Copy link
Contributor

teor2345 commented Jul 25, 2022

Motivation

Zebra can take a long time to re-open the database after the initial sync:

2022-07-25T03:50:05.294821Z WARN {net="Main"}: zebra_chain::diagnostic: opening finalized state database code took a long time to execute execution_time="1m 8s" module_path=Some("zebra_state::service") line=Some(172)

We should do this work in a blocking thread, so it doesn't block the rest of the tokio executor.

Some RocksDB documentation warns that the first read can also be slow, so we might want to do it in the same blocking call.

Designs

  • Open the database and do the first database read using tokio::spawn_blocking() or tokio::block_in_place()
  • Log an info-level message before opening the database, so that users know it might take a while

Related Work

@teor2345 teor2345 added C-bug Category: This is a bug S-needs-triage Status: A bug report needs triage P-High 🔥 I-slow Problems with performance or responsiveness A-state Area: State / database changes and removed P-High 🔥 labels Jul 25, 2022
@conradoplg
Copy link
Collaborator

I wonder if some of these suggestions can also reduce the opening time

@oxarbitrage
Copy link
Contributor

@conradoplg , there is another ticket to try to apply some of those: #4822

@teor2345
Copy link
Contributor Author

This is something we want to do eventually, but it's not urgent.

@teor2345 teor2345 added the I-usability Zebra is hard to understand or use label Aug 23, 2022
@teor2345
Copy link
Contributor Author

We might want to do this usability fix some time during the release candidate series, but it's not a blocker.

@teor2345
Copy link
Contributor Author

@arya2 it's ok to do the spawn_blocking() in zebrad::commands::start or zebra_state::init(), whatever is easier.

@ftm1000 ftm1000 removed the S-needs-triage Status: A bug report needs triage label Sep 15, 2022
@mpguerra mpguerra moved this to 🆕 New in Zebra Sep 22, 2022
@mpguerra mpguerra added this to Zebra Sep 22, 2022
@mpguerra mpguerra moved this from 🆕 New to 🏗 In progress in Zebra Sep 22, 2022
@mergify mergify bot closed this as completed in #5228 Sep 26, 2022
Repository owner moved this from 🏗 In progress to ✅ Done in Zebra Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-state Area: State / database changes C-bug Category: This is a bug I-slow Problems with performance or responsiveness I-usability Zebra is hard to understand or use
Projects
Archived in project
5 participants