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

Parallel fetch for chain sync #3887

Merged
merged 11 commits into from
Sep 23, 2020
Merged

Parallel fetch for chain sync #3887

merged 11 commits into from
Sep 23, 2020

Conversation

vyzo
Copy link
Contributor

@vyzo vyzo commented Sep 16, 2020

Also fixes stream leaks during sync.

@vyzo vyzo changed the title Feat/parallel sync Parallel chain sync Sep 16, 2020
@vyzo vyzo marked this pull request as ready for review September 16, 2020 19:11
@vyzo
Copy link
Contributor Author

vyzo commented Sep 16, 2020

Marked as ready to review as it seems to be working; I'll wait for my node to do a full sync and figure out how long it takes.

Please make suggestions for improvements, this is step 1.

@vyzo vyzo changed the title Parallel chain sync Parallel fetch for chain sync Sep 17, 2020
@vyzo
Copy link
Contributor Author

vyzo commented Sep 17, 2020

rebased on master.


mx.Lock()
if requestResult != nil {
copy(batch[j+offset:], requestResult)
Copy link
Contributor

Choose a reason for hiding this comment

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

I concurrent reslice and copy into a slice safe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might be safe, I am just not sure -- hence the lock.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or do you mean the copy operation on the reslice? That should be perfectly fine, we make a new slice and then we copy.

Copy link
Contributor

Choose a reason for hiding this comment

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

I 100% missed the lock ;p

@vyzo
Copy link
Contributor Author

vyzo commented Sep 21, 2020

fixed a minor issue in the end of sync, there was an off by 1 in the batch size.

note that it didn't prevent from syncing, it just required an extra call to fetchMessages.

@whyrusleeping
Copy link
Member

running this i seem to get a lot of:

2020-09-22T22:21:14.558-0700	WARN	chainxchg	exchange/client.go:112	could not connect to peer 12D3KooWCrx8yVG9U9Kf7w8KLN3Edkj5ZKDhgCaeMqQbcQUoB6CT: failed to read chainxchg response: i/o deadline reached
2020-09-22T22:21:16.885-0700	WARN	chainxchg	exchange/client.go:112	could not connect to peer 12D3KooW9yeKXha4hdrJKq74zEo99T8DhriQdWNoojWnnQbsgB3v: failed to read chainxchg response: i/o deadline reached
2020-09-22T22:21:18.232-0700	WARN	chainxchg	exchange/client.go:112	could not connect to peer 12D3KooWKYSsbpgZ3HAjax5M1BXCwXLa6gVkUARciz7uN3FNtr7T: failed to read chainxchg response: i/o deadline reached
2020-09-22T22:21:18.240-0700	WARN	chainxchg	exchange/client.go:112	could not connect to peer 12D3KooWQYzqnLASJAabyMpPb1GcWZvNSe7JDcRuhdRqonFoiK9W: failed to read chainxchg response: i/o deadline reached
2020-09-22T22:21:18.408-0700	WARN	chainxchg	exchange/client.go:112	could not connect to peer 12D3KooWPkL9LrKRQgHtq7kn9ecNhGU9QaziG8R5tX8v9v7t3h34: failed to read chainxchg response: i/o deadline reached
2020-09-22T22:21:18.648-0700	WARN	chainxchg	exchange/client.go:112	could not connect to peer 12D3KooWKdy1XigjH7mJ8ZM4bULqSJnUYV8UJ6AggGvRSGzWCoSV: failed to read chainxchg response: i/o deadline reached

@vyzo
Copy link
Contributor Author

vyzo commented Sep 23, 2020

Yeah, that's kind of expected, we use more peers so at startup we might select some bad ones.

Copy link
Member

@whyrusleeping whyrusleeping left a comment

Choose a reason for hiding this comment

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

LGTM, and works well on my machine!

@magik6k magik6k merged commit a2278e2 into master Sep 23, 2020
@magik6k magik6k deleted the feat/parallel-sync branch September 23, 2020 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants