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: Refactor initial cfilter fetching to be done in smaller batches #2307

Merged
merged 2 commits into from
Nov 28, 2023

Conversation

matheusd
Copy link
Member

This refactors the initial cfilter fetching to be based around requesting smaller batches of cfilters from the lower p2p level.

While this does not make any functional difference at the moment, in the future, when a P2P protocol with batched CFilter is supported (decred/dcrd#3211 or equivalent), it will be trivial to switch to using it for remote peers that support it.

Additionally, this reduces the total number of goroutines used for the underlying CFiltersV2() call from the p2p package, which is useful in slightly reducing the total cpu and memory loads during initial sync.

This splits cfilter fetching during initial sync to use smaller sized
batches of requests.

This makes the code ready to switch to batched cfilter fetching on a
per-peer basis when a new protocol version is introduced that supports
it.
This refactors the CFiltersV2 function to reduce the number of
goroutines used, therefore slightly reducing total cpu and memory load
and making it easier to run the race detector and debug issues.

The number of goroutines is reduced from one per block hash in the
request to two per call.  This is done by refactoring the code to use
one goroutine to send all requests and one to read the responses, while
ensuring that the requests are still sent as fast as the network stack
will allow it.
@jrick jrick merged commit 41fc943 into decred:master Nov 28, 2023
2 checks passed
@matheusd matheusd deleted the batched-cfilters branch November 28, 2023 20:55
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.

2 participants