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: concurrent download blocks on ibd #1957

Merged
merged 1 commit into from
Mar 19, 2020

Conversation

driftluo
Copy link
Collaborator

@driftluo driftluo commented Mar 6, 2020

As the chain height rises gradually, the synchronization duration increases linearly. This PR is the beginning of improving the synchronization time.

ckb synchronization is roughly divided into two blocks:

  • ibd(init block download), when tip block timestamp < now - 24h
  • Normal synchronization, when tip block timestamp > now - 24h

In the ibd process, currently only request a header map from a random node, and then initiate a download block request to the node based on the node's best-known header and the last common block calculated by the current tip.

In principle, block download does not limit the number of nodes requested, but because the ibd process only interacts with a node's header map during the ibd process, currently ibd can only download blocks from one node.

This pr uses the headers_locator_hash_list in the getheader request from the other node to try to restore the best-known header of the node through the locally synchronized header map and then expands the number of downloadable block nodes from one to the current outbound number

I used a Hong Kong cloud host for testing, its configuration is:

  • 4c 8g 100G hard drive 10M bandwidth
  • 4 Intel (R) Xeon (R) Platinum 8163 CPU @ 2.50GH

before:

Sync from 0 to 1013645, took 184 minutes, average speed 5509/min
Sync from 0 to 1017469,took 148 minutes,average speed 6874/min

after:

8 outbound peer, sync from 0 to 1015441,took 72 minutes,average speed 14103/min
8 outbound peer, sync from 0 to 1017339,took 102 minutes,average speed 9974/min
8 outbound peer, sync from 0 to 1017339,took 100 minutes,average speed 10173/min
16 outbound peer, sync from 0 to 1023994,took 93 minutes,average speed 11010/min
32 outbound peer, sync from 0 to 494467,took 110 minutes,average speed 4495/min

When the number of sync nodes reaches 32, it seems that the download logic itself is a bit problem and further observation is needed, but this does not affect the modification of pr itself.

sync/src/synchronizer/mod.rs Outdated Show resolved Hide resolved
sync/src/synchronizer/block_fetcher.rs Outdated Show resolved Hide resolved
sync/src/types.rs Show resolved Hide resolved
sync/src/types.rs Outdated Show resolved Hide resolved
@doitian doitian added this to 👀 Awaiting review in CKB - Pull Requests Mar 9, 2020
sync/src/types.rs Outdated Show resolved Hide resolved
sync/src/synchronizer/block_fetcher.rs Outdated Show resolved Hide resolved
doitian added a commit that referenced this pull request Mar 10, 2020
feat: concurrent download blocks on ibd
sync/src/synchronizer/mod.rs Outdated Show resolved Hide resolved
sync/src/synchronizer/mod.rs Outdated Show resolved Hide resolved
sync/src/synchronizer/mod.rs Outdated Show resolved Hide resolved
pub fn try_update_best_known_with_unknown_header_list(&self, pi: PeerIndex) {
// header list Is an ordered list, sorted from highest to lowest,
// when header hash unknown, break loop is ok
while let Some(hash) = self.peers().take_unknown_last(pi) {
Copy link
Member

Choose a reason for hiding this comment

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

👍

doitian
doitian previously approved these changes Mar 19, 2020
@doitian
Copy link
Member

doitian commented Mar 19, 2020

Hey folks, please review @quake @keroro520 @zhangsoledad

quake
quake previously approved these changes Mar 19, 2020
CKB - Pull Requests automation moved this from 👀 Awaiting review to ✅ Reviewer approved Mar 19, 2020
@doitian
Copy link
Member

doitian commented Mar 19, 2020

Please rebase

@doitian doitian added the s:waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. label Mar 19, 2020
@driftluo driftluo dismissed stale reviews from quake and doitian via 27f38fa March 19, 2020 07:11
CKB - Pull Requests automation moved this from ✅ Reviewer approved to 👀 Awaiting review Mar 19, 2020
@doitian doitian merged commit 4793b88 into nervosnetwork:develop Mar 19, 2020
CKB - Pull Requests automation moved this from 👀 Awaiting review to Done Mar 19, 2020
@driftluo driftluo deleted the optimize-ibd-sync branch March 19, 2020 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s:waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author.
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants