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

spv: Move getheaders stage to global syncer instead of per-peer #2300

Merged
merged 2 commits into from
Nov 17, 2023

Conversation

matheusd
Copy link
Member

@matheusd matheusd commented Nov 17, 2023

This moves the fetch headers and cfilters stage from the per-peer startup function to the main syncer startup function.

This avoids wasting duplicate effort for every peer. In the future, this will allow using multiple peers to fetch headers and cfilters from, as well as allowing asynchronous fetching.

This change significantly reduces the amount of resources (cpu, ram, goroutines) used during the initial sync at the cost of increasing the sync time. The sync time will be reduced in the future as well, after parallelizing the headers/cfilters/chainswitch stages and after batched cfilter fetching is implemented and deployed.

Part of #2289

spv/sync.go Show resolved Hide resolved
p2p/peering.go Outdated Show resolved Hide resolved
This moves the fetch headers and cfilters from the peer startup to the
syncer startup.

This avoids wasting duplicate effort for every peer. In the future, this
will allow using multiple peers to fetch headers and cfilters from, as
well as allowing asynchronous fetching.
The locators are now only needed during the initial getHeaders sync
stage, therefore they are not needed in the global syncer struct.

Since they are accessed only from a single goroutine now, the mutex is
also unneeded.
@jrick jrick merged commit 0203f76 into decred:master Nov 17, 2023
2 checks passed
@matheusd matheusd deleted the global-getheaders branch November 17, 2023 17:11
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.

None yet

2 participants