Skip to content

Reduce booting time by using is_empty method #1526

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 3 commits into from
May 12, 2019

Conversation

HoOngEe
Copy link
Contributor

@HoOngEe HoOngEe commented May 10, 2019

The previous version of codechain booting time is so slow when the db is heavy. The reason is that when codechain checks if db is empty, it used db.keys().is_empty(). The routine had collected all the keys in the db to a hashmap, so the majority of the booting time was occupied by the routine for iterating and collecting keys.
I sent the method is_empty in JournalDB up to HashDB and used the method in db empty checking.

It closes #1513

@foriequal0
Copy link
Contributor

Why do we have method that returns entire keys for the DB in the first place?

@mergify mergify bot merged commit 7d53cb0 into CodeChain-io:master May 12, 2019
@HoOngEe
Copy link
Contributor Author

HoOngEe commented May 13, 2019

The original method keys() in HashDB is part of parity's implementation and I'm just guessing that we used db.keys().is_emtpy() because there was no db.is_empty().

@HoOngEe HoOngEe deleted the improve/enhance-boot-time branch May 13, 2019 02:43
@sgkim126 sgkim126 added the performance Something is slow label May 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Long booting time when there are many blocks.
3 participants