Skip to content

Fix slow sync #1567

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 31, 2019
Merged

Fix slow sync #1567

merged 3 commits into from
May 31, 2019

Conversation

HoOngEe
Copy link
Contributor

@HoOngEe HoOngEe commented May 28, 2019

Now the total time taken for a node to synchronize with the corgi blocks is about 145 minutes.
Queued cache has introduced distinct from the downloaded cache in HeaderDownloader.
I failed to analyze the correct reason but decreasing MAX_HEADERS_TO_IMPORT down to 1,000 helps reducing sync time.
And lastly, in the current structure it doesn't help to spawn many threads because the cpu intensive jobs should be sequential. So I decreased it down to 2.

The following image shows the cpu time spent during 50,000 block synchronization.
with_queued_cache

Now the main cpu intensive jobs are all related to EC calculation for verification.

@HoOngEe HoOngEe changed the title [WIP] Fix/slow sync [WIP] Fix slow sync May 28, 2019
@sgkim126 sgkim126 added sync performance Something is slow labels May 29, 2019
@HoOngEe HoOngEe force-pushed the fix/slow-sync branch 2 times, most recently from 14a879e to 2d4328c Compare May 29, 2019 05:20
@HoOngEe HoOngEe requested review from remagpie and sgkim126 May 29, 2019 08:16
@HoOngEe HoOngEe force-pushed the fix/slow-sync branch 2 times, most recently from 67a43b3 to dab6124 Compare May 29, 2019 10:44
@HoOngEe HoOngEe changed the title [WIP] Fix slow sync Fix slow sync May 29, 2019
// FIXME: handle import errors
Err(err) => {
cwarn!(SYNC, "Cannot import header({}): {:?}", header.hash(), err);
break
}
_ => {}
_ => queued.push(hash),
Copy link
Contributor

Choose a reason for hiding this comment

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

You should handle only queue related error here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now I'm pushing hashes to the queue after importing error occurs.

.get(&self.pivot.hash)
.map(Clone::clone)
.or_else(|| self.client.block_header(&BlockId::Hash(self.pivot.hash)))
.unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you use function chaining here?
Using match seems to be more readable for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it to match style.

@remagpie
Copy link
Contributor

Please fix the commit message.
queued chache -> queued cache

@HoOngEe HoOngEe force-pushed the fix/slow-sync branch 2 times, most recently from 6b80947 to 2cd87be Compare May 30, 2019 02:21
remagpie
remagpie previously approved these changes May 30, 2019
@sgkim126
Copy link
Contributor

@HoOngEe Please resolve conflicts.

HoOngEe added 3 commits May 31, 2019 10:24
In current structure, multithreading helps little. Because the verification step should be sequential.
@HoOngEe
Copy link
Contributor Author

HoOngEe commented May 31, 2019

I resolved the conficts

@sgkim126 sgkim126 merged commit 535ad4f into CodeChain-io:master May 31, 2019
@HoOngEe HoOngEe deleted the fix/slow-sync branch May 31, 2019 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Something is slow sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants