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

improvement: reduce times of querying header map #2151

Merged

Conversation

yangby-cryptape
Copy link
Collaborator

@yangby-cryptape yangby-cryptape commented Jul 3, 2020

I added some log outputs when do tests, I got the follow results:

  • Sync chain from height 0 to tip:
    • If always query the header map first.
      • Query the header map first but not found: about tip/2 ~ tip times (mark as x)
      • If not found in the header map, it must be in the store.
    • If query header from store first when the block in that height was already inserted into the chain database.
      • Query the header map first but not found: about tip/4 ~ tip/6 times (mark as y)
      • Query the store first but not found: 0
  • The result of my last test: tip = 2_230_953; x = 1_179_787; y = 552_325

@doitian doitian added this to 👀 Awaiting review in CKB - Pull Requests Jul 6, 2020
pub fn get_header_view(
&self,
hash: &Byte32,
store_first_opt: Option<bool>,
Copy link
Member

Choose a reason for hiding this comment

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

is it possible to use BlockStatus here?

BlockStatus::UNKNOWN => None,
BlockStatus::STORED => Some(true),
others => Some(false),

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This assume that tip.number() >= header.number() => BlockStatus::STORED, I'm not sure about that.
I just search store first when tip.number() >= header.number(), but not mean BlockStatus::STORED.

CKB - Pull Requests automation moved this from 👀 Awaiting review to ✅ Reviewer approved Jul 20, 2020
@quake
Copy link
Member

quake commented Jul 20, 2020

bors r=quake,TheWaWaR,driftluo

@bors
Copy link
Contributor

bors bot commented Jul 20, 2020

Build succeeded:

  • continuous-integration/travis-ci/push

@bors bors bot merged commit 37dac61 into nervosnetwork:develop Jul 20, 2020
CKB - Pull Requests automation moved this from ✅ Reviewer approved to Done Jul 20, 2020
@yangby-cryptape yangby-cryptape deleted the pr/reduce-times-of-query-headermap branch September 11, 2020 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants